Commit b3873449 by Иван Кубота

fix standard generation

parent d203ac43
Pipeline #543 failed with stage
......@@ -56,6 +56,8 @@ const standardGenerator = function(random) {
const log = quizGenerator.log = ['Random seed: '+initialSeed];
const questionID = random(Object.values(dP.standardQuestions)),
q = dP.standardQuestions[questionID];
if(!q)
return false;
log.push('Creating standard question.');
log.push('It would be question number '+questionID);
log.push('');
......
......@@ -65,11 +65,14 @@ module.exports = {
photo = seeded() > 0.7,
result;
if((args.type !== void 0 ? args.type === 2: seeded()>0.5)){
result = ctx.standardGenerator(()=>rand(1,countStdQ))
while(!result){
if( ( args.type !== void 0 ? args.type === 2 : seeded() > 0.5 ) ){
result = ctx.standardGenerator( () => rand( 1, countStdQ ) )
}else{
result = ctx.quizGenerator( multiple ? 'checkbox' : 'radio', args.photo !== void 0 ? args.photo : photo );
}
}
console.log(`cat: ${result.categoryId}, prod: ${result.productId}, seed: ${seed}. ${result.question.substr(0,33)}`);
if(args.nolog)
......@@ -128,6 +131,10 @@ module.exports = {
}else{
result = ctx.standardGenerator(()=>cur.id)
if(!result){
tries = 100;
break;
}
}
tries++;
if(tries === 100)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment