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
38c3d9df
Commit
38c3d9df
authored
Feb 15, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
random tune
parent
413104d9
Pipeline
#546
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
generateRandom.js
src/api/generateRandom.js
+17
-7
No files found.
src/api/generateRandom.js
View file @
38c3d9df
...
@@ -99,7 +99,7 @@ module.exports = {
...
@@ -99,7 +99,7 @@ module.exports = {
let
used
=
{},
generated
=
0
;
let
used
=
{},
generated
=
0
;
let
last
=
{
c
:
-
1
},
let
last
=
{
c
:
-
1
},
list
=
[],
list
=
[],
globalMaxTries
=
args
.
count
*
5
,
globalMaxTries
=
args
.
count
*
5
00
,
globalTries
=
0
;
globalTries
=
0
;
if
(
args
.
count
>
100
)
args
.
count
=
100
;
if
(
args
.
count
>
100
)
args
.
count
=
100
;
while
(
generated
<
args
.
count
&&
globalTries
<
globalMaxTries
){
while
(
generated
<
args
.
count
&&
globalTries
<
globalMaxTries
){
...
@@ -109,18 +109,19 @@ module.exports = {
...
@@ -109,18 +109,19 @@ module.exports = {
p
:
seeded
()
>
0.7
,
p
:
seeded
()
>
0.7
,
c
:
1
c
:
1
};
};
if
(
last
.
c
===
1
&&
seeded
()
>
0.5
){
if
(
seeded
()
>
0.3
){
//if( last.c === 1 && seeded() > 0.5 ){
cur
=
{
cur
=
{
c
:
2
c
:
2
};
};
let
id
,
tries
=
0
;
let
id
,
tries
=
0
;
do
{
/*
do{
id = rand(1, countStdQ);
id = rand(1, countStdQ);
tries++;
tries++;
if(tries === 100){
if(tries === 100){
break;
break;
}
}
}
while
(
'2.'
+
id
in
used
);
}while('2.'+id in used);
*/
if
(
tries
===
100
)
if
(
tries
===
100
)
continue
;
continue
;
cur
.
id
=
id
;
cur
.
id
=
id
;
...
@@ -132,8 +133,16 @@ module.exports = {
...
@@ -132,8 +133,16 @@ module.exports = {
if
(
cur
.
c
===
1
){
if
(
cur
.
c
===
1
){
result
=
ctx
.
quizGenerator
(
cur
.
m
?
'checkbox'
:
'radio'
,
cur
.
p
);
result
=
ctx
.
quizGenerator
(
cur
.
m
?
'checkbox'
:
'radio'
,
cur
.
p
);
}
else
{
}
else
{
let
counter
=
0
,
r
=
2
;
result
=
ctx
.
standardGenerator
(()
=>
cur
.
id
)
do
{
r
=
rand
(
1
,
countStdQ
);
let
q
=
data
.
standardQuestions
[
r
];
if
(
q
&&
!
(
q
.
category_id
+
'.'
+
q
.
qID
in
used
))
break
;
counter
++
;
}
while
(
counter
<
100
);
result
=
ctx
.
standardGenerator
(()
=>
r
);
if
(
result
)
if
(
!
result
){
if
(
!
result
){
tries
=
100
;
tries
=
100
;
break
;
break
;
...
@@ -143,8 +152,9 @@ module.exports = {
...
@@ -143,8 +152,9 @@ module.exports = {
if
(
tries
===
100
)
if
(
tries
===
100
)
break
;
break
;
}
while
(
result
.
categoryId
+
'.'
+
result
.
productId
in
used
);
}
while
(
result
.
categoryId
===
last
.
c
||
result
.
categoryId
+
'.'
+
result
.
productId
in
used
);
if
(
tries
!==
100
){
if
(
tries
!==
100
){
cur
.
c
=
result
.
categoryId
;
used
[
result
.
categoryId
+
'.'
+
result
.
productId
]
=
true
;
used
[
result
.
categoryId
+
'.'
+
result
.
productId
]
=
true
;
list
.
push
(
result
);
list
.
push
(
result
);
...
...
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