Obojobo icon indicating copy to clipboard operation
Obojobo copied to clipboard

Generative / Variable questions

Open iturgeon opened this issue 6 years ago • 6 comments

Issue by zachberry Friday Jun 15, 2018 at 20:35 GMT Originally opened as https://github.com/ucfcdl/Obojobo-Document-Engine/issues/258


Probable prereq: #550 Possibly related: #566

Marking as question as this still has several items we need to figure out before development can start.

Want to be able to create a question with values that change so that several different questions can be created from a single question. The obvious use case is for numeric input type questions but this could be used for other question types.

An example of a numeric question (syntax yet to be determined):

  • What is the horizontal distance travelled by an object moving at a velocity of {{VELOCITY}} ms^-1 after {{SECONDS}} seconds?

Which might produce "What is the horizontal distance travelled by an object moving at a velocity of 20 ms^-1 after 2 seconds?"

Another example:

  • ... How fast was {{NAME}} running?
  1. 2 mph
  2. 5 mph
  3. 6 mph
  4. 12 mph

Here NAME could be either a random name picked from a list of names with no bearing on the result of the question or it could change the correct answer based on which NAME was selected.

Here's some ideas for what this might look like (presented as XML):

<Question>
  <variables>
    <variable name="x" type="int" value="[0,4]" />
    <variable name="My_Named_Variable" type="decimal" value="[0,4]" />
  </variables>
  <p>What is {{x}} + {{My_Named_Variable}} = ?</p>
  <NumericInteraction type="int" minInput="0" maxInput="100" revealAnswerAfterSubmit="true">
      <NumericAnswer answer="=x+My_Named_Variable" score="100">
          <p>Great job!</p>
      </NumericAnswer>
      <NumericAnswer answer="=x+My_Named_Variable" percentError="0.5" score="10">
          <p>Almost, but the answer is {{=x+My_Named_Variable}}</p>
      </NumericAnswer>
      <NumericAnswer answer="=x+My_Named_Variable" score="0">
          <p>PLUS, not MINUS!</p>
      </NumericAnswer>
  </NumericInteraction>
</Question>

Having to specify =x+My_Named_Variable seems tedious, perhaps the result could be specified as it's own variable?

Or, an alterative syntax:

<Question>
  <p>What is {{=x:int([0,4])}} + {{=dec([0,4])}} = ?</p>
  <!-- Above two variables are created. The first is named - "x" - and can be referenced either with "x" or by index with "$1". The second has no name and can only be referenced by index with "$2". -->
  <NumericInteraction type="int" minInput="0" maxInput="100" revealAnswerAfterSubmit="true">
      <NumericAnswer answer="=x+$2" score="100">
          <p>Great job!</p>
      </NumericAnswer>
      <NumericAnswer answer="=x+$2" percentError="0.5" score="10">
          <p>Almost, but the answer is {{=x+$2}}</p>
      </NumericAnswer>
      <NumericAnswer answer="=x-$2" score="0">
          <p>PLUS, not MINUS!</p>
      </NumericAnswer>
  </NumericInteraction>
</Question>

Another example of a possible syntax - here to create a list of names:

<Question>
  <variables>
    <variable name="person">
      <value>Lars</value>
      <value>Sadie</value>
      <value>Steven</value>
    </variable>
  </variables>
  <p>If {{person}} has 4 apples and eats 3 apples how many apples to do they left?</p>
   ...
</Question>

For numeric variables we could either create a bunch of possibilities when the item is created / document is saved and then randomly select a set of values to use when a visit is started or a question is viewed. For example, for this:

<variables>
  <variable name="x" type="int" value="[0,4]" />
  <variable name="My_Named_Variable" type="decimal" value="[0,4]" />
</variables>

Maybe the system creates 10 pairs of values:

  1. x=0, My_Named_Variable=3.27
  2. x=3, My_Named_Variable=1.92
  3. x=1, My_Named_Variable=0.66
  4. ...and so on

This would let the content creator potentially review the pairs created and modify them. Maybe there needs to be some way to specify sets of variables so that an author could write their own pairs. In the person example above maybe this looks like:

<Question>
  <variables>
    <variable name="person">
      <set>
        <value>Lars</value>
        <value>Sadie</value>
      </set>
      <set>
        <value>Steven</value>
        <value>Connie</value>
      </set>
    </variable>
  </variables>
  <p>If {{person:1}} has 4 apples and {{person:2}} eats 3 of their apples how many apples to do they left?</p>
   ...
</Question>

In this way the question will either be generated with Lars and Sadie or Steven and Connie only. This could be used in a numeric question, for example, setting x=0, y=1 or x=2, y=5.

We also need to store which option or options were selected or generated (x was 2, x was 7, etc), and we need to be able to eval the answer in numeric questions to determine its correctness.

iturgeon avatar Oct 01 '18 17:10 iturgeon

More potential syntax ideas:

<Question>
	<p>What is 2+<var name="x" value="1|2|3|4">x</var>+<var name="y_i" value="int[1,4]|float[8,9]"><latex>y_i</latex></var>=?</p>
	<NumericAssessment regenerate="true">
		<validationRules>
			<numericRule isInteger="false">
				<NumericFeedback>
					<p>Your answer must be an integer</p>
				</NumericFeedback>
			</numericRule>
		</validationsRules>
		<scoreRules>
			<numericRule value="=2+{x}+{y_i}" absoluteError="1" score="100">
				<NumericFeedback>
					<p>Congrats!</p>
				</NumericFeedback>
			</numericRule>
			<numericRule value="=2-{x}-{y_i}" score="0" />
		</scoreRules>
	</NumericAssessment>
</Question>

Or, <p>What is 2+{{x=1|2|3|4}}+{{y=int[1,4]|float[8,9]}}=?</p>

The = prefix for the numeric rule value property would be how you specify that the answer is an equation.

zachberry avatar Sep 23 '19 19:09 zachberry

Here's the current structure I'm pretty happy with

<Question>
	<variables>
		<variable name="x" min="0" max="4" decimals="2" />
		<variable name="y" min="2" max="6" decimals="2" />
	</variables>
	<p>What is {{x}} + {{y}} = ?</p>
	<NumericAssessment>
		<scoreRules>
			<numericRule value="=x+y" score="100" />
			<numericRule value="=x+y" percentError="1" score="0">
				<NumericFeedback>
					<p>You were close but you have to be exact!</p>
				</NumericFeedback>
			</numericRule>
			<numericRule value="=x-y" score="0">
				<NumericFeedback>
					<p>You subtracted when you should've added</p>
				</NumericFeedback>
			</numericRule>
		</scoreRules>
	</NumericAssessment>
</Question>

I have code written to generate variables and to evaluate mathematical equations. In the example above those are prefixed with = but I'm not sold on that just yet.

Every oboNode then can define 'variables' which would be available to that node and its children.

zachberry avatar Oct 01 '19 21:10 zachberry

More complete variables example (in XML)

<variables>
	<variable type="pick-list" name="a" values="[a,b,c]" size="1" ordered="true" />
	<variable type="list-sequence" name="a" start="9" step="2" size="5" />
	<variable type="list-random" name="a" min="0" max="100" decmials="100" size="2" />
	<variable type="numeric" name="a" min="0" max="100" decimals="100" />
	<variable type="set">
		<variables>
			<variable type="numeric" name="x" min="0" max="1" decimals="10" />
			<variable type="numeric" name="y" min="1" max="2" decimals="10" />
		</variables>
		<variables>
			<variable type="numeric" name="x" min="9" max="19" decimals="10" />
			<variable type="numeric" name="y" min="19" max="29" decimals="10" />
		</variables>
	</variable type="set">
</variables>

zachberry avatar Oct 01 '19 21:10 zachberry

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep our backlog under control, but we thank you for your contributions.

stale[bot] avatar Mar 29 '20 22:03 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep our backlog under control, but we thank you for your contributions.

stale[bot] avatar Feb 07 '21 18:02 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep our backlog under control, but we thank you for your contributions.

stale[bot] avatar Aug 28 '21 16:08 stale[bot]