mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 11:56:40 +02:00
MDL-47494 ddmarker: NOBUG make it possible to select just one question for processing
This commit is contained in:
parent
e1bd1cf6e3
commit
864e786019
2 changed files with 14 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue