Skip to content

Commit

Permalink
Merge branch 'MDL-30760_22' of git://github.com/timhunt/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_22_STABLE
  • Loading branch information
Sam Hemelryk committed Dec 20, 2011
2 parents 6005434 + 9660c98 commit 9f83ba0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions question/engine/bank.php
Expand Up @@ -42,6 +42,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
abstract class question_bank { abstract class question_bank {
const MAX_SUMMARY_LENGTH = 65000;

/** @var array question type name => question_type subclass. */ /** @var array question type name => question_type subclass. */
private static $questiontypes = array(); private static $questiontypes = array();


Expand Down
5 changes: 5 additions & 0 deletions question/engine/datalib.php
Expand Up @@ -89,6 +89,11 @@ public function insert_question_attempt(question_attempt $qa, $context) {
$record->minfraction = $qa->get_min_fraction(); $record->minfraction = $qa->get_min_fraction();
$record->flagged = $qa->is_flagged(); $record->flagged = $qa->is_flagged();
$record->questionsummary = $qa->get_question_summary(); $record->questionsummary = $qa->get_question_summary();
if (textlib::strlen($record->questionsummary) > question_bank::MAX_SUMMARY_LENGTH) {
// It seems some people write very long quesions! MDL-30760
$record->questionsummary = textlib::substr($record->questionsummary,
0, question_bank::MAX_SUMMARY_LENGTH - 3) . '...';
}
$record->rightanswer = $qa->get_right_answer_summary(); $record->rightanswer = $qa->get_right_answer_summary();
$record->responsesummary = $qa->get_response_summary(); $record->responsesummary = $qa->get_response_summary();
$record->timemodified = time(); $record->timemodified = time();
Expand Down
5 changes: 5 additions & 0 deletions question/engine/upgrade/upgradelib.php
Expand Up @@ -245,6 +245,11 @@ public function save_usage($preferredbehaviour, $attempt, $qas, $quizlayout) {
$qa = $qas[$questionid]; $qa = $qas[$questionid];
$qa->questionusageid = $attempt->uniqueid; $qa->questionusageid = $attempt->uniqueid;
$qa->slot = $i; $qa->slot = $i;
if (textlib::strlen($qa->questionsummary) > question_bank::MAX_SUMMARY_LENGTH) {
// It seems some people write very long quesions! MDL-30760
$qa->questionsummary = textlib::substr($qa->questionsummary,
0, question_bank::MAX_SUMMARY_LENGTH - 3) . '...';
}
$this->insert_record('question_attempts', $qa); $this->insert_record('question_attempts', $qa);
$layout[$questionkeys[$questionid]] = $qa->slot; $layout[$questionkeys[$questionid]] = $qa->slot;


Expand Down
2 changes: 1 addition & 1 deletion question/type/multianswer/questiontype.php
Expand Up @@ -404,7 +404,7 @@ function qtype_multianswer_extract_question($text) {
&& preg_match('~'.NUMERICAL_ALTERNATIVE_REGEX.'~', && preg_match('~'.NUMERICAL_ALTERNATIVE_REGEX.'~',
$altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], $numregs)) { $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], $numregs)) {
$wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER]; $wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER];
if ($numregs[NUMERICAL_ABS_ERROR_MARGIN]) { if (array_key_exists(NUMERICAL_ABS_ERROR_MARGIN, $numregs)) {
$wrapped->tolerance["$answerindex"] = $wrapped->tolerance["$answerindex"] =
$numregs[NUMERICAL_ABS_ERROR_MARGIN]; $numregs[NUMERICAL_ABS_ERROR_MARGIN];
} else { } else {
Expand Down

0 comments on commit 9f83ba0

Please sign in to comment.