From 2379439f63af89fa968c6e636fb45dd830ca349c Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Tue, 27 Mar 2012 14:41:58 +0700 Subject: [PATCH] MDL-47494 ddmarker: NOBUG change API calls that only work post 2.1 This need to be merged into master branch because we want to keep the 2.1 branch mergeable but then we will merge with 'ours' strategy, effectively discarding changes. --- .../type/ddmarker/imagetargetconverter.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/question/type/ddmarker/imagetargetconverter.php b/question/type/ddmarker/imagetargetconverter.php index 7eb3f997920..be2d62f1148 100644 --- a/question/type/ddmarker/imagetargetconverter.php +++ b/question/type/ddmarker/imagetargetconverter.php @@ -99,7 +99,7 @@ class qtype_ddmarker_category_list_item extends qtype_ddmarker_list_item { $actionurl = new moodle_url($PAGE->url, array('categoryid'=> $this->record->id)); $thisitem = html_writer::tag('a', $thisitem, array('href' => $actionurl)); } - + return $thisitem.$this->render_children($stringidentifier, $link); } } @@ -126,7 +126,7 @@ class qtype_ddmarker_context_list_item extends qtype_ddmarker_list_item { global $PAGE; $a = new stdClass(); $a->qcount = $this->qcount; - $a->name = $this->record->get_context_name(); + $a->name = print_context_name($this->record); $thisitem = get_string($stringidentifier.'context', 'qtype_ddmarker', $a); if ($link) { $actionurl = new moodle_url($PAGE->url, array('contextid'=> $this->record->id)); @@ -170,10 +170,16 @@ class qtype_ddmarker_context_list extends qtype_ddmarker_list { global $DB; $this->records = array(); foreach ($contextids as $contextid) { - if (!isset($records[$contextid])) { - $this->records[$contextid] = context::instance_by_id($contextid); + if (!isset($this->records[$contextid])) { + $this->records[$contextid] = get_context_instance_by_id($contextid, MUST_EXIST); + } + $parents = get_parent_contexts($this->records[$contextid]); + foreach ($parents as $parentcontextid) { + if (!isset($this->records[$parentcontextid])) { + $this->records[$parentcontextid] = + get_context_instance_by_id($parentcontextid, MUST_EXIST); + } } - $this->records += $this->records[$contextid]->get_parent_contexts(); } parent::make_list_item_instances_from_records ($contextids); } @@ -271,7 +277,7 @@ if ($categoryid || $qcontextid) { echo $contexts->render('listitem', false, $torender); echo $OUTPUT->confirm(get_string('confirmimagetargetconversion', 'qtype_ddmarker'), $cofirmedurl, $cancelurl); } else if (confirm_sesskey()) { - + } } else { echo $contexts->render('listitemaction', true, $contexts->root_node());