mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
merged from stable
This commit is contained in:
parent
36f0d1acbb
commit
8c95e97fec
3 changed files with 24 additions and 18 deletions
|
@ -261,7 +261,7 @@
|
||||||
|
|
||||||
|
|
||||||
<tr valign="top">
|
<tr valign="top">
|
||||||
<?php include('reviewoptions.html'); ?>
|
<?php include($CFG->dirroot . '/mod/quiz/reviewoptions.html'); ?>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<input type="hidden" name="fix_review" value="0" />
|
<input type="hidden" name="fix_review" value="0" />
|
||||||
<input type="checkbox" name="fix_review" value="1" <?php p($CFG->quiz_fix_review ? "checked" : "") ?> />
|
<input type="checkbox" name="fix_review" value="1" <?php p($CFG->quiz_fix_review ? "checked" : "") ?> />
|
||||||
|
|
|
@ -281,7 +281,7 @@
|
||||||
|
|
||||||
<?php if (!$CFG->quiz_fix_review) {
|
<?php if (!$CFG->quiz_fix_review) {
|
||||||
echo '<tr valign="top">';
|
echo '<tr valign="top">';
|
||||||
include('reviewoptions.html');
|
include($CFG->dirroot . '/mod/quiz/reviewoptions.html');
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
} else $fix=1 ?>
|
} else $fix=1 ?>
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@
|
||||||
|
|
||||||
<?php if ($CFG->quiz_fix_review) {
|
<?php if ($CFG->quiz_fix_review) {
|
||||||
echo '<tr valign="top">';
|
echo '<tr valign="top">';
|
||||||
include('reviewoptions.html');
|
include($CFG->dirroot . '/mod/quiz/reviewoptions.html');
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
|
|
|
@ -364,14 +364,18 @@ function quiz_qtype_multianswer_extract_question($text) {
|
||||||
// Regexes are always awkard when defined but more comprehensible
|
// Regexes are always awkard when defined but more comprehensible
|
||||||
// when used as constants in the executive code
|
// when used as constants in the executive code
|
||||||
|
|
||||||
// ANSWER_ALTERNATIVE regexes
|
// Handle the entity encoded ampersand in entities (e.g. &lt; -> <)
|
||||||
|
$text = preg_replace('/&(.{2,9}?;)/', '&${1}', $text);
|
||||||
|
|
||||||
|
// ANSWER_ALTERNATIVE regexes
|
||||||
define("ANSWER_ALTERNATIVE_FRACTION_REGEX",
|
define("ANSWER_ALTERNATIVE_FRACTION_REGEX",
|
||||||
'=|%(-?[0-9]+)%');
|
'=|%(-?[0-9]+)%');
|
||||||
define("ANSWER_ALTERNATIVE_ANSWER_REGEX",
|
define("ANSWER_ALTERNATIVE_ANSWER_REGEX",
|
||||||
'[^~#}]+');
|
'.+?(?<!\\\\)(?=[~#}]|$)');
|
||||||
|
//'[^~#}]+');
|
||||||
define("ANSWER_ALTERNATIVE_FEEDBACK_REGEX",
|
define("ANSWER_ALTERNATIVE_FEEDBACK_REGEX",
|
||||||
'[^~}]*');
|
'.*?(?<!\\\\)(?=[~}]|$)');
|
||||||
|
//'[//^~}]*');
|
||||||
define("ANSWER_ALTERNATIVE_REGEX",
|
define("ANSWER_ALTERNATIVE_REGEX",
|
||||||
'(' . ANSWER_ALTERNATIVE_FRACTION_REGEX .')?'
|
'(' . ANSWER_ALTERNATIVE_FRACTION_REGEX .')?'
|
||||||
. '(' . ANSWER_ALTERNATIVE_ANSWER_REGEX . ')'
|
. '(' . ANSWER_ALTERNATIVE_ANSWER_REGEX . ')'
|
||||||
|
@ -405,7 +409,7 @@ function quiz_qtype_multianswer_extract_question($text) {
|
||||||
. '(' . ANSWER_ALTERNATIVE_REGEX
|
. '(' . ANSWER_ALTERNATIVE_REGEX
|
||||||
. '(~'
|
. '(~'
|
||||||
. ANSWER_ALTERNATIVE_REGEX
|
. ANSWER_ALTERNATIVE_REGEX
|
||||||
. ')*)}' );
|
. ')*)\}' );
|
||||||
|
|
||||||
// Parenthesis positions for singulars in ANSWER_REGEX
|
// Parenthesis positions for singulars in ANSWER_REGEX
|
||||||
define("ANSWER_REGEX_NORM", 1);
|
define("ANSWER_REGEX_NORM", 1);
|
||||||
|
@ -420,24 +424,24 @@ function quiz_qtype_multianswer_extract_question($text) {
|
||||||
|
|
||||||
$question = new stdClass;
|
$question = new stdClass;
|
||||||
$question->qtype= MULTIANSWER;
|
$question->qtype= MULTIANSWER;
|
||||||
$question->questiontext= $text;
|
$question->questiontext= stripslashes($text);
|
||||||
$question->options->questions = array();
|
$question->options->questions = array();
|
||||||
$question->defaultgrade = 0; // Will be increased for each answer norm
|
$question->defaultgrade = 0; // Will be increased for each answer norm
|
||||||
|
|
||||||
for ($positionkey=1
|
for ($positionkey=1
|
||||||
; ereg(ANSWER_REGEX, $question->questiontext, $answerregs)
|
; preg_match('/'.ANSWER_REGEX.'/', $question->questiontext, $answerregs)
|
||||||
; ++$positionkey ) {
|
; ++$positionkey ) {
|
||||||
$wrapped = new stdClass;
|
$wrapped = new stdClass;
|
||||||
$wrapped->defaultgrade = $answerregs[ANSWER_REGEX_NORM]
|
$wrapped->defaultgrade = $answerregs[ANSWER_REGEX_NORM]
|
||||||
or $wrapped->defaultgrade = '1';
|
or $wrapped->defaultgrade = '1';
|
||||||
if ($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL]) {
|
if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL])) {
|
||||||
$wrapped->qtype = NUMERICAL;
|
$wrapped->qtype = NUMERICAL;
|
||||||
$wrapped->multiplier = array();
|
$wrapped->multiplier = array();
|
||||||
$wrapped->units = array();
|
$wrapped->units = array();
|
||||||
} else if($answerregs[ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER]) {
|
} else if(!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER])) {
|
||||||
$wrapped->qtype = SHORTANSWER;
|
$wrapped->qtype = SHORTANSWER;
|
||||||
$wrapped->usecase = 0;
|
$wrapped->usecase = 0;
|
||||||
} else if($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE]){
|
} else if(!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE])) {
|
||||||
$wrapped->qtype = MULTICHOICE;
|
$wrapped->qtype = MULTICHOICE;
|
||||||
$wrapped->single = 1;
|
$wrapped->single = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -451,11 +455,11 @@ function quiz_qtype_multianswer_extract_question($text) {
|
||||||
$wrapped->answer = array();
|
$wrapped->answer = array();
|
||||||
$wrapped->fraction = array();
|
$wrapped->fraction = array();
|
||||||
$wrapped->feedback = array();
|
$wrapped->feedback = array();
|
||||||
$wrapped->questiontext = $answerregs[0];
|
$wrapped->questiontext = addslashes($answerregs[0]);
|
||||||
$wrapped->questiontextformat = 0;
|
$wrapped->questiontextformat = 0;
|
||||||
|
|
||||||
$remainingalts = $answerregs[ANSWER_REGEX_ALTERNATIVES];
|
$remainingalts = $answerregs[ANSWER_REGEX_ALTERNATIVES];
|
||||||
while (ereg(ANSWER_ALTERNATIVE_REGEX, $remainingalts, $altregs)) {
|
while (preg_match('/~?'.ANSWER_ALTERNATIVE_REGEX.'/', $remainingalts, $altregs)) {
|
||||||
if ('=' == $altregs[ANSWER_ALTERNATIVE_REGEX_FRACTION]) {
|
if ('=' == $altregs[ANSWER_ALTERNATIVE_REGEX_FRACTION]) {
|
||||||
$wrapped->fraction[] = '1';
|
$wrapped->fraction[] = '1';
|
||||||
} else if ($percentile =
|
} else if ($percentile =
|
||||||
|
@ -464,17 +468,19 @@ function quiz_qtype_multianswer_extract_question($text) {
|
||||||
} else {
|
} else {
|
||||||
$wrapped->fraction[] = '0';
|
$wrapped->fraction[] = '0';
|
||||||
}
|
}
|
||||||
$wrapped->feedback[] = $altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK];
|
$wrapped->feedback[] =
|
||||||
if ($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL]
|
isset($altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK])
|
||||||
|
? $altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK] : '';
|
||||||
|
if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL])
|
||||||
&& ereg(NUMERICAL_ALTERNATIVE_REGEX,
|
&& ereg(NUMERICAL_ALTERNATIVE_REGEX,
|
||||||
$altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER],
|
$altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER],
|
||||||
$numregs) )
|
$numregs) )
|
||||||
{
|
{
|
||||||
$wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER];
|
$wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER];
|
||||||
if ($numregs[NUMERICAL_ABS_ERROR_MARGIN]) {
|
if ($numregs[NUMERICAL_ABS_ERROR_MARGIN]) {
|
||||||
$wrapped->tolerance = $numregs[NUMERICAL_ABS_ERROR_MARGIN];
|
$wrapped->tolerance[] = $numregs[NUMERICAL_ABS_ERROR_MARGIN];
|
||||||
} else {
|
} else {
|
||||||
$wrapped->tolerance = 0;
|
$wrapped->tolerance[] = 0;
|
||||||
}
|
}
|
||||||
} else { // Tolerance can stay undefined for non numerical questions
|
} else { // Tolerance can stay undefined for non numerical questions
|
||||||
$wrapped->answer[] = $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER];
|
$wrapped->answer[] = $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue