From: toyomoyo Date: Mon, 10 Apr 2006 05:08:19 +0000 (+0000) Subject: question->qtype X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a35af29014560b92fc17a419538f837dccf4bdf7;p=moodle.git question->qtype --- diff --git a/mod/quiz/db/migrate2utf8.php b/mod/quiz/db/migrate2utf8.php index 5b0555e12a..3196922b5f 100755 --- a/mod/quiz/db/migrate2utf8.php +++ b/mod/quiz/db/migrate2utf8.php @@ -48,6 +48,56 @@ function migrate2utf8_question_name($recordid){ return $result; } + +function migrate2utf8_question_qtype($recordid){ + global $CFG, $globallang; + +/// Some trivial checks + if (empty($recordid)) { + log_the_problem_somewhere(); + return false; + } + + $SQL = "SELECT qc.course + FROM {$CFG->prefix}question_categories qc, + {$CFG->prefix}question qq + WHERE qc.id = qq.category + AND qq.id = $recordid"; + + if (!$quiz = get_record_sql($SQL)) { + log_the_problem_somewhere(); + return false; + } + + if (!$quizquestions = get_record('question','id',$recordid)) { + log_the_problem_somewhere(); + return false; + } + if ($globallang) { + $fromenc = $globallang; + } else { + $sitelang = $CFG->lang; + $courselang = get_course_lang($quiz->course); //Non existing! + $userlang = get_main_teacher_lang($quiz->course); //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($quizquestions->qtype, $fromenc); + + $newquizquestion = new object; + $newquizquestion->id = $recordid; + $newquizquestion->qtype = $result; + update_record('question',$newquizquestion); + } +/// And finally, just return the converted field + return $result; +} + function migrate2utf8_question_questiontext($recordid){ global $CFG, $globallang; diff --git a/mod/quiz/db/migrate2utf8.xml b/mod/quiz/db/migrate2utf8.xml index 34dfbe31aa..b5e0f8e31d 100755 --- a/mod/quiz/db/migrate2utf8.xml +++ b/mod/quiz/db/migrate2utf8.xml @@ -104,6 +104,11 @@ migrate2utf8_question_name(RECORDID) + + + migrate2utf8_question_qtype(RECORDID) + + migrate2utf8_question_questiontext(RECORDID)