From 92e2ed8f16318ce75bc0abdb2282d20ae7f3a87a Mon Sep 17 00:00:00 2001 From: pichetp Date: Sat, 10 Mar 2007 10:31:49 +0000 Subject: [PATCH] merge from 18_STABLE --- .../datasetdefinitions_form.php | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/question/type/datasetdependent/datasetdefinitions_form.php b/question/type/datasetdependent/datasetdefinitions_form.php index b383d1c35f..57f0c8d22e 100644 --- a/question/type/datasetdependent/datasetdefinitions_form.php +++ b/question/type/datasetdependent/datasetdefinitions_form.php @@ -28,7 +28,7 @@ class question_dataset_dependent_definitions_form extends moodleform { function definition() { global $SESSION; $mform =& $this->_form; - + $stringfile = 'qtype_'.$this->question->qtype ; $possibledatasets = $this->qtypeobj->find_dataset_names($this->question->questiontext); $mandatorydatasets = array(); if (isset($this->question->options->answers)){ @@ -42,25 +42,44 @@ class question_dataset_dependent_definitions_form extends moodleform { } $key = 0; + $datadefscat= array(); + $datadefscat = $this->qtypeobj->get_dataset_definitions_category($this->question); $datasetmenus = array(); + $label = "
".get_string('datasetrole', 'qtype_datasetdependent','numerical')."
"; + $mform->addElement('html', $label);// explaining the role of datasets so other strings can be shortened + $mform->addElement('header', 'mandatoryhdr', get_string('mandatoryhdr', $stringfile)); + $labelsharedwildcard = get_string("sharedwildcard", "qtype_datasetdependent"); + 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"); + $label = get_string("wildcard", "quiz"). " $datasetname "; $mform->addElement('select', "dataset[$key]", $label, $options); + if (isset($datadefscat[$datasetname])){ + $mform->addElement('static', "there is a category", $labelsharedwildcard." $datasetname ", get_string('dataitemdefined',"qtype_datasetdependent", $datadefscat[$datasetname])); + } $mform->setDefault("dataset[$key]", $selected); $datasetmenus[$datasetname]=''; $key++; } } + $mform->addElement('header', 'possiblehdr', get_string('possiblehdr', $stringfile)); + + 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"); + $this->qtypeobj->dataset_options($this->question, $datasetname,false); + $label = get_string("wildcard", "quiz"). " $datasetname "; $mform->addElement('select', "dataset[$key]", $label, $options); + // $mform->addRule("dataset[$key]", null, 'required', null, 'client'); + if (isset($datadefscat[$datasetname])){ + $mform->addElement('static', "there is a category", $labelsharedwildcard." $datasetname ", get_string('dataitemdefined',"qtype_datasetdependent", $datadefscat[$datasetname])); + } + + // $selected ="0"; $mform->setDefault("dataset[$key]", $selected); $datasetmenus[$datasetname]=''; $key++; @@ -81,6 +100,22 @@ class question_dataset_dependent_definitions_form extends moodleform { $mform->addElement('hidden', 'wizard', 'datasetitems'); $mform->setType('wizard', PARAM_ALPHA); } + function validation($data){ + $errors = array(); + $datasets = $data['dataset']; + $countvalid = 0 ; + foreach ($datasets as $key => $dataset){ + if ($dataset !="0") { + $countvalid++; + } + } + if (!$countvalid){ + foreach ($datasets as $key => $dataset){ + $errors['dataset['.$key.']'] = get_string('atleastonerealdataset', 'qtype_datasetdependent'); + } + } + return $errors; + } } ?> \ No newline at end of file -- 2.39.5