Skip to content

Commit 3a45b96

Browse files
feat: Add logic to select and enqueue least done exercise based on user performance
1 parent a86ec4f commit 3a45b96

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/start_training.clp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,50 @@
6464
)
6565
else
6666
(printout t "User '" ?user "' has already done exercises in domain '" ?domain:name "'" crlf)
67+
; Select the least done exercise in the domain
68+
(bind ?min-done 100000) ; Initialize with high value
69+
(bind ?next-cog-ex nil) ; Initialize with nil
70+
(bind ?next-cog-ex-level 0) ; Initialize with 0
71+
(bind ?last-ex-score 0) ; Initialize with 0
72+
; Iterate over all exercises done by the user in the domain
73+
(do-for-all-facts ((?ex-done-user ExerciseDone_user) (?ex-done-exercise ExerciseDone_exercise) (?ex-done-done ExerciseDone_done) (?ex-done-level ExerciseDone_level) (?ex-done-score ExerciseDone_score) (?cog-ex-domain CognitiveExercise_domain))
74+
(and
75+
(eq ?ex-done-user:item_id ?ex-done-exercise:item_id)
76+
(eq ?ex-done-user:item_id ?ex-done-done:item_id)
77+
(eq ?ex-done-user:item_id ?ex-done-level:item_id)
78+
(eq ?ex-done-user:item_id ?ex-done-score:item_id)
79+
(eq ?ex-done-user:user ?user)
80+
(eq ?ex-done-exercise:exercise ?cog-ex-domain:item_id)
81+
(eq ?cog-ex-domain:domain ?domain:item_id))
82+
(printout t "User '" ?user "' has done exercise '" ?ex-done-exercise:exercise "' at level " ?ex-done-level:level " with score " ?ex-done-score:score " " ?ex-done-done:done " times" crlf)
83+
(if (< ?ex-done-done:done ?min-done)
84+
then
85+
(bind ?min-done ?ex-done-done:done)
86+
(bind ?next-cog-ex ?ex-done-exercise:exercise)
87+
(bind ?next-cog-ex-level ?ex-done-level:level)
88+
(bind ?last-ex-score ?ex-done-score:score)
89+
)
90+
)
91+
(if (neq ?next-cog-ex nil)
92+
then
93+
(printout t "User '" ?user "' has done exercise '" ?next-cog-ex "' at level " ?next-cog-ex-level " the least number of times: " ?min-done crlf)
94+
(if (< ?last-ex-score 0.3)
95+
then
96+
(enqueue-exercise ?next-cog-ex (min (- ?next-cog-ex-level 1) 1))
97+
(enqueue-exercise ?next-cog-ex (min (- ?next-cog-ex-level 1) 1))
98+
else
99+
(if (< ?last-ex-score 0.6)
100+
then
101+
(enqueue-exercise ?next-cog-ex ?next-cog-ex-level)
102+
(enqueue-exercise ?next-cog-ex ?next-cog-ex-level)
103+
else
104+
(enqueue-exercise ?next-cog-ex (min (+ ?next-cog-ex-level 1) 6))
105+
(enqueue-exercise ?next-cog-ex (min (+ ?next-cog-ex-level 1) 6))
106+
)
107+
)
108+
else
109+
(printout t "No exercises found for user '" ?user "' in domain '" ?domain:name "'" crlf)
110+
)
67111
)
68112
)
69113
; Execute the first available exercise

0 commit comments

Comments
 (0)