From d9e73158b5410b090ff8f43f128203edea2b2a6c Mon Sep 17 00:00:00 2001 From: Gordon Bateson Date: Wed, 14 May 2014 06:45:09 +0900 Subject: [PATCH] MDL-79863 qtype_ordering: qtype/ordering fix undefined passwordsaltmain in Moodle >= 2.6 --- question/type/ordering/renderer.php | 9 ++++++++- question/type/ordering/version.php | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/question/type/ordering/renderer.php b/question/type/ordering/renderer.php index 626ff51b472..a36566c7eef 100644 --- a/question/type/ordering/renderer.php +++ b/question/type/ordering/renderer.php @@ -133,12 +133,19 @@ class qtype_ordering_renderer extends qtype_renderer { $result .= html_writer::start_tag('div', array('class' => 'answer')); $result .= html_writer::start_tag('ul', array('class' => 'boxy', 'id' => 'sortable'.$question->id)); + // a salt (=random string) to help disguise answer ids + if (isset($CFG->passwordsaltmain)) { + $salt = $CFG->passwordsaltmain; + } else { + $salt = complex_random_string(); + } + // generate ordering items foreach ($answerids as $i => $answerid) { // the original "id" revealed the correct order of the answers // because $answer->fraction holds the correct order number // $id = 'ordering_item_'.$answerid.'_'.intval($answers[$answerid]->fraction); - $id = 'ordering_item_'.md5($CFG->passwordsaltmain.$answers[$answerid]->answer); + $id = 'ordering_item_'.md5($salt.$answers[$answerid]->answer); $params = array('class' => 'ui-state-default', 'id' => $id); $result .= html_writer::tag('li', $answers[$answerid]->answer, $params); } diff --git a/question/type/ordering/version.php b/question/type/ordering/version.php index 5d2a25195b6..79dbb0d103d 100644 --- a/question/type/ordering/version.php +++ b/question/type/ordering/version.php @@ -30,6 +30,6 @@ defined('MOODLE_INTERNAL') || die(); $plugin->cron = 0; $plugin->component = 'qtype_ordering'; $plugin->maturity = MATURITY_STABLE; // ALPHA=50, BETA=100, RC=150, STABLE=200 -$plugin->release = '2013-06-28.00'; -$plugin->version = 2013062800; +$plugin->release = '2014-05-14.01'; +$plugin->version = 2014051401; $plugin->requires = 2010112400; // Moodle 2.0