From 864e78601941ec3aaeb98b5937fa35bb950e0549 Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Sat, 31 Mar 2012 14:23:25 +0700 Subject: [PATCH] MDL-47494 ddmarker: NOBUG make it possible to select just one question for processing --- question/type/ddmarker/imagetargetconverter.php | 13 ++++++++++--- question/type/ddmarker/questionlists.php | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/question/type/ddmarker/imagetargetconverter.php b/question/type/ddmarker/imagetargetconverter.php index a0a9bb79c43..93423dd73e5 100644 --- a/question/type/ddmarker/imagetargetconverter.php +++ b/question/type/ddmarker/imagetargetconverter.php @@ -61,6 +61,7 @@ class qtype_ddmarker_question_converter_list_item extends qtype_ddmarker_questio $categoryid = optional_param('categoryid', 0, PARAM_INT); $qcontextid = optional_param('contextid', 0, PARAM_INT); +$questionid = optional_param('questionid', 0, PARAM_INT); $confirm = optional_param('confirm', 0, PARAM_INT); // Check the user is logged in. require_login(); @@ -89,6 +90,10 @@ if ($qcontextid) { $from .= ', {question_categories} cat2'; $where .= 'AND cat.contextid = cat2.contextid AND cat2.id = :categoryid '; $params['categoryid'] = $categoryid; +} else if ($questionid) { + //fetch all questions from this cats context + $where .= 'AND q.id = :questionid '; + $params['questionid'] = $questionid; } $sql = 'SELECT q.*, cat.contextid '.$from.$where.'ORDER BY cat.id, q.name'; @@ -106,8 +111,10 @@ $questionlist = new qtype_ddmarker_question_converter_list($questions, $category foreach ($questions as $question) { $questionlist->leaf_node($question->id, 1); } -$questionsselected = (bool) ($categoryid || $qcontextid); -if ($categoryid) { +$questionsselected = (bool) ($categoryid || $qcontextid || $questionid); +if ($questionid) { + $top = $questionlist->get_instance($questionid); +} else if ($categoryid) { $top = $categorylist->get_instance($categoryid); } else if ($qcontextid) { $top = $contextlist->get_instance($qcontextid); @@ -117,7 +124,7 @@ if ($categoryid) { if (!$confirm) { if ($questionsselected) { echo $contextlist->render('listitemaction', false, $top); - $cofirmedurl = new moodle_url($PAGE->url, compact('categoryid', 'contextid')+array('confirm'=>1)); + $cofirmedurl = new moodle_url($PAGE->url, compact('categoryid', 'contextid', 'questionid') + array('confirm'=>1)); $cancelurl = new moodle_url($PAGE->url); echo $OUTPUT->confirm(get_string('confirmimagetargetconversion', 'qtype_ddmarker'), $cofirmedurl, $cancelurl); } else { diff --git a/question/type/ddmarker/questionlists.php b/question/type/ddmarker/questionlists.php index 23cd17ab540..ecb5f4f93f2 100644 --- a/question/type/ddmarker/questionlists.php +++ b/question/type/ddmarker/questionlists.php @@ -144,6 +144,10 @@ class qtype_ddmarker_question_list_item extends qtype_ddmarker_list_item { $a = new stdClass(); $a->name = $this->record->name; $thisitem = get_string('listitemquestion', 'qtype_ddmarker', $a); + if ($link) { + $actionurl = new moodle_url($PAGE->url, array('questionid'=> $this->record->id)); + $thisitem = html_writer::tag('a', $thisitem, array('href' => $actionurl)); + } return $thisitem; } public function question_ids() {