Permalink
Browse files

MDL-19214 Adding category hidden element Merging from HEAD

  • Loading branch information...
1 parent 40bb96d commit 3978521f564d0dd4b81b5f2e8ebec786ee28e8aa pichetp committed May 24, 2009
@@ -28,6 +28,13 @@ function question_dataset_dependent_definitions_form($submiturl, $question){
global $QTYPES;
$this->question = $question;
$this->qtypeobj =& $QTYPES[$this->question->qtype];
+ // Validate the question category.
+ if (!$category = get_record('question_categories', 'id', $question->category)) {
+ print_error('categorydoesnotexist', 'question', $returnurl);
+ }
+ $this->category = $category;
+ $this->categorycontext = get_context_instance_by_id($category->contextid);
+
parent::moodleform($submiturl);
}
function definition() {
@@ -107,6 +114,10 @@ function definition() {
$mform->setType('cmid', PARAM_INT);
$mform->setDefault('cmid', 0);
+ $mform->addElement('hidden', 'category');
+ $mform->setType('category', PARAM_RAW);
+ $mform->setDefault('category', array('contexts' => array($this->categorycontext)));
+
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'wizard', 'datasetitems');
$mform->setType('wizard', PARAM_ALPHA);
@@ -32,6 +32,12 @@ function question_dataset_dependent_items_form($submiturl, $question, $regenerat
$this->regenerate = $regenerate;
$this->question = $question;
$this->qtypeobj =& $QTYPES[$this->question->qtype];
+ // Validate the question category.
+ if (!$category = get_record('question_categories', 'id', $question->category)) {
+ print_error('categorydoesnotexist', 'question', $returnurl);
+ }
+ $this->category = $category;
+ $this->categorycontext = get_context_instance_by_id($category->contextid);
//get the dataset defintions for this question
if (empty($question->id)) {
$this->datasetdefs = $this->qtypeobj->get_dataset_definitions($question->id, $SESSION->datasetdependent->definitionform->dataset);
@@ -161,6 +167,10 @@ function definition() {
$mform->setType('cmid', PARAM_INT);
$mform->setDefault('cmid', 0);
+ $mform->addElement('hidden', 'category');
+ $mform->setType('category', PARAM_RAW);
+ $mform->setDefault('category', array('contexts' => array($this->categorycontext)));
+
$mform->addElement('hidden', 'wizard', 'datasetitems');
$mform->setType('wizard', PARAM_ALPHA);

0 comments on commit 3978521

Please sign in to comment.