Skip to content
Snippets Groups Projects
Commit 005c35ea authored by Tim Hunt's avatar Tim Hunt
Browse files

Add the two extra input options to the DB and elsewhere.

parent e93ddb36
No related branches found
No related tags found
No related merge requests found
......@@ -40,11 +40,13 @@
<FIELD NAME="boxsize" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="15" SEQUENCE="false" COMMENT="The desired size for the input." PREVIOUS="tans" NEXT="strictsyntax"/>
<FIELD NAME="strictsyntax" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether this input element should validate the input strictly." PREVIOUS="boxsize" NEXT="insertstars"/>
<FIELD NAME="insertstars" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether this input should automatically insert *s where there is implicit multiplication." PREVIOUS="strictsyntax" NEXT="syntaxhint"/>
<FIELD NAME="syntaxhint" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="An optional initial value to display in the input to help the student know what to type." PREVIOUS="insertstars" NEXT="forbidfloat"/>
<FIELD NAME="forbidfloat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether floating point numbers should be rejected in this input." PREVIOUS="syntaxhint" NEXT="requirelowestterms"/>
<FIELD NAME="syntaxhint" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="An optional initial value to display in the input to help the student know what to type." PREVIOUS="insertstars" NEXT="forbidwords"/>
<FIELD NAME="forbidwords" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="Any additional words (e.g. function names) that the student is not permitted to use in this input." PREVIOUS="syntaxhint" NEXT="forbidfloat"/>
<FIELD NAME="forbidfloat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether floating point numbers should be rejected in this input." PREVIOUS="forbidwords" NEXT="requirelowestterms"/>
<FIELD NAME="requirelowestterms" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether any fractions in the input must be given in lowest terms." PREVIOUS="forbidfloat" NEXT="checkanswertype"/>
<FIELD NAME="checkanswertype" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether the type of the students answer (expression, list, ...) should be validated to ensure it is the same as tans." PREVIOUS="requirelowestterms" NEXT="showvalidation"/>
<FIELD NAME="showvalidation" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether the validation results for this input should be displayed." PREVIOUS="checkanswertype"/>
<FIELD NAME="checkanswertype" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether the type of the students answer (expression, list, ...) should be validated to ensure it is the same as tans." PREVIOUS="requirelowestterms" NEXT="mustverify"/>
<FIELD NAME="mustverify" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether the interpretation of this input must be verified by the student before it is graded." PREVIOUS="checkanswertype" NEXT="showvalidation"/>
<FIELD NAME="showvalidation" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether the validation results for this input should be displayed." PREVIOUS="mustverify"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="questionid"/>
......
......@@ -233,5 +233,35 @@ function xmldb_qtype_stack_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2012031302, 'qtype', 'stack');
}
if ($oldversion < 2012031600) {
// Define field forbidwords to be added to qtype_stack_inputs
$table = new xmldb_table('qtype_stack_inputs');
$field = new xmldb_field('forbidwords', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'syntaxhint');
// Conditionally launch add field forbidwords
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// qtype_stack savepoint reached
upgrade_plugin_savepoint(true, 2012031600, 'qtype', 'stack');
}
if ($oldversion < 2012031601) {
// Define field mustverify to be added to qtype_stack_inputs
$table = new xmldb_table('qtype_stack_inputs');
$field = new xmldb_field('mustverify', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '1', 'checkanswertype');
// Conditionally launch add field mustverify
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// qtype_stack savepoint reached
upgrade_plugin_savepoint(true, 2012031601, 'qtype', 'stack');
}
return true;
}
......@@ -368,9 +368,11 @@ class qtype_stack_edit_form extends question_edit_form {
$question->{$inputname . 'strictsyntax'} = $input->strictsyntax;
$question->{$inputname . 'insertstars'} = $input->insertstars;
$question->{$inputname . 'syntaxhint'} = $input->syntaxhint;
$question->{$inputname . 'forbidwords'} = $input->forbidwords;
$question->{$inputname . 'forbidfloat'} = $input->forbidfloat;
$question->{$inputname . 'requirelowestterms'} = $input->requirelowestterms;
$question->{$inputname . 'checkanswertype'} = $input->checkanswertype;
$question->{$inputname . 'mustverify'} = $input->mustverify;
$question->{$inputname . 'showvalidation'} = $input->showvalidation;
}
......
......@@ -96,9 +96,11 @@ class qtype_stack extends question_type {
$input->strictsyntax = $fromform->{$inputname . 'strictsyntax'};
$input->insertstars = $fromform->{$inputname . 'insertstars'};
$input->syntaxhint = $fromform->{$inputname . 'syntaxhint'};
$input->forbidwords = $fromform->{$inputname . 'forbidwords'};
$input->forbidfloat = $fromform->{$inputname . 'forbidfloat'};
$input->requirelowestterms = $fromform->{$inputname . 'requirelowestterms'};
$input->checkanswertype = $fromform->{$inputname . 'checkanswertype'};
$input->mustverify = $fromform->{$inputname . 'mustverify'};
$input->showvalidation = $fromform->{$inputname . 'showvalidation'};
$DB->update_record('qtype_stack_inputs', $input);
......@@ -205,7 +207,8 @@ class qtype_stack extends question_type {
$question->inputs = $DB->get_records('qtype_stack_inputs',
array('questionid' => $question->id), 'name',
'name, id, questionid, type, tans, boxsize, strictsyntax, insertstars, ' .
'syntaxhint, forbidfloat, requirelowestterms, checkanswertype, showvalidation');
'syntaxhint, forbidwords, forbidfloat, requirelowestterms, ' .
'checkanswertype, mustverify, showvalidation');
$question->prts = $DB->get_records('qtype_stack_prts',
array('questionid' => $question->id), 'name',
......@@ -249,9 +252,11 @@ class qtype_stack extends question_type {
'strictSyntax' => (bool) $inputdata->strictsyntax,
'insertStars' => (bool) $inputdata->insertstars,
'syntaxHint' => $inputdata->syntaxhint,
'forbidWords' => $inputdata->forbidwords,
'forbidFloats' => (bool) $inputdata->forbidfloat,
'lowestTerms' => (bool) $inputdata->requirelowestterms,
'sameType' => (bool) $inputdata->checkanswertype,
'mustVerify' => (bool) $inputdata->mustverify,
'hideFeedback' => !$inputdata->showvalidation,
);
$question->inputs[$name] = stack_input_factory::make(
......
......@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2012031302;
$plugin->version = 2012031601;
$plugin->requires = 2012020200;
$plugin->cron = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment