Merge branch 'MDL-32464_22' of git://github.com/timhunt/moodle into MOODLE_22_STABLE
This commit is contained in:
@@ -17,10 +17,9 @@
|
||||
/**
|
||||
* Embedded answer (Cloze) question importer.
|
||||
*
|
||||
* @package qformat
|
||||
* @subpackage multianswer
|
||||
* @copyright 2003 Henrik Kaipe
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package qformat_multianswer
|
||||
* @copyright 2003 Henrik Kaipe
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,32 +30,36 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* Importer that imports a text file containing a single Multianswer question
|
||||
* from a text file.
|
||||
*
|
||||
* @copyright 2003 Henrik Kaipe
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @copyright 2003 Henrik Kaipe
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qformat_multianswer extends qformat_default {
|
||||
|
||||
public function provide_import() {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function readquestions($lines) {
|
||||
public function readquestions($lines) {
|
||||
question_bank::get_qtype('multianswer'); // Ensure the multianswer code is loaded.
|
||||
|
||||
// For this class the method has been simplified as
|
||||
// there can never be more than one question for a
|
||||
// multianswer import
|
||||
// multianswer import.
|
||||
$questions = array();
|
||||
|
||||
$questiontext = array();
|
||||
$questiontext['text'] = implode('', $lines);
|
||||
$questiontext['format'] = 0 ;
|
||||
$questiontext['format'] = FORMAT_MOODLE;
|
||||
$questiontext['itemid'] = '';
|
||||
$question = qtype_multianswer_extract_question($questiontext);
|
||||
$question->questiontext = $question->questiontext['text'] ;
|
||||
$question->questiontextformat = 0 ;
|
||||
$question->questiontext = $question->questiontext['text'];
|
||||
$question->questiontextformat = 0;
|
||||
|
||||
$question->qtype = MULTIANSWER;
|
||||
$question->qtype = 'multianswer';
|
||||
$question->generalfeedback = '';
|
||||
$question->course = $this->course;
|
||||
$question->generalfeedbackformat = FORMAT_MOODLE;
|
||||
$question->length = 1;
|
||||
$question->penalty = 0.3333333;
|
||||
|
||||
if (!empty($question)) {
|
||||
$name = html_to_text(implode(' ', $lines));
|
||||
|
||||
@@ -303,7 +303,7 @@ function qtype_multianswer_extract_question($text) {
|
||||
$question->defaultmark = 0; // Will be increased for each answer norm
|
||||
|
||||
for ($positionkey = 1;
|
||||
preg_match('/'.ANSWER_REGEX.'/', $question->questiontext['text'], $answerregs);
|
||||
preg_match('/'.ANSWER_REGEX.'/s', $question->questiontext['text'], $answerregs);
|
||||
++$positionkey) {
|
||||
$wrapped = new stdClass();
|
||||
$wrapped->generalfeedback['text'] = '';
|
||||
@@ -389,7 +389,7 @@ function qtype_multianswer_extract_question($text) {
|
||||
$answerindex = 0;
|
||||
|
||||
$remainingalts = $answerregs[ANSWER_REGEX_ALTERNATIVES];
|
||||
while (preg_match('/~?'.ANSWER_ALTERNATIVE_REGEX.'/', $remainingalts, $altregs)) {
|
||||
while (preg_match('/~?'.ANSWER_ALTERNATIVE_REGEX.'/s', $remainingalts, $altregs)) {
|
||||
if ('=' == $altregs[ANSWER_ALTERNATIVE_REGEX_FRACTION]) {
|
||||
$wrapped->fraction["$answerindex"] = '1';
|
||||
} else if ($percentile = $altregs[ANSWER_ALTERNATIVE_REGEX_PERCENTILE_FRACTION]) {
|
||||
@@ -411,7 +411,7 @@ function qtype_multianswer_extract_question($text) {
|
||||
|
||||
}
|
||||
if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL])
|
||||
&& preg_match('~'.NUMERICAL_ALTERNATIVE_REGEX.'~',
|
||||
&& preg_match('~'.NUMERICAL_ALTERNATIVE_REGEX.'~s',
|
||||
$altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], $numregs)) {
|
||||
$wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER];
|
||||
if (array_key_exists(NUMERICAL_ABS_ERROR_MARGIN, $numregs)) {
|
||||
|
||||
Reference in New Issue
Block a user