Merge branch 'MDL-47476' of git://github.com/timhunt/moodle

Conflicts:
	lib/db/upgrade.php
	version.php
This commit is contained in:
Sam Hemelryk 2014-10-08 11:02:38 +13:00
commit 70b370982f
7 changed files with 13 additions and 396 deletions

View File

@ -910,7 +910,7 @@ class core_plugin_manager {
// branch, listed should be no plugins that were removed at 1.9.x - 2.1.x versions as
// Moodle 2.3 supports upgrades from 2.2.x only.
$plugins = array(
'qformat' => array('blackboard'),
'qformat' => array('blackboard', 'learnwise'),
'enrol' => array('authorize'),
'tinymce' => array('dragmath'),
'tool' => array('bloglevelupgrade', 'qeupgradehelper'),
@ -1086,7 +1086,7 @@ class core_plugin_manager {
'qformat' => array(
'aiken', 'blackboard_six', 'examview', 'gift',
'learnwise', 'missingword', 'multianswer', 'webct',
'missingword', 'multianswer', 'webct',
'xhtml', 'xml'
),

View File

@ -3964,5 +3964,15 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2014100700.01);
}
if ($oldversion < 2014100800.00) {
// Remove qformat_learnwise (unless it has manually been added back).
if (!file_exists($CFG->dirroot . '/question/format/learnwise/format.php')) {
unset_all_config_for_plugin('qformat_learnwise');
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2014100800.00);
}
return true;
}

View File

@ -1,190 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Examview question importer.
*
* @package qformat_learnwise
* @copyright 2005 Alton College, Hampshire, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Examview question importer.
*
* Alton College, Hampshire, UK - Tom Flannaghan, Andrew Walker
*
* Imports learnwise multiple choice questions (single and multiple answers)
* currently ignores the deduct attribute for multiple answer questions
* deductions are currently simply found by dividing the award for the incorrect
* answer by the total number of options
*
* @copyright 2005 Alton College, Hampshire, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qformat_learnwise extends qformat_default {
public function provide_import() {
return true;
}
public function export_file_extension() {
return '.xml';
}
protected function readquestions($lines) {
$questions = array();
$currentquestion = array();
foreach ($lines as $line) {
$line = trim($line);
$currentquestion[] = $line;
if ($question = $this->readquestion($currentquestion)) {
$questions[] = $question;
$currentquestion = array();
}
}
return $questions;
}
protected function readquestion($lines) {
global $OUTPUT;
$text = implode(' ', $lines);
$text = str_replace(array('\t', '\n', '\r'), array('', '', ''), $text);
$startpos = strpos($text, '<question type');
$endpos = strpos($text, '</question>');
if ($startpos === false || $endpos === false) {
return false;
}
preg_match("/<question type=[\"\']([^\"\']+)[\"\']>/i", $text, $matches);
$type = strtolower($matches[1]); // Multichoice or multianswerchoice.
$questiontext = core_text::entities_to_utf8($this->stringbetween($text, '<text>', '</text>'));
$questionhint = core_text::entities_to_utf8($this->stringbetween($text, '<hint>', '</hint>'));
$questionaward = $this->stringbetween($text, '<award>', '</award>');
$optionlist = $this->stringbetween($text, '<answer>', '</answer>');
$optionlist = explode('<option', $optionlist);
$n = 0;
$optionscorrect = array();
$optionstext = array();
if ($type == 'multichoice') {
foreach ($optionlist as $option) {
if (trim($option) === '') {
continue;
}
$correct = $this->stringbetween($option, ' correct="', '">');
$answer = $this->stringbetween($option, '">', '</option>');
$optionscorrect[$n] = $correct;
$optionstext[$n] = core_text::entities_to_utf8($answer);
++$n;
}
} else if ($type == 'multianswerchoice') {
$numcorrect = 0;
$totalaward = 0;
$optionsaward = array();
foreach ($optionlist as $option) {
if (trim($option) === '') {
continue;
}
preg_match("/correct=\"([^\"]*)\"/i", $option, $correctmatch);
preg_match("/award=\"([^\"]*)\"/i", $option, $awardmatch);
$correct = $correctmatch[1];
$award = $awardmatch[1];
if ($correct == 'yes') {
$totalaward += $award;
++$numcorrect;
}
$answer = $this->stringbetween($option, '">', '</option>');
$optionscorrect[$n] = $correct;
$optionstext[$n] = core_text::entities_to_utf8($answer);
$optionsaward[$n] = $award;
++$n;
}
} else {
echo $OUTPUT->notification(get_string('unknownorunhandledtype', 'question', $type));
}
$question = $this->defaultquestion();
$question->qtype = 'multichoice';
$question->name = $this->create_default_question_name($questiontext, get_string('questionname', 'question'));
$this->add_blank_combined_feedback($question);
$question->questiontext = $questiontext;
$question->questiontextformat = FORMAT_HTML;
$question->single = ($type == 'multichoice') ? 1 : 0;
$question->fraction = array();
$question->answer = array();
for ($n = 0; $n < count($optionstext); ++$n) {
if ($optionstext[$n]) {
if (!isset($numcorrect)) {
// Single answer.
if ($optionscorrect[$n] == 'yes') {
$fraction = (int) $questionaward;
} else {
$fraction = 0;
}
} else {
// Multiple answers.
if ($optionscorrect[$n] == 'yes') {
$fraction = $optionsaward[$n] / $totalaward;
} else {
$fraction = -$optionsaward[$n] / count($optionstext);
}
}
$question->fraction[] = $fraction;
$question->answer[] = array('text' => $optionstext[$n], 'format' => FORMAT_HTML);
$question->feedback[] = array('text' => '', 'format' => FORMAT_HTML); // No feedback in this type.
}
}
return $question;
}
/**
* Extract the substring of $text between $start and $end.
* @param string $text text to analyse.
* @param string $start opening delimiter.
* @param string $end closing delimiter.
* @return string the requested substring.
*/
protected function stringbetween($text, $start, $end) {
$startpos = strpos($text, $start) + strlen($start);
$endpos = strpos($text, $end);
if ($startpos <= $endpos) {
return substr($text, $startpos, $endpos - $startpos);
}
}
}

View File

@ -1,26 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'qformat_learnwise', language 'en', branch 'MOODLE_20_STABLE'
*
* @package qformat_learnwise
* @copyright 2010 Helen Foster
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Learnwise format';
$string['pluginname_help'] = 'This format enables the import of multiple choice questions saved in Learnwise\'s XML format.';

View File

@ -1,145 +0,0 @@
<?xml version="1.0" ?>
<activityset setno="2">
<title>Maths</title>
<questions>
<question type="multiChoice">
<text>The ages, in years, of 10 horses in a field were 3, 3, 4, 5, 7, 7, 7, 8, 8, 8,&lt;p&gt;
Which one of the following is true?</text>
<award>1</award>
<hint>mean = (3+3+4+5+7+7+7+8+8+8)/10 = 6&lt;p&gt;
median = 7 i.e the middle number&lt;p&gt;
range = 8-3 = 5</hint>
<answer>
<option correct="yes">median &gt; mean &gt; range</option>
<option correct="no">mean = median</option>
<option correct="no">mean &gt; median &gt; range</option>
<option correct="no">median &gt; range &gt; mean</option>
</answer>
</question>
<question type="multiChoice">
<text>At a college, students are given a points score calculated from their GCSE grades.&lt;p&gt;
Someone with 4 A grades and 4 B grades gains a score of 36 points.&lt;br&gt;Someone with 2 A grades and 4 B grades gains a score of 26 points.&lt;br&gt;Someone with 3 A grades and 3 B grades would have a score of</text>
<award>1</award>
<hint>4A + 4B = 36 and 2A + 4B = 26&lt;p&gt;solving simultaneously gives A = 5 and B = 4</hint>
<answer>
<option correct="yes">27 points</option>
<option correct="no">21 points</option>
<option correct="no">30 points</option>
<option correct="no">31 points</option>
</answer>
</question>
<question type="multiChoice">
<text>A sequence consists of adding the previous three terms together to form the next term. The first three terms of the sequence are 1, 2, 3.&lt;p&gt;
What is the sixth term in the sequence?</text>
<award>1</award>
<hint>1, 2, 3, 6, 11, ...</hint>
<answer>
<option correct="yes">20</option>
<option correct="no">6</option>
<option correct="no">11</option>
<option correct="no">13</option>
</answer>
</question>
<question type="multiChoice">
<text>The value of an item is described as decreasing exponentially. Which description below best matches this statement?</text>
<award>1</award>
<hint>No hint - you either know this or you don't!</hint>
<answer>
<option correct="yes">The value falls by a smaller amount each year.</option>
<option correct="no">The value falls by the same amount each year.</option>
<option correct="no">The value falls by the same amount each year for a while, and then remains constant.</option>
<option correct="no">The value falls by a larger amount each year.</option>
</answer>
</question>
<question type="multiChoice">
<text>Consider the statement&lt;p&gt;
&quot;Schools with high numbers of pupils on free school meals do not do well in league tables.&quot;&lt;p&gt;
Which of the following statements follows logically from the one above?</text>
<award>1</award>
<hint>Factors other than the number of pupils on free school meals affect how well a school does in league tables.</hint>
<answer>
<option correct="yes">Schools which do well in league tables do not have high numbers of pupils on free school meals.</option>
<option correct="no">Schools with low numbers of pupils on free school meals do well in league tables.</option>
<option correct="no">Making all pupils pay for school meals will improve league table results.</option>
<option correct="no">Schools which do not do well in league tables have high numbers of pupils on free school meals.</option>
</answer>
</question>
<question type="multiChoice">
<text>The force between two point electric charges is inversely proportional to the square of their distance apart. What effect does doubling this distance have on the force?</text>
<award>1</award>
<hint>Inversely proportional means that increasing the distance decreases the force.&lt;br&gt;2 squared gives 4.</hint>
<answer>
<option correct="yes">The force decreases by a factor of four.</option>
<option correct="no">The force is halved.</option>
<option correct="no">The force is doubled.</option>
<option correct="no">The force increases by a factor of four.</option>
</answer>
</question>
<question type="multiChoice">
<text>Two of the five playing cards that Colin has are aces. He shuffles the five cards, then puts them face down on the table. Madge takes a card and then another. The probability that she now has &lt;b&gt;both&lt;/b&gt; of the aces is</text>
<award>1</award>
<hint>2/5 x 1/4</hint>
<answer>
<option correct="yes">1/10</option>
<option correct="no">4/25</option>
<option correct="no">1/5</option>
<option correct="no">2/5</option>
</answer>
</question>
<question type="multiChoice">
<text>A college's guidelines say that classes must have a minimum of 12 students and a maximum of 20 students. For what numbers of students studying a particular subject is it impossible to run classes without breaking the guidelines?</text>
<award>1</award>
<hint>between 12 and 20 students - one class&lt;br&gt;
between 24 and 36 students - two classes&lt;br&gt;
between 36 and 40 students - two classes</hint>
<answer>
<option correct="yes">between 20 and 24 students</option>
<option correct="no">between 12 and 20 students</option>
<option correct="no">between 24 and 36 students</option>
<option correct="no">between 36 and 40 students</option>
</answer>
</question>
<question type="multiChoice">
<text>The ages of two friends are in the ratio 3:4. In 8 years time their ages will be in the ratio 5:6. How old are they now?</text>
<award>1</award>
<hint>(12+8):(16+8) = 20:24 = 5:6</hint>
<answer>
<option correct="yes">12, 16</option>
<option correct="no">3, 4</option>
<option correct="no">6, 8</option>
<option correct="no">9, 12</option>
</answer>
</question>
<question type="multiChoice">
<text>A heavy construction vehicle travels for 40 minutes between sites, at an average speed of 16 km per second. The distance between sites is</text>
<award>1</award>
<hint>16/60 x 40</hint>
<answer>
<option correct="yes">10.7 km</option>
<option correct="no">2.5 km</option>
<option correct="no">6.4 km</option>
<option correct="no">38.4 km</option>
</answer>
</question>
<question type="multianswerchoice">
<text>Which of the following are features of a Virtual Learning Environment? (Select all that apply)</text>
<hint />
<answer>
<option correct="yes" award="1" deduct="0">course resources are available from home and from college</option>
<option correct="yes" award="1" deduct="0">forums enable collaborative work</option>
<option correct="yes" award="1" deduct="0">assessments can give instant feedback</option>
<option correct="yes" award="1" deduct="0">course progress is recorded</option>
<option correct="no" award="1" deduct="0">kettle is put on automatically for tea/coffee</option>
</answer>
</question>
<question type="multianswerchoice">
<text>Which of the following may a Virtual Learning Environment be used for? (Select all that apply)</text>
<hint />
<answer>
<option correct="yes" award="1" deduct="1">delivering a course online</option>
<option correct="yes" award="1" deduct="1">supporting face-to-face teaching</option>
<option correct="no" award="1" deduct="0">as a complete replacement for teachers</option>
</answer>
</question>
</questions>
</activityset>

View File

@ -1,32 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version information for the calculated question type.
*
* @package qformat_learnwise
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'qformat_learnwise';
$plugin->version = 2014051200;
$plugin->requires = 2014050800;
$plugin->maturity = MATURITY_STABLE;

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2014100700.01; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2014100800.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.