mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
fix for MDL-6326, add support for quiz_feedaback table
This commit is contained in:
parent
d9a35e1270
commit
ed60c54a94
2 changed files with 59 additions and 0 deletions
|
@ -1,4 +1,54 @@
|
||||||
<?php // $Id$
|
<?php // $Id$
|
||||||
|
|
||||||
|
function migrate2utf8_quiz_feedback_feedbacktext($recordid) {
|
||||||
|
global $CFG, $globallang;
|
||||||
|
/// Some trivial checks
|
||||||
|
if (empty($recordid)) {
|
||||||
|
log_the_problem_somewhere();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$SQL = "SELECT q.course
|
||||||
|
FROM {$CFG->prefix}quiz_feedback qf,
|
||||||
|
{$CFG->prefix}quiz q
|
||||||
|
WHERE qf.quizid = q.id
|
||||||
|
AND qf.id = $recordid";
|
||||||
|
|
||||||
|
if (!$quiz = get_record_sql($SQL)) {
|
||||||
|
log_the_problem_somewhere();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$quizfeedback = get_record('quiz_feedback','id',$recordid)) {
|
||||||
|
log_the_problem_somewhere();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($globallang) {
|
||||||
|
$fromenc = $globallang;
|
||||||
|
} else {
|
||||||
|
$sitelang = $CFG->lang;
|
||||||
|
$courselang = get_course_lang($quiz->course);
|
||||||
|
$userlang = null; //N.E.!!
|
||||||
|
|
||||||
|
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// We are going to use textlib facilities
|
||||||
|
|
||||||
|
/// Convert the text
|
||||||
|
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||||
|
$result = utfconvert($quizfeedback->feedbacktext, $fromenc);
|
||||||
|
|
||||||
|
$newquizfeedback = new object;
|
||||||
|
$newquizfeedback->id = $recordid;
|
||||||
|
$newquizfeedback->feedbacktext = $result;
|
||||||
|
update_record('quiz_feedback',$newquizfeedback);
|
||||||
|
}
|
||||||
|
/// And finally, just return the converted field
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
function migrate2utf8_question_name($recordid){
|
function migrate2utf8_question_name($recordid){
|
||||||
global $CFG, $globallang;
|
global $CFG, $globallang;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
<DBMIGRATION type="mod/quiz" VERSION="2005120100">
|
<DBMIGRATION type="mod/quiz" VERSION="2005120100">
|
||||||
<TABLES>
|
<TABLES>
|
||||||
|
<TABLE name="quiz_feedback">
|
||||||
|
<FIELDS>
|
||||||
|
<FIELD name="feedbacktext" method="PHP_FUNCTION" type="text" length="0">
|
||||||
|
<PHP_FUNCTION>
|
||||||
|
migrate2utf8_quiz_feedback_feedbacktext(RECORDID)
|
||||||
|
</PHP_FUNCTION>
|
||||||
|
</FIELD>
|
||||||
|
</FIELDS>
|
||||||
|
</TABLE>
|
||||||
<TABLE name="quiz_grades" />
|
<TABLE name="quiz_grades" />
|
||||||
<TABLE name="question_datasets" />
|
<TABLE name="question_datasets" />
|
||||||
<TABLE name="quiz_question_instances" />
|
<TABLE name="quiz_question_instances" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue