diff --git a/lang/en_utf8/qtype_calculated.php b/lang/en_utf8/qtype_calculated.php
index 6144790f473..2b2a5091825 100644
--- a/lang/en_utf8/qtype_calculated.php
+++ b/lang/en_utf8/qtype_calculated.php
@@ -10,4 +10,5 @@ $string['mustbenumeric'] = 'You must enter a number here.';
$string['mustnotbenumeric'] = 'This can\'t be a number.';
$string['youmustenteramultiplierhere'] = 'You must enter a multiplier here.';
$string['nextpage'] = 'Next Page';
+$string['makecopynextpage'] = 'Next Page (new question)';
?>
\ No newline at end of file
diff --git a/lang/en_utf8/qtype_datasetdependent.php b/lang/en_utf8/qtype_datasetdependent.php
new file mode 100644
index 00000000000..cc46217bc01
--- /dev/null
+++ b/lang/en_utf8/qtype_datasetdependent.php
@@ -0,0 +1,14 @@
+$a}';
+$string['additem'] = 'Add Item';
+$string['itemtoadd'] = 'Item To Add';
+$string['calclength'] = 'Significant Figures';
+$string['calcdistribution'] = 'Distribution';
+$string['uniform'] = 'Uniform';
+$string['loguniform'] = 'Loguniform';
+$string['generate'] = 'Generate';
+$string['calcmin'] = 'Minimum';
+$string['calcmax'] = 'Maximum';
+$string['minmax'] = 'Range of Values';
+?>
\ No newline at end of file
diff --git a/question/type/calculated/edit_calculated_form.php b/question/type/calculated/edit_calculated_form.php
index 693c4cb6f51..fc9442db7a6 100644
--- a/question/type/calculated/edit_calculated_form.php
+++ b/question/type/calculated/edit_calculated_form.php
@@ -152,9 +152,11 @@ class question_edit_calculated_form extends question_edit_form {
$key++;
}
}
- $default_values['submitbutton'] = get_string('nextpage', 'qtype_calculated');
- $question = (object)((array)$question + $default_values);
}
+ $default_values['submitbutton'] = get_string('nextpage', 'qtype_calculated');
+ $default_values['makecopy'] = get_string('makecopynextpage', 'qtype_calculated');
+ $question = (object)((array)$question + $default_values);
+
parent::set_data($question);
}
@@ -174,11 +176,13 @@ class question_edit_calculated_form extends question_edit_form {
foreach ($answers as $key => $answer){
//check no of choices
$trimmedanswer = trim($answer);
- if (!empty($trimmedanswer)){
+ if (!empty($trimmedanswer)||$answercount==0){
$eqerror = qtype_calculated_find_formula_errors($trimmedanswer);
if (FALSE !== $eqerror){
$errors['answers['.$key.']'] = $eqerror;
}
+ }
+ if (!empty($trimmedanswer)){
if ('2' == $data['correctanswerformat'][$key]
&& '0' == $data['correctanswerlength'][$key]) {
$errors['correctanswerlength['.$key.']'] = get_string('zerosignificantfiguresnotallowed','quiz');
diff --git a/question/type/datasetdependent/abstractqtype.php b/question/type/datasetdependent/abstractqtype.php
index a7b4d97fbe6..5e5c29ee6ba 100644
--- a/question/type/datasetdependent/abstractqtype.php
+++ b/question/type/datasetdependent/abstractqtype.php
@@ -228,8 +228,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
$SESSION->datasetdependent->definitionform = $form;
} else {
// Something went wrong, go back to the first page
- redirect("question.php?category={$question->category}" .
- "&qtype={$question->qtype}");
+ redirect("question.php?category={$question->category}" ."&qtype={$question->qtype}");
}
} else {
$this->save_dataset_definitions($form);
@@ -237,8 +236,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
break;
case 'datasetitems':
if (empty($form->id) && isset($form->addbutton)) {
- $question = parent::save_question($question,
- $SESSION->datasetdependent->questionform, $course);
+ $question = parent::save_question($question, $SESSION->datasetdependent->questionform, $course);
$SESSION->datasetdependent->definitionform->id = $form->id = $question->id;
$this->save_dataset_definitions($SESSION->datasetdependent->definitionform);
unset($SESSION->datasetdependent);
diff --git a/question/type/datasetdependent/datasetdefinitions_form.php b/question/type/datasetdependent/datasetdefinitions_form.php
new file mode 100644
index 00000000000..73e61b726cd
--- /dev/null
+++ b/question/type/datasetdependent/datasetdefinitions_form.php
@@ -0,0 +1,68 @@
+question = $question;
+ $this->qtypeobj =& $QTYPES[$this->question->qtype];
+ parent::moodleform($submiturl);
+ }
+ function definition() {
+ $mform =& $this->_form;
+
+ $possibledatasets = $this->qtypeobj->find_dataset_names($this->question->questiontext);
+ $mandatorydatasets = array();
+ foreach ($this->question->answers as $answer) {
+ $mandatorydatasets += $this->qtypeobj->find_dataset_names($answer);
+ }
+ $key = 0;
+ $datasetmenus = array();
+ foreach ($mandatorydatasets as $datasetname) {
+ if (!isset($datasetmenus[$datasetname])) {
+ list($options, $selected) =
+ $this->qtypeobj->dataset_options($this->question, $datasetname);
+ unset($options['0']); // Mandatory...
+ $label = get_string("wildcard", "quiz"). " $datasetname ". get_string("substitutedby", "quiz");
+ $mform->addElement('select', "dataset[$key]", $label, $options);
+ $mform->setDefault("dataset[$key]", $selected);
+ $datasetmenus[$datasetname]='';
+ $key++;
+ }
+ }
+ foreach ($possibledatasets as $datasetname) {
+ if (!isset($datasetmenus[$datasetname])) {
+ list($options, $selected) =
+ $this->qtypeobj->dataset_options($this->question, $datasetname);
+ $label = get_string("wildcard", "quiz"). " $datasetname ". get_string("substitutedby", "quiz");
+ $mform->addElement('select', "dataset[$key]", $label, $options);
+ $mform->setDefault("dataset[$key]", $selected);
+ $datasetmenus[$datasetname]='';
+ $key++;
+ }
+ }
+ //hidden elements
+ $mform->addElement('hidden', 'wizardpage', 'datasetdefinitions');
+ $mform->setType('wizardpage', PARAM_ALPHA);
+ $this->add_action_buttons(true, get_string('nextpage', 'qtype_calculated'));
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/question/type/datasetdependent/datasetitems_form.php b/question/type/datasetdependent/datasetitems_form.php
new file mode 100644
index 00000000000..719c30131bd
--- /dev/null
+++ b/question/type/datasetdependent/datasetitems_form.php
@@ -0,0 +1,97 @@
+question = $question;
+ $this->qtypeobj =& $QTYPES[$this->question->qtype];
+ parent::moodleform($submiturl);
+ }
+ function definition() {
+ $mform =& $this->_form;
+
+ $repeated = array();
+ $repeatedoptions = array();
+ $repeated[] =& $mform->createElement('header', 'itemhdr', get_string('itemno', 'qtype_datasetdependent', '{no}'));
+ $params = array('a', 'b', 'c');
+ foreach ($params as $paramno => $param){
+ $idx = $paramno +1;
+ $repeated[] =& $mform->createElement('text', "number[$idx]", get_string('param', 'qtype_datasetdependent', $param));
+ $repeated[] =& $mform->createElement('hidden', "itemid[$idx]");
+ $repeated[] =& $mform->createElement('hidden', "definition[$idx]");
+
+ $repeatedoptions["number[$idx]"]['type'] = PARAM_NUMBER;
+ //$repeatedoptions["number[$idx]"]['rule'] = 'numeric';
+ $repeatedoptions["itemid[$idx]"]['type'] = PARAM_INT;
+ $repeatedoptions["definition[$idx]"]['type'] = PARAM_NOTAGS;
+ }
+
+ /*if (isset($this->question->options)){
+ $countanswers = count($this->question->options->answers);
+ } else {
+ $countanswers = 0;
+ }
+ $repeatsatstart = (QUESTION_NUMANS_START > ($countanswers + QUESTION_NUMANS_ADD))?
+ QUESTION_NUMANS_START : ($countanswers + QUESTION_NUMANS_ADD);
+ */
+ $repeatsatstart = 3;
+ $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'itemsno', 'itemsadd', 1, get_string('additem', 'qtype_datasetdependent'));
+
+
+ if ($this->qtypeobj->supports_dataset_item_generation()){
+ $radiogrp = array();
+ $radiogrp[] =& $mform->createElement('radio', "forceregeneration", 0, get_string('reuseifpossible', 'quiz'));
+ $radiogrp[] =& $mform->createElement('radio', "forceregeneration", 1, get_string('forceregeneration', 'quiz'));
+ $mform->addGroup($radiogrp, 'forceregenerationgrp', '', null, false);
+ }
+
+ $mform->addElement('header', 'additemhdr', get_string('itemtoadd', 'qtype_datasetdependent'));
+ foreach ($params as $paramno => $param){
+ $idx = $paramno +1;
+ $mform->addElement('text', "numbertoadd[$idx]", get_string('param', 'qtype_datasetdependent', $param));
+
+ $minmaxgrp = array();
+ $minmaxgrp[] =& $mform->createElement('text', "calcmin[$idx]", get_string('calcmin', 'qtype_datasetdependent'), 'size="3"');
+ $minmaxgrp[] =& $mform->createElement('text', "calcmax[$idx]", get_string('calcmax', 'qtype_datasetdependent'), 'size="3"');
+ $mform->addGroup($minmaxgrp, 'minmaxgrp', get_string('minmax', 'qtype_datasetdependent'), ' - ', false);
+
+ $precisionoptions = range(0, 10);
+ $mform->addElement('select', "calclength[$idx]", get_string('calclength', 'qtype_datasetdependent'), $precisionoptions);
+
+ $distriboptions = array('uniform' => get_string('uniform', 'qtype_datasetdependent'), 'loguniform' => get_string('loguniform', 'qtype_datasetdependent'));
+ $mform->addElement('select', "calcdistribution[$idx]", get_string('calcdistribution', 'qtype_datasetdependent'), $distriboptions);
+
+
+ $mform->addElement('submit', "generate[$idx]", get_string('generate', 'qtype_datasetdependent'));
+ $mform->addElement('hidden', "definition[$idx]");
+
+ $repeatedoptions["number[$idx]"]['type'] = PARAM_NUMBER;
+ //$repeatedoptions["number[$idx]"]['rule'] = 'numeric';
+ $repeatedoptions["itemid[$idx]"]['type'] = PARAM_INT;
+ $repeatedoptions["definition[$idx]"]['type'] = PARAM_NOTAGS;
+ }
+ $mform->addElement('hidden', 'wizardpage', 'datasetitems');
+ $mform->setType('wizardpage', PARAM_ALPHA);
+ $this->add_action_buttons(true);
+ }
+
+}
+?>
\ No newline at end of file