Picture of Oliver Foster
Re: Component feedback
by Oliver Foster - Friday, 25 August 2017, 7:37 PM
 

3. A brief example:

QuetionView + ButtonsView work together:
https://github.com/adaptlearning/adapt_framework/blob/master/src/core/js/views/questionView.js#L112-L145

ButtonsView goes through these states to control the flow of questionView:
https://github.com/adaptlearning/adapt_framework/blob/master/src/core/js/enums/buttonStateEnum.js#L4-L10

The state is always at "SUBMIT" on first visit. When the submit button is clicked this function executes:
https://github.com/adaptlearning/adapt_framework/blob/master/src/core/js/views/questionView.js#L155-L211

(You can almost ignore the _runModelCompatibleFunction wrapper, this just says to either run the function from the model if available, or run the function on the view if no model is supplied - legacy style, we're trying to shift to have models for each component).

From the view function onSubmitClicked you should be able to see the order in which the model functions are executed. (Anything not wrapped in _runModelCompatibleFunction is a view only function, such as: showInstructionError, onCannotSubmit, removeInstructionError, showMarking, recordInteraction, showFeedback, onSubmitted).
The order of the model and view function executions when onSubmitClick is executed are:

  model.canSubmit (your code),

view.showInstructionError (core),

  view.onCannotSubmit (your code),

model.updateAttempts (core),

model.setQuestionAsSubmitted (core),

view.removeInstructionError (core),

  model.storeUserAnswer (your code), // specifically for restoring the state

model.markQuestion (core),

  model.isCorrect (your code),

  model.isPartlyCorrect (your code),

  model.setScore (your code),

  view.showMarking (your code),

model.checkQuestionCompletion (core),

  view.recordInteraction (your code), // specifically for scorm cmi.interactions

model.setupFeedback (core),

model.setupCorrectFeedback (core), 

model.setupPartlyCorrectFeedback (core), 

model.setupIncorrectCorrectFeedback (core),

model.updateButtons (code),

view.showFeedback (core),

  view.onSubmitted (your code) // mostly unneeded

Any of these functions can be overwritten on your model or view if you need bespoke behaviour, the ones with (core) next to them have default behaviour, the ones with (your code) need you to write something. There are only 6 functions that are really mandatory (if you exclude onSubmitted, storeUserAnswer and recordInteraction).

The attributes used and changed on the model with the core code include these:
_attemptsLeft,

_isEnabled,

_isSubmitted,

_isCorrect,

_isInteractionComplete,

_buttonState,

_canShowModelAnswer,

feedbackTitle,

feedbackMessage


Any other attributes are not part of this feedback process. They may be used but the core framework (see the inheritance chains of each core type, AdaptView>ComponentView>QuestionView, and AdaptModel>ComponentModel>QuestionModel) or by the component itself.

MCQ is a really good example of a question. 

Sorry that you're frustrated by the lack of docs. We're getting there slowly.

 

Ollie