Skip to content

Commit

Permalink
work in progress on grading done button
Browse files Browse the repository at this point in the history
and getting associated hints working again.
Testing, mostly works.
  • Loading branch information
bvds committed Dec 1, 2011
1 parent 7a9cdba commit 1dfa985
Show file tree
Hide file tree
Showing 17 changed files with 383 additions and 254 deletions.
12 changes: 1 addition & 11 deletions Help/API.cl
Expand Up @@ -95,17 +95,7 @@
close-problem
check-entries
))

;; --------------------------------------------------------------
;; Autocalc
;; There is only one autocalc api. It is what we use to return
;; the score values and as such constiutes a separate class of
;; return value. This is used for displaying the students scores
;; to them at runtime.
(Statistics .
(set-stats
get-stats))


;; -------------------------------------------------------------
;; Noneq-Entry
;; non-eq entries such as assert object are dde's that post a
Expand Down
49 changes: 31 additions & 18 deletions Help/Entry-API.cl
Expand Up @@ -1656,37 +1656,50 @@
;; Having done that look up the corresponding PSM and determine if the PSM
;; has been completed if so then the value is green if not then don't.
(defun check-mc-no-quant-done-answer-sought (entry)
(let* ((id (second (StudentEntry-prop entry)))
(PSM (match-exp->enode ID (problem-graph *cp*)))
;; corresponding systementry
(sysent (find-SystemEntry (StudentEntry-prop entry))))
(let* ((id (second (StudentEntry-prop entry))) ;prop of task to be done
;; Corresponding systementry for done button.
(sysent (find-SystemEntry (StudentEntry-prop entry)))
;; Find enode that is associated with the done button.
(PSM (find-if
#'(lambda (x) (member sysent x))
(bubblegraph-enodes (problem-graph *cp*))
:key #'enode-entries)))
(cond
;; If the PSM is not found then we need to throw an error saying that.
((null PSM)
(make-bad-problem-turn
(format nil "No problem step found for button labelled ~a" ID)))

((null sysent)
(make-bad-problem-turn
(format nil "No SystemEntry for button labelled ~a" ID)))
(error 'webserver:log-error
:tag (list 'done-button-without-systementry id)
:text "No SystemEntry for button"))

((null PSM)
(error 'webserver:log-error
:tag (list 'done-button-without-enode id)
:text "No problem step found for button"))

;; If this is not a non-quant psm then we also need to throw an error
;; asserting that fact.
((not (enode-has-mark? PSM 'non-quant))
(make-bad-problem-turn
(format nil "Unmarked enode matching non-quant IDNum ~a ~a" PSM ID)))
(error 'webserver:log-error
:tag (list 'bad-mark-for-button-enode psm id)
:text "Unmarked enode matching non-quant IDNum"))

;; Otherwise test to see if it present and behave appropriately.
((psmg-path-enteredp (enode-path PSM))
;; Otherwise, test to see if task is completed by finding prerequisite
;; do-steps and seeing if all associated SystemEntries are done.
((every #'(lambda (x) (or (null (csdo-entries x))
(csdo-enteredp x)))
(find-prop-in-path id (enode-path PSM)))
(setf (StudentEntry-state entry) +CORRECT+)
(pushnew entry (SystemEntry-entered sysent))
(make-green-turn :id (StudentEntry-id entry)))
;; Activity is incomplete, give a hint
;; based on goalprop, and then defer to NSH.
(T (setf (StudentEntry-state entry) +INCORRECT+)
(let ((rem (nsh-walk-node-graph
(strcat "You have not finished " (goal id) ".<p>")
psm)))
(setf (SystemEntry-entered sysent) nil)
(let ((rem (if t ;new BvdS
(walk-psm-path "You have not finished "
(bgnode-path psm) nil)
(nsh-walk-node-graph
(strcat "You have not finished " (goal id) ".<p>")
psm))))
(setf (StudentEntry-ErrInterp entry)
(make-ErrorInterp
;; The diagnosis never makes it to the log file.
Expand Down
4 changes: 2 additions & 2 deletions Help/HelpMessages.cl
Expand Up @@ -38,8 +38,8 @@

(#-sbcl defconstant #+sbcl sb-int:defconstant-eqx
+dead-path-help+
'("Correct, but does not lead to a solution. Try a different approach."
"Sometimes guessing is required to solve problems. For instance, you might know two different principles that mention the sought quantity, but you usually don't need to apply both, so you have to guess which one try first. Whenever you have two or more correct choices, and you guess one that won't ultimately lead to a solution, Andes will tell you so, thus saving you some work."
'("Correct, but does not lead to a solution.&nbsp; Try a different approach."
"Sometimes guessing is required to solve problems.&nbsp; For instance, you might know two different principles that mention the sought quantity, but you usually don't need to apply both, so you have to guess which one try first. Whenever you have two or more correct choices, and you guess one that won't ultimately lead to a solution, Andes will tell you so, thus saving you some work."
(function next-step-help)) #+sbcl #'equalp)

(#-sbcl defconstant #+sbcl sb-int:defconstant-eqx
Expand Down
141 changes: 73 additions & 68 deletions Help/NextStepHelp.cl
Expand Up @@ -1304,7 +1304,7 @@
"Prompt for the student to start working on the givens."
(nsh-dialog-prompt-Node
(strcat "At this point it would be a good idea to begin enumerating "
"all of the useful given quantities in the problem." )
"all of the useful given quantities in the problem.")
"Why don't you start with "
(car *nsh-givens*)
:Assoc `((nsh prompt-start-givens ,(bgnode-exp (car *nsh-givens*))))))
Expand Down Expand Up @@ -1359,7 +1359,7 @@
(make-explain-more-turn
(strcat "On problems such as this you need to complete "
"all of the individual goals listed in the "
"problem description. ")
"problem description.")
:hint (nsh-prompt-Node
"Why don't you start with "
Principle
Expand All @@ -1377,23 +1377,16 @@
(null (remove-if #'nsh-principle-completed-p
(car *nsh-solution-sets*)))))

;;; Inform the students that they are done, and prompt them to go
;;; Inform the students that they are done., and prompt them to go
;;; ahead and check off the boxes (if they have not already done so
;; and tell them to quit.
(defun nsh-prompt-no-quant-done ()
"Prompt that the student is done with the problem."
(make-end-dialog-turn
(strcat "You have completed all of the principles necessary "
"in this problem. " (nsh-get-no-quant-done-str))
(strcat "You have completed all of the steps necessary "
"to solve this problem.")
:Assoc '((nsh . prompt-no-quant-done))))

(defun nsh-get-no-quant-done-str ()
(if (< 1 (length (problem-soughts *cp*)))
"Please check the \"I am done\" checkboxes on the screen."
"Please check the \"I am done\" checkbox and quit."))




;;;; ====================== Multiple-choice-Problems ==========================
;;;; For the Multiple-choice only problems the only tasks that they students need
Expand Down Expand Up @@ -2771,7 +2764,6 @@
*nsh-solution-sets*))



;;; If the student has already completed the best principle, then
;;; we want to prompt them to move on to the next principle in the
;;; solution.
Expand All @@ -2780,13 +2772,12 @@
(setq *nsh-current-solutions* (nsh-cfp-match-fp-sol Best))
(make-explain-more-turn
(strcat Prefix " You have already finished "
(nlg (enode-id Best) 'psm-exp)
". You can move on to the next step in the solution.")
(psm-exp (enode-id Best))
".&nbsp; You can move on to the next step in the solution.")
:hint (nsh-prompt-solution "Why don't you work on " Solution)
:Assoc `((nsh cfp-success-completed ,(bgnode-exp Best)))))



;;; If the student has not completed the first principle
;;; then we want to go ahead and prompt them to make the
;;; entry as necessary.
Expand All @@ -2795,10 +2786,7 @@
(setq *nsh-current-solutions* (nsh-cfp-match-fp-sol Best))
(nsh-walk-node-graph Prefix Best))






;;; ----------------- invalid choices --------------------------------
;;; If the student selects principles that are present but invalid
;;; then we want to tell them that. In future this will be modified
Expand All @@ -2815,7 +2803,6 @@
Sought Past :Case 'Invalid))



;;;-------------------------- Wrong principle ---------------------------------
;;; If the student fails to select the appropriate principle
;;; then we want to give them an appropriate response message
Expand Down Expand Up @@ -2874,8 +2861,8 @@
"Prompt the solution."
(make-explain-more-turn
(strcat Message " You have already finished "
(nlg (enode-id Principle) 'psm-exp)
". Why don't you start working on the next principle?")
(psm-exp (enode-id Principle))
".&nbsp; Why don't you start working on the next principle?")
:hint (nsh-prompt-solution "Why don't you work on " Solution)
:Assoc `((nsh prompt-done-fp ,Case ,(enode-id Principle)))))

Expand Down Expand Up @@ -3071,10 +3058,14 @@
(defun nsh-prompt-parameter (Prefix Parameter &key Assoc)
"Prompt the student to work on the parameter."
(setq *nsh-last-node* Parameter) ;Should set when hint is given, Bug #1854
(make-explain-more-turn
(strcat prefix (nlg (bgnode-exp Parameter) 'psm-exp) ". ")
:hint (nsh-walk-node-graph "" Parameter)
:Assoc (alist-warn Assoc)))
;; Only add this turn if principle itself is hintable.
(if (psm-exp-hintable (bgnode-exp parameter))
(make-explain-more-turn
(strcat prefix (psm-exp (bgnode-exp Parameter)) ".")
:hint (nsh-walk-node-graph "" Parameter)
:Assoc (alist-warn Assoc))
;; otherwise, defer to principles on bubblegraph
(walk-psm-path prefix (bgnode-path parameter) nil)))


;;; ---------------------------------------------------------------------------
Expand All @@ -3083,29 +3074,37 @@
;;; that will be used. Apart from that they are all the same.

(defun nsh-prompt-principle (Prefix principle &key Assoc)
"Prompt the specified principle appropriately based upoin how \"done\" it is"
"Prompt the specified principle appropriately based upon how \"done\" it is"
(setq *nsh-last-node* Principle) ;Should set when hint is given, Bug #1854
(cond ((nsh-goal-principle-P Principle)
(nsh-prompt-goal-principle Prefix Principle Assoc))
(t (nsh-prompt-principle-final Prefix Principle Assoc))))


;;; Goal principles, unlike the major/minor/given principles found in quantity
;;; problems are not psm-classes or psmtypes they are simply goalprops. Therefore
;;; we need to prompt them using a separate form.
;;; problems are not psm-classes or psmtypes they are simply goalprops.
;;; Therefore we need to prompt them using a separate form.
(defun nsh-prompt-goal-principle (prefix Principle Assoc)
"Prompt the specified major principle."
(make-explain-more-turn
(strcat prefix (nlg (enode-id principle) 'goal) ". ")
:hint (nsh-walk-Node-graph "" principle)
:Assoc (alist-warn Assoc)))
;; Only add this turn if principle itself is hintable.
(if (goalprop-exp-p (enode-id principle))
(make-explain-more-turn
(strcat prefix (goal (enode-id principle)) ".")
:hint (nsh-walk-Node-graph "" principle)
:Assoc (alist-warn Assoc))
;; otherwise, defer to principles on bubblegraph
(walk-psm-path prefix (bgnode-path principle) nil)))


(defun nsh-prompt-principle-final (prefix principle Assoc)
(make-explain-more-turn
(strcat prefix (nlg (enode-id principle) 'psm-exp) ". ")
:hint (nsh-walk-Node-graph "" principle)
:Assoc (alist-warn Assoc)))
;; Only add this turn if principle itself is hintable.
(if (psm-exp-hintable (enode-id principle))
(make-explain-more-turn
(strcat prefix (psm-exp (enode-id principle)) ".")
:hint (nsh-walk-Node-graph "" principle)
:Assoc (alist-warn Assoc))
;; otherwise, defer to principles on bubblegraph
(walk-psm-path prefix (bgnode-path principle) nil)))


;;;; ======================== Support functions ==================================
Expand Down Expand Up @@ -3415,12 +3414,6 @@
"Your goal should be ")))








;;;;============================ psm graph ==================================
;;;; we encounter the psm graphs in three instances. Firstly when asking if
;;;; a psm is entered. Secondly when we are traversing the psm path to find
Expand All @@ -3445,10 +3438,15 @@
;;; to traverse the path is made based upon the structure of the graph.
;;; this depends upon the graph structures defined in the psmg file
;;; of helpstructs.

;; node is an enode.
(defun nsh-walk-node-graph (prefix node)
;; Get the specified node's graph.
(walk-psm-path prefix (cdr (bgnode-path Node)) nil))

;; Returns turn struct or nil.
;; stack is list of cssg objects.
;; path is from bgnode-path.
(defun walk-psm-path (prefix path stack)
(cond ((null path)
(error "Reached end of psm path before finding target entry"))
Expand Down Expand Up @@ -3735,7 +3733,7 @@

;;; When the path-entered? search encounters a csdo it tests to see
;;; if the csdo has entries and if so if it has not been entered
;;; increment the count and recurse. Otherwize return 1 (path entered.)
;;; increment the count and recurse. Otherwise return 1 (path entered.)
(defun path-entered-csdo? (path count)
"Has the csdo been entered or not?"
(cond ((null (remove-if #'SystemEntry-implicit-eqnp
Expand Down Expand Up @@ -3929,35 +3927,42 @@
(when **Print-NSH-Stack** (pprint (reverse Stack)))
;; cs-do can have copies of entry.
(setf *help-last-entries* (remove-duplicates (csdo-entries step)))
(make-hint-seq
(append (collect-stack-hintstrs stack)
`((function make-hint-seq
,(collect-step-hints step)
;; BvdS: subsequent steps don't need affirmation.
:prefix "" ; ,prefix
:OpTail ,(list (csdo-op Step)))))
:prefix Prefix))


(let ((stepHints (collect-step-hints step)))
(make-hint-seq
(append (collect-stack-hintstrs prefix stack)
(if stepHints
`((function make-hint-seq
,stepHints
;; BvdS: subsequent steps don't need affirmation.
:prefix "" ;,prefix
:OpTail ,(list (csdo-op Step))))
nil)))))


;;; the goal hintstrs returns a list of hint strings for each goal
;;; located in the stack in reverse order. This sequence of strings
;;; which have been passed to nlg can be used to generate a hint
;;; sequence.
(defun collect-stack-hintstrs (stack)
;;; sequence.
;;;
;;; Add random goal prefix only to subsequent goals.
(defun collect-stack-hintstrs (prefix stack)
"Collect the stack hint strings."
(let ((hints))
(dolist (g stack)
(if (goalprop-exp-p (cssg-goal g))
(push `(goal ,(strcat (random-goal-prefix)
(nlg (cssg-goal g) 'goal) ".")
(goal ,(cssg-op g) ,(cssg-goal g)))

hints)
(when *debug-help*
(format t "NSH: Skipping unhintable goal ~S~%" (cssg-goal g)))))
hints))
(let (hints)
(dolist (g (reverse stack))
(let ((goalprop (goalprop-exp-p (cssg-goal g))))
(if (and goalprop (goalprop-nlg-english goalprop))
(progn
(push `(goal ,(strcat (if (> (length prefix) 0)
prefix
(random-goal-prefix))
(goal (cssg-goal g)) ".")
(goal ,(cssg-op g) ,(cssg-goal g)))
hints)
(setf prefix nil))
(when *debug-help*
(format t "NSH: Skipping unhintable goal ~S~%"
(cssg-goal g))))))
(reverse hints)))


;;; ------------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions Help/SolutionGraph.cl
Expand Up @@ -783,7 +783,7 @@
(dolist (E entries)
(let ((grade (SystemEntry-graded E)))
(pushnew len-enter (graded-eqns grade) :test #'unify)
(push Entry (SystemEntry-Entered E))))))
(pushnew Entry (SystemEntry-Entered E))))))


;;---------------------------------------------------------------------
Expand Down Expand Up @@ -844,11 +844,11 @@
;; fields of the System Entries in its cinterp.
(defun sg-delete-StudentEntry (Entry)
"Remove the markings from each node in the Entrie's CInterp."
; AW: unneeded variable check will mark define-var sysentries
; as entered by some student equation entries, even though
; the define-vars are NOT saved in the studentEntry's Cinterp.
; Change to loop over ALL system entries to allow for this case.
; Hairy technique, probably should be changed.
;; AW: unneeded variable check will mark define-var sysentries
;; as entered by some student equation entries, even though
;; the define-vars are NOT saved in the studentEntry's Cinterp.
;; Change to loop over ALL system entries to allow for this case.
;; Hairy technique, probably should be changed.
(dolist (E *sg-entries*) ; was: (E (studentEntry-Cinterp Entry))
(setf (SystemEntry-Entered E)
(remove Entry (SystemEntry-Entered E)))))
Expand Down

0 comments on commit 1dfa985

Please sign in to comment.