mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
question bank: MDL-12787, MDL-17870 field in the question editing form to tag questions, and load and save the tags from the DB.
This commit is contained in:
parent
8942fd77be
commit
c599a68240
3 changed files with 24 additions and 15 deletions
|
@ -46,18 +46,15 @@ if ($cmid){
|
|||
}
|
||||
$contexts = new question_edit_contexts($thiscontext);
|
||||
|
||||
|
||||
if (!$returnurl) {
|
||||
$returnurl = "{$CFG->wwwroot}/question/edit.php?courseid={$COURSE->id}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($id) {
|
||||
if (!$question = $DB->get_record('question', array('id' => $id))) {
|
||||
print_error('questiondoesnotexist', 'question', $returnurl);
|
||||
}
|
||||
get_question_options($question);
|
||||
get_question_options($question, true);
|
||||
} else if ($categoryid && $qtype) { // only for creating new questions
|
||||
$question = new stdClass;
|
||||
$question->category = $categoryid;
|
||||
|
@ -72,7 +69,7 @@ if (!$category = $DB->get_record('question_categories', array('id' => $question-
|
|||
}
|
||||
|
||||
//permissions
|
||||
$question->formoptions = new object();
|
||||
$question->formoptions = new stdClass;
|
||||
|
||||
$categorycontext = get_context_instance_by_id($category->contextid);
|
||||
$addpermission = has_capability('moodle/question:add', $categorycontext);
|
||||
|
@ -99,7 +96,6 @@ if ($id) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
} else { // creating a new question
|
||||
require_capability('moodle/question:add', $categorycontext);
|
||||
$formeditable = true;
|
||||
|
@ -107,14 +103,12 @@ if ($id) {
|
|||
$question->formoptions->movecontext = false;
|
||||
}
|
||||
|
||||
|
||||
// Validate the question type.
|
||||
if (!isset($QTYPES[$question->qtype])) {
|
||||
print_error('unknownquestiontype', 'question', $returnurl, $question->qtype);
|
||||
}
|
||||
$CFG->pagepath = 'question/type/' . $question->qtype;
|
||||
|
||||
|
||||
// Create the question editing form.
|
||||
if ($wizardnow!=='' && !$movecontext){
|
||||
if (!method_exists($QTYPES[$question->qtype], 'next_wizard_form')){
|
||||
|
@ -183,7 +177,12 @@ if ($mform->is_cancelled()){
|
|||
}
|
||||
}
|
||||
|
||||
$question = $QTYPES[$question->qtype]->save_question($question, $fromform, $COURSE, $wizardnow);
|
||||
$question = $QTYPES[$question->qtype]->save_question($question, $fromform, $COURSE, $wizardnow, true);
|
||||
if (!empty($CFG->usetags)) {
|
||||
require_once($CFG->dirroot.'/tag/lib.php');
|
||||
tag_set('question', $question->id, $fromform->tags);
|
||||
}
|
||||
|
||||
if (($QTYPES[$question->qtype]->finished_edit_wizard($fromform)) || $movecontext){
|
||||
if ($inpopup) {
|
||||
notify(get_string('changessaved'), '');
|
||||
|
@ -242,7 +241,6 @@ if ($mform->is_cancelled()){
|
|||
print_header_simple($streditingquestion, '', $navigation);
|
||||
}
|
||||
|
||||
|
||||
// Display a heading, question editing form and possibly some extra content needed for
|
||||
// for this question type.
|
||||
$QTYPES[$question->qtype]->display_question_editing_page($mform, $question, $wizardnow);
|
||||
|
|
|
@ -146,6 +146,11 @@ class question_edit_form extends moodleform {
|
|||
// Any questiontype specific fields.
|
||||
$this->definition_inner($mform);
|
||||
|
||||
if (!empty($CFG->usetags)) {
|
||||
$mform->addElement('header', 'tagsheader', get_string('tags'));
|
||||
$mform->addElement('tags', 'tags', get_string('tags'));
|
||||
}
|
||||
|
||||
if (!empty($this->question->id)){
|
||||
$mform->addElement('header', 'createdmodifiedheader', get_string('createdmodifiedheader', 'question'));
|
||||
$a = new object();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue