Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kus-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
kus-admin
Commits
298d9d71
Commit
298d9d71
authored
Feb 13, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stats
parent
b3873449
Pipeline
#544
canceled with stage
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
6 deletions
+43
-6
db.js
db.js
+3
-2
quizGenerator.js
public/js/controller/quizGenerator.js
+1
-1
generateRandom.js
src/api/generateRandom.js
+39
-3
No files found.
db.js
View file @
298d9d71
...
@@ -507,7 +507,7 @@ data = {tags:[], connections:[], more:[], standardQuestions: {}, standardAnswers
...
@@ -507,7 +507,7 @@ data = {tags:[], connections:[], more:[], standardQuestions: {}, standardAnswers
},
},
index
:
'id'
index
:
'id'
});
});
debugger
theInc
();
theInc
();
data
.
components
=
await
readCSV
({
data
.
components
=
await
readCSV
({
fileName
:
path
.
join
(
base
,
moreElement
.
i
),
fileName
:
path
.
join
(
base
,
moreElement
.
i
),
...
@@ -588,6 +588,7 @@ data = {tags:[], connections:[], more:[], standardQuestions: {}, standardAnswers
...
@@ -588,6 +588,7 @@ data = {tags:[], connections:[], more:[], standardQuestions: {}, standardAnswers
a.cardInfoID = adishen+a.cardInfoID;
a.cardInfoID = adishen+a.cardInfoID;
a.qID = adishen+a.qID;
a.qID = adishen+a.qID;
a.category_id = moreElement.q[0]|0;
a.answers = [];
a.answers = [];
a.multiple = ( a.multiple + '' )[ 0 ].toLowerCase() in { '
д
': 1, '
1
': 1, '
y
': '
1
', '
c
': '
1
' };
a.multiple = ( a.multiple + '' )[ 0 ].toLowerCase() in { '
д
': 1, '
1
': 1, '
y
': '
1
', '
c
': '
1
' };
a.image = null;
a.image = null;
...
@@ -605,7 +606,7 @@ data = {tags:[], connections:[], more:[], standardQuestions: {}, standardAnswers
...
@@ -605,7 +606,7 @@ data = {tags:[], connections:[], more:[], standardQuestions: {}, standardAnswers
types: {
types: {
qID: Number,
qID: Number,
title: String,
title: String,
correct:
Number
correct:
String
},
},
postProcess: ( a, inc ) => {
postProcess: ( a, inc ) => {
if( a.title.trim() === '' ) return false;
if( a.title.trim() === '' ) return false;
...
...
public/js/controller/quizGenerator.js
View file @
298d9d71
...
@@ -68,7 +68,7 @@ const standardGenerator = function(random) {
...
@@ -68,7 +68,7 @@ const standardGenerator = function(random) {
return
{
return
{
type
:
q
.
multiple
?
'checkbox'
:
'radio'
,
type
:
q
.
multiple
?
'checkbox'
:
'radio'
,
categoryId
:
q
.
category
,
categoryId
:
q
.
category
_id
,
productId
:
q
.
qID
,
productId
:
q
.
qID
,
question
:
textFormat
(
q
.
title
),
question
:
textFormat
(
q
.
title
),
answers
:
shuffle
(
q
.
answers
.
map
(
a
=>
answers
:
shuffle
(
q
.
answers
.
map
(
a
=>
...
...
src/api/generateRandom.js
View file @
298d9d71
...
@@ -89,16 +89,18 @@ module.exports = {
...
@@ -89,16 +89,18 @@ module.exports = {
seed
:
{
required
:
false
,
description
:
'initialize random state. Make response determined'
,
type
:
String
},
seed
:
{
required
:
false
,
description
:
'initialize random state. Make response determined'
,
type
:
String
},
photo
:
{
required
:
false
,
description
:
'question with photo'
,
type
:
Boolean
},
photo
:
{
required
:
false
,
description
:
'question with photo'
,
type
:
Boolean
},
type
:
{
required
:
false
,
description
:
'1 - products, 2 - standards'
,
type
:
Number
},
type
:
{
required
:
false
,
description
:
'1 - products, 2 - standards'
,
type
:
Number
},
nolog
:
{
required
:
false
,
description
:
'remove human readable log'
,
type
:
Boolean
}
nolog
:
{
required
:
false
,
description
:
'remove human readable log'
,
type
:
Boolean
},
stats
:
{
required
:
false
,
description
:
'aggregate stats and explain questions'
,
type
:
Boolean
},
},
},
fn
:
async
function
(
args
)
{
fn
:
async
function
(
args
,
req
,
res
)
{
let
seed
=
args
.
seed
||
Math
.
random
().
toString
(
36
).
substr
(
2
);
let
seed
=
args
.
seed
||
Math
.
random
().
toString
(
36
).
substr
(
2
);
ctx
.
seeded
.
setStringSeed
(
seed
);
ctx
.
seeded
.
setStringSeed
(
seed
);
let
used
=
{},
generated
=
0
;
let
used
=
{},
generated
=
0
;
let
last
=
{
c
:
-
1
},
let
last
=
{
c
:
-
1
},
list
=
[],
list
=
[],
globalMaxTries
=
args
.
count
*
100
,
globalMaxTries
=
args
.
count
*
5
,
globalTries
=
0
;
globalTries
=
0
;
if
(
args
.
count
>
100
)
args
.
count
=
100
;
while
(
generated
<
args
.
count
&&
globalTries
<
globalMaxTries
){
while
(
generated
<
args
.
count
&&
globalTries
<
globalMaxTries
){
globalTries
++
;
globalTries
++
;
let
cur
=
{
let
cur
=
{
...
@@ -152,6 +154,40 @@ module.exports = {
...
@@ -152,6 +154,40 @@ module.exports = {
result
.
number
=
generated
;
result
.
number
=
generated
;
}
}
}
}
if
(
args
.
stats
){
res
.
header
(
"Content-Type"
,
"text/html; charset=utf-8"
);
let
stats
=
{};
let
statsImage
=
{};
let
statsCategory
=
{};
let
statsType
=
{};
list
.
forEach
(
i
=>
{
if
(
i
.
categoryId
===
void
0
)
debugger
;
let
key
=
i
.
type
+
', '
+
(
i
.
image
?
'image'
:
'no image'
)
+
', '
+
i
.
categoryId
;
stats
[
key
]
=
(
stats
[
key
]
||
0
)
+
1
;
key
=
i
.
type
+
''
;
statsType
[
key
]
=
(
statsType
[
key
]
||
0
)
+
1
;
key
=
(
i
.
image
?
'image'
:
'no image'
);
statsImage
[
key
]
=
(
statsImage
[
key
]
||
0
)
+
1
;
key
=
i
.
categoryId
+
''
;
statsCategory
[
key
]
=
(
statsCategory
[
key
]
||
0
)
+
1
;
});
return
'<HTML><head></head><body>'
+
`<h2>Generated:
${
list
.
length
}
</h2>`
+
'<div>'
+
Object
.
keys
(
stats
).
map
(
k
=>
`<b>
${
k
}
</b>: <span>
${
stats
[
k
]}
</span>`
).
join
(
'<br/>'
)
+
'</div>'
+
'<h2>Image</h2><div>'
+
Object
.
keys
(
statsImage
).
map
(
k
=>
`<b>
${
k
}
</b>: <span>
${
statsImage
[
k
]}
</span>`
).
join
(
'<br/>'
)
+
'</div>'
+
'<h2>Category</h2><div>'
+
Object
.
keys
(
statsCategory
).
map
(
k
=>
`<b>
${
k
}
</b>: <span>
${
statsCategory
[
k
]}
</span>`
).
join
(
'<br/>'
)
+
'</div>'
+
'<h2>Type</h2><div>'
+
Object
.
keys
(
statsType
).
map
(
k
=>
`<b>
${
k
}
</b>: <span>
${
statsType
[
k
]}
</span>`
).
join
(
'<br/>'
)
+
'</div>'
+
'</body></HTML>'
}
return
list
;
return
list
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment