Skip to content

Commit

Permalink
#554 Adjusted all relevant obonode converters and JSON to XML parsers…
Browse files Browse the repository at this point in the history
… to add variable support. Created migration to add a 'state' column to visits for tracking variable values per visit, for use in tracking those same generated values when starting an assessment attempt. Added support for variable usage in assessment attempt and review contexts.
  • Loading branch information
FrenjaminBanklin committed Nov 3, 2023
1 parent 1a7b13a commit 1f35d07
Show file tree
Hide file tree
Showing 48 changed files with 180 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class AssessmentStateHelpers {
const assessmentModel = OboModel.models[assessmentId]

if (assessment.questionResponses && assessment.questionResponses.length > 0) {
const context = `assessment:${assessmentId}:${assessment.attemptId}`
const context = this.composeNavContextString(assessmentId, assessment.attemptId)

const contextState = QuestionStore.getOrCreateContextState(context)

Expand Down Expand Up @@ -240,6 +240,7 @@ class AssessmentStateHelpers {
}

this.setAssessmentQuestionBank(assessmentModel, assessment.questions)
this.setAssessmentAttemptVariables(assessmentModel, assessment.attemptId, assessment.state.variables)
this.updateNavContextAndMenu(assessmentModel, assessment.attemptId)
this.signalAttemptStarted(assessmentModel)

Expand All @@ -254,6 +255,14 @@ class AssessmentStateHelpers {
Array.from(questions).forEach(child => qb.children.add(OboModel.create(child)))
}

static setAssessmentAttemptVariables(assessmentModel, attemptId, variables) {
const assessmentId = assessmentModel.get('id')
const context = this.composeNavContextString(assessmentId, attemptId)
Dispatcher.trigger('variables:addContext', {
value: { context, variables }
})
}

static updateNavContextAndMenu(assessmentModel, attemptId) {
const assessmentId = assessmentModel.get('id')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Common from 'Common'
import VariableUtil from '../util/variable-util'
// import VariableGenerator from './variable-store/variable-generator'

const { Store } = Common.flux
const { Dispatcher } = Common.flux
Expand All @@ -15,10 +14,15 @@ const getNewContextState = () => {
class VariableStore extends Store {
constructor() {
super('variableStore')

Dispatcher.on({
'variables:addContext': payload => {
this._addMultiple(payload.value.context, payload.value.variables)
}
})
}

_addMultiple(context, values) {
console.log('add mult', context, values, this)
values.forEach(({ id, value }) => {
const [ownerId, varName] = id.split(':')
this._add(context, ownerId, varName, value)
Expand Down Expand Up @@ -62,7 +66,6 @@ class VariableStore extends Store {
}
}

// this._addVariablesForModel('practice', variableState)
this._addMultiple('practice', variableValues)
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import Common from 'Common'

const { Dispatcher } = Common.flux

const VariableUtil = {
getKey(ownerId, varName) {
return `${ownerId}:${varName}`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const textGroupParser = require('../text-group-parser')
const processTriggers = require('../process-triggers')
const processVars = require('../process-vars')
const processObjectives = require('../process-objectives')
const processAttrs = require('../process-attrs')

Expand All @@ -8,10 +9,11 @@ const actionButtonNodeParser = node => {
const attrs = processAttrs(node.content, ['triggers', 'textGroup', 'actions'])
const textGroupXML = textGroupParser(node.content.textGroup)
const triggersXML = processTriggers(node.content.triggers)
const varsXML = processVars(node.content.variables)
const objectivesXML = processObjectives(node.content.objectives)

return (
`<ActionButton${attrs}${id}>` + textGroupXML + triggersXML + objectivesXML + `</ActionButton>`
`<ActionButton${attrs}${id}>` + textGroupXML + triggersXML + objectivesXML + varsXML + `</ActionButton>`
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const processTriggers = require('../process-triggers')
const processAttrs = require('../process-attrs')
const processVars = require('../process-vars')
const processObjectives = require('../process-objectives')

const assessmentNodeParser = (node, childrenParser) => {
Expand All @@ -8,6 +9,7 @@ const assessmentNodeParser = (node, childrenParser) => {
const scoreActionsXML = scoreActionsParser(node.content.scoreActions, childrenParser)
const rubricXML = rubricParser(node.content.rubric)
const triggersXML = processTriggers(node.content.triggers)
const varsXML = processVars(node.content.variables)
const objectivesXML = processObjectives(node.content.objectives)

return (
Expand All @@ -17,6 +19,7 @@ const assessmentNodeParser = (node, childrenParser) => {
rubricXML +
triggersXML +
objectivesXML +
varsXML +
`</Assessment>`
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const processAttrs = require('../process-attrs')
const processTriggers = require('../process-triggers')
const processVars = require('../process-vars')
const processObjectives = require('../process-objectives')
const breakNodeParser = node => {
const id = node.id ? ` id="${node.id}"` : ''
const attrs = processAttrs(node.content, ['triggers', 'actions'])
const triggersXML = processTriggers(node.content.triggers)
const varsXML = processVars(node.content.variables)
const objectivesXML = processObjectives(node.content.objectives)

if (triggersXML) {
return `<Break${attrs}${id}>${triggersXML}` + objectivesXML + `</Break>`
return `<Break${attrs}${id}>${triggersXML}` + objectivesXML + varsXML + `</Break>`
}

return `<hr${attrs}${id} />`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
const textGroupParser = require('../text-group-parser')
const processAttrs = require('../process-attrs')
const processTriggers = require('../process-triggers')
const processVars = require('../process-vars')
const processObjectives = require('../process-objectives')
const codeNodeParser = node => {
const id = node.id ? ` id="${node.id}"` : ''
const attrs = processAttrs(node.content, ['triggers', 'textGroup'])
const textGroupXML = textGroupParser(node.content.textGroup)
const triggersXML = processTriggers(node.content.triggers)
const varsXML = processVars(node.content.variables)
const objectivesXML = processObjectives(node.content.objectives)

return `<Code${attrs}${id}>` + textGroupXML + triggersXML + objectivesXML + `</Code>`
return `<Code${attrs}${id}>` + textGroupXML + triggersXML + objectivesXML + varsXML `</Code>`
}

module.exports = codeNodeParser
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
const processAttrs = require('../process-attrs')
const processTriggers = require('../process-triggers')
const processVars = require('../process-vars')
const processObjectives = require('../process-objectives')
const contentNodeParser = (node, childrenParser) => {
const id = node.id ? ` id="${node.id}"` : ''
const attrs = processAttrs(node.content, ['triggers'])
const triggersXML = processTriggers(node.content.triggers)
const varsXML = processVars(node.content.variables)
const objectivesXML = processObjectives(node.content.objectives)

return (
`<Content${attrs}${id}>` +
childrenParser(node.children) +
triggersXML +
objectivesXML +
varsXML +
`</Content>`
)
}
Expand Down
Loading

0 comments on commit 1f35d07

Please sign in to comment.