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
a036f87a
Commit
a036f87a
authored
Feb 13, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
human readable generator
parent
298d9d71
Pipeline
#545
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
generateRandom.js
src/api/generateRandom.js
+33
-0
No files found.
src/api/generateRandom.js
View file @
a036f87a
...
@@ -91,6 +91,7 @@ module.exports = {
...
@@ -91,6 +91,7 @@ module.exports = {
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
},
stats
:
{
required
:
false
,
description
:
'aggregate stats and explain questions'
,
type
:
Boolean
},
human
:
{
required
:
false
,
description
:
'aggregate stats and explain questions'
,
type
:
Boolean
}
},
},
fn
:
async
function
(
args
,
req
,
res
)
{
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
);
...
@@ -187,7 +188,39 @@ module.exports = {
...
@@ -187,7 +188,39 @@ module.exports = {
'<h2>Type</h2><div>'
+
Object
.
keys
(
statsType
).
map
(
k
=>
`<b>
${
k
}
</b>: <span>
${
statsType
[
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>'
'</body></HTML>'
}
}
if
(
args
.
human
){
res
.
header
(
"Content-Type"
,
"text/html; charset=utf-8"
);
return
'<HTML><head>'
+
`<style>
.hidden {
display: none
}
.how-block {
white-space: pre-wrap;
padding: 0 16px;
border-left: 4px solid #ff0060;
}
.seed {color: #999}
.title {font-size:26px}
*{font-family: Verdana;}
pre {font-family: monospace;}
.how {color: #ff0060;border-bottom: 1px dotted;font-size:14px;cursor: pointer}
</style><script>var toggle=function(a){a.parentNode.parentNode.querySelector('.how-block').classList.toggle('hidden')}</script>`
+
'</head><body><div class="seed">seed: '
+
seed
+
'</div> '
+
list
.
map
((
result
,
i
)
=>
`<div class="quest"><div class="title">
${
i
+
1
}
)
${
result
.
question
}
<span class="how" onclick="toggle(this)">Как так получилось?</span></div>
<pre>
${
result
.
answers
.
map
(
a
=>
(
(
result
.
type
===
'checkbox'
?(
a
.
correct
?
'[v]'
:
'[ ]'
):(
a
.
correct
?
'(o)'
:
'( )'
))
+
' '
+
a
.
text
)
).
join
(
'
\
n'
)}
</pre>
<pre class="how-block hidden">
${
result
.
log
.
join
(
'
\
n'
)}
</pre>
</div>
`
).
join
(
'<br/><br/>'
)
+
'</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