From 8009810ed40fc886349faedfeceae6107aa16490 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 15 Mar 2013 08:12:39 +0000 Subject: [PATCH] MDL-38395 question categories: wrong URLs after editing. The problem was that array1 + array2 takes the values from array1 when a key appears in both places. While working on this area, I updated it to use html_writer. --- question/category_class.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/question/category_class.php b/question/category_class.php index 9c061a51239..8fb88cf9b09 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -99,20 +99,26 @@ class question_category_list_item extends list_item { $editqestions = get_string('editquestions', 'question'); - /// Each section adds html to be displayed as part of this list item - $questionbankurl = new moodle_url("/question/edit.php", ($this->parentlist->pageurl->params() + array('cat'=>"$category->id,$category->contextid"))); - $catediturl = $this->parentlist->pageurl->out(true, array('edit' => $this->id)); - $item = "edit}\" href=\"$catediturl\">" . - format_string($category->name, true, array('context' => $this->parentlist->context)) . - " ".'('.$category->questioncount.')'; - - $item .= ' ' . format_text($category->info, $category->infoformat, + // Each section adds html to be displayed as part of this list item. + $questionbankurl = new moodle_url('/question/edit.php', $this->parentlist->pageurl->params()); + $questionbankurl->param('cat', $category->id . ',' . $category->contextid); + $catediturl = new moodle_url($this->parentlist->pageurl, array('edit' => $this->id)); + $item = ''; + $item .= html_writer::tag('b', html_writer::link($catediturl, + format_string($category->name, true, array('context' => $this->parentlist->context)), + array('title' => $str->edit))) . ' '; + $item .= html_writer::link($questionbankurl, '(' . $category->questioncount . ')', + array('title' => $editqestions)) . ' '; + $item .= format_text($category->info, $category->infoformat, array('context' => $this->parentlist->context, 'noclean' => true)); // don't allow delete if this is the last category in this context. if (count($this->parentlist->records) != 1) { - $item .= ' - ' .$str->delete. ''; + $deleteurl = new moodle_url($this->parentlist->pageurl, array('delete' => $this->id, 'sesskey' => sesskey())); + $item .= html_writer::link($deleteurl, + html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), + 'class' => 'iconsmall', 'alt' => $str->delete)), + array('title' => $str->delete)); } return $item;