MDL-19214 Adding category hidden element
This commit is contained in:
@@ -25,9 +25,15 @@ class question_dataset_dependent_definitions_form extends moodleform {
|
||||
* @param MoodleQuickForm $mform the form being built.
|
||||
*/
|
||||
function question_dataset_dependent_definitions_form($submiturl, $question){
|
||||
global $QTYPES;
|
||||
global $QTYPES, $DB;
|
||||
$this->question = $question;
|
||||
$this->qtypeobj =& $QTYPES[$this->question->qtype];
|
||||
// Validate the question category.
|
||||
if (!$category = $DB->get_record('question_categories', array('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() {
|
||||
@@ -99,6 +105,10 @@ class question_dataset_dependent_definitions_form extends moodleform {
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'category');
|
||||
$mform->setType('category', PARAM_RAW);
|
||||
$mform->setDefault('category', array('contexts' => array($this->categorycontext)));
|
||||
|
||||
$mform->addElement('hidden', 'courseid');
|
||||
$mform->setType('courseid', PARAM_INT);
|
||||
$mform->setDefault('courseid', 0);
|
||||
|
||||
@@ -36,6 +36,12 @@ class question_dataset_dependent_items_form extends moodleform {
|
||||
$this->regenerate = $regenerate;
|
||||
$this->question = $question;
|
||||
$this->qtypeobj =& $QTYPES[$this->question->qtype];
|
||||
// Validate the question category.
|
||||
if (!$category = $DB->get_record('question_categories', array('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->calculated->definitionform->dataset);
|
||||
@@ -195,6 +201,10 @@ class question_dataset_dependent_items_form extends moodleform {
|
||||
$mform->setType('courseid', PARAM_INT);
|
||||
$mform->setDefault('courseid', 0);
|
||||
|
||||
$mform->addElement('hidden', 'category');
|
||||
$mform->setType('category', PARAM_RAW);
|
||||
$mform->setDefault('category', array('contexts' => array($this->categorycontext)));
|
||||
|
||||
$mform->addElement('hidden', 'cmid');
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
$mform->setDefault('cmid', 0);
|
||||
|
||||
Reference in New Issue
Block a user