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
0299c626
Commit
0299c626
authored
Mar 06, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new tag based sequence generator
parent
2ea85a78
Pipeline
#566
canceled with stage
Changes
5
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
199 additions
and
96 deletions
+199
-96
checkbox.js
public/js/controller/quizBits/checkbox.js
+2
-2
main.js
public/js/controller/quizBits/main.js
+11
-11
radio.js
public/js/controller/quizBits/radio.js
+2
-2
quizGenerator.js
public/js/controller/quizGenerator.js
+8
-8
generateRandom.js
src/api/generateRandom.js
+176
-73
No files found.
public/js/controller/quizBits/checkbox.js
View file @
0299c626
...
...
@@ -77,14 +77,14 @@ quizTypes.checkbox = [ ComponentsOfProduct = {
type
:
'Select components of product'
,
products
:
{
from
:
2
,
to
:
4
},
minSimilarTags
:
1
,
from
(
log
){
from
(
log
,
isTest
){
const
products
=
qB
.
randomProduct
({
minComponents
:
1
,
amount
:
this
.
products
,
connectedByTags
:
true
,
minSimilarTags
:
this
.
minSimilarTags
,
doNotTrim
:
true
},
log
),
},
log
,
isTest
),
componentsWithProducts
=
qB
.
getComponentsWithSharedProducts
(
products
,
2
);
...
...
public/js/controller/quizBits/main.js
View file @
0299c626
...
...
@@ -7,7 +7,7 @@ const qB = {
minSimilarTags
,
doNotTrim
,
withPhoto
},
log
)
{
},
log
,
isTest
)
{
let
filtered
=
Object
.
values
(
dP
.
products
);
...
...
@@ -74,7 +74,7 @@ const qB = {
similarClusters
=
Object
.
keys
(
similarTags
)
.
map
(
k
=>
({
k
,
v
:
similarTags
[
k
]}))
.
filter
(
a
=>
a
.
v
.
length
>=
minAmount
&&
a
.
v
.
filter
(
av
=>
av
.
use
).
length
>
0
);
.
filter
(
a
=>
a
.
v
.
length
>=
minAmount
&&
a
.
v
.
filter
(
isTest
).
length
>
0
);
log
.
push
(
`Clusters that have >=
${
minSimilarTags
}
similar tags: `
+
Object
.
values
(
similarClusters
).
length
);
...
...
@@ -89,7 +89,7 @@ const qB = {
let
result
;
if
(
single
){
result
=
rand
(
filtered
.
filter
(
p
=>
p
.
use
));
result
=
rand
(
filtered
.
filter
(
isTest
));
log
.
push
(
'Matched product: '
+
result
.
title
);
}
else
{
...
...
@@ -98,7 +98,7 @@ const qB = {
return
false
;
}
let
used
=
rand
(
filtered
.
filter
(
p
=>
p
.
use
)),
let
used
=
rand
(
filtered
.
filter
(
isTest
)),
other
=
filtered
.
slice
();
other
.
splice
(
other
.
indexOf
(
used
));
...
...
@@ -192,11 +192,11 @@ const qB = {
prebuild
:
{
similarTaggedProductWithPhotoAndComponents
:
{
fn
:
function
(
log
)
{
fn
:
function
(
log
,
isTest
)
{
this
.
getEmAll
=
true
;
this
.
products
=
{
min
:
2
};
const
possibilities
=
shuffle
(
qB
.
prebuild
.
similarTaggedProductWithPhoto
.
fn
.
call
(
this
,
log
)
qB
.
prebuild
.
similarTaggedProductWithPhoto
.
fn
.
call
(
this
,
log
,
isTest
)
);
if
(
!
possibilities
||
!
possibilities
.
length
)
return
false
;
...
...
@@ -238,7 +238,7 @@ const qB = {
questionMinComponentsCount
:
Number
,
products
:
{
min
:
Number
,
max
:
Number
},
fn
:
function
(
log
)
{
fn
:
function
(
log
,
isTest
)
{
let
allProducts
=
Object
.
values
(
dP
.
products
);
let
products
=
Object
.
values
(
dP
.
products
)
.
filter
(
p
=>
p
.
image
)
...
...
@@ -251,7 +251,7 @@ const qB = {
}
const
possibility
=
products
.
map
(
p
=>
{
if
(
!
p
.
use
)
if
(
!
isTest
(
p
)
)
return
false
;
const
similar
=
qB
.
getProductsWithTags
({
products
:
allProducts
,
...
...
@@ -285,20 +285,20 @@ const qB = {
// product similarity (minimal matched tags count)
minSimilarTags
:
2
,
fn
(
log
){
fn
(
log
,
isTest
){
let
products
=
qB
.
randomProduct
({
minComponents
:
this
.
questionCmpAmount
,
amount
:
this
.
products
,
connectedByTags
:
true
,
minSimilarTags
:
this
.
minSimilarTags
},
log
);
},
log
,
isTest
);
for
(
let
i
=
0
,
_i
=
products
.
length
;
i
<
_i
;
i
++
){
const
product
=
products
[
i
];
/* if(this.withPhoto && !product.image)
continue;*/
if
(
!
product
.
use
)
if
(
!
isTest
(
product
)
)
continue
;
const
cmps
=
product
.
getComponents
()
...
...
public/js/controller/quizBits/radio.js
View file @
0299c626
...
...
@@ -88,8 +88,8 @@ quizTypes.radio = [
question
:
({
product
})
=>
`Выберите лишний ингредиент, НЕ входящий в продукт "
${
product
.
title
}
"`
,
type
:
'Do not contain'
,
from
:
(
log
)
=>
{
const
product
=
qB
.
randomProduct
({
minComponents
:
2
,
single
:
true
},
log
);
from
:
(
log
,
isTest
)
=>
{
const
product
=
qB
.
randomProduct
({
minComponents
:
2
,
single
:
true
},
log
,
isTest
);
return
{
baseProduct
:
product
,
product
}
},
...
...
public/js/controller/quizGenerator.js
View file @
0299c626
...
...
@@ -81,10 +81,10 @@ const standardGenerator = function(random) {
log
};
};
const
quizGenerator
=
function
(
type
,
photo
,
subType
)
{
return
_quizGenerator
(
type
,
photo
,
subType
);
const
quizGenerator
=
function
(
type
,
photo
,
isTest
,
subType
)
{
return
_quizGenerator
(
type
,
photo
,
isTest
,
subType
);
},
_quizGenerator
=
function
(
type
,
photo
,
subType
,
attempt
)
{
_quizGenerator
=
function
(
type
,
photo
,
isTest
,
subType
,
attempt
)
{
attempt
=
attempt
||
0
;
const
initialSeed
=
Math
.
random
.
seeded
.
getStringSeed
();
let
log
;
...
...
@@ -119,23 +119,23 @@ const quizGenerator = function(type, photo, subType) {
if
(
!
cfg
)
return
{
answers
:
[],
log
};
const
source
=
cfg
.
from
.
call
(
cfg
,
log
);
const
source
=
cfg
.
from
.
call
(
cfg
,
log
,
isTest
);
if
(
source
===
false
){
// давай по новой
return
_quizGenerator
(
type
,
photo
,
subType
,
attempt
+
1
);
return
_quizGenerator
(
type
,
photo
,
isTest
,
subType
,
attempt
+
1
);
}
let
answers
=
shuffle
(
cfg
.
answer
.
call
(
cfg
,
source
,
log
));
let
answers
=
shuffle
(
cfg
.
answer
.
call
(
cfg
,
source
,
log
,
isTest
));
if
(
answers
===
false
||
answers
.
length
===
1
){
// давай по новой
return
_quizGenerator
(
type
,
photo
,
subType
,
attempt
+
1
);
return
_quizGenerator
(
type
,
photo
,
isTest
,
subType
,
attempt
+
1
);
}
return
{
seed
:
initialSeed
,
type
,
categoryId
:
1
,
productId
:
source
.
baseProduct
.
id
,
question
:
cfg
.
question
.
call
(
cfg
,
source
,
log
),
question
:
cfg
.
question
.
call
(
cfg
,
source
,
log
,
isTest
),
answers
,
image
:
!
photo
?
null
:
source
.
baseProduct
.
image
,
...
...
src/api/generateRandom.js
View file @
0299c626
This diff is collapsed.
Click to expand it.
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