]> git.mjollnir.org Git - moodle.git/commitdiff
fix for 5209
authortoyomoyo <toyomoyo>
Tue, 18 Apr 2006 06:43:29 +0000 (06:43 +0000)
committertoyomoyo <toyomoyo>
Tue, 18 Apr 2006 06:43:29 +0000 (06:43 +0000)
lib/db/migrate2utf8.xml
mod/data/db/migrate2utf8.php
mod/data/db/migrate2utf8.xml
mod/quiz/db/migrate2utf8.xml

index c7e67fa2f5746b09a105e06e7fc872104fa8697c..c04acad68a68718a9e9f147cf66117e061b72757 100755 (executable)
     <TABLE name="user_coursecreators" />
     <TABLE name="course">
       <FIELDS>
+        <FIELD name="currency" method="NO_CONV" type="char" length="3" />
+        <FIELD name="enrol" method="NO_CONV" type="varchar" length="20" />
         <FIELD name="password" method="PHP_FUNCTION" type="varchar" length="50">
           <PHP_FUNCTION>
             migrate2utf8_course_password(RECORDID)
index 4cbb53341ef9b57caea5d53d11139d061a9c9f39..5dde2c340105d90f98d27f1aedd6f00e1f04b195 100755 (executable)
@@ -328,6 +328,46 @@ function migrate2utf8_data_rsstemplate($recordid){
     return $result;
 }
 
+
+function migrate2utf8_data_csstemplate($recordid){
+    global $CFG, $globallang;
+
+/// Some trivial checks
+    if (empty($recordid)) {
+        log_the_problem_somewhere();
+        return false;
+    }
+
+    if (!$data = get_record('data','id',$recordid)) {
+        log_the_problem_somewhere();
+        return false;
+    }
+
+    if ($globallang) {
+        $fromenc = $globallang;
+    } else {
+        $sitelang   = $CFG->lang;
+        $courselang = get_course_lang($data->course);  //Non existing!
+        $userlang   = get_main_teacher_lang($data->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($data->csstemplate, $fromenc);
+
+        $newdata= new object;
+        $newdata->id = $recordid;
+        $newdata->csstemplate = $result;
+        migrate2utf8_update_record('data',$newdata);
+    }
+/// And finally, just return the converted field
+    return $result;
+}
+
+
 function migrate2utf8_data_listtemplateheader($recordid){
     global $CFG, $globallang;
 
index 832b40837a8b20adf907537d513f38863265a02a..fa48f5dd443c53c61cc37eb0365b5057729075f6 100755 (executable)
            migrate2utf_data_listtemplate(RECORDID)
           </PHP_FUNCTION>
         </FIELD>
+        <FIELD name="csstemplate" method="PHP_FUNCTION" type="text" length="0">
+          <PHP_FUNCTION>
+           migrate2utf_data_csstemplate(RECORDID)
+          </PHP_FUNCTION>
+        </FIELD>
         <FIELD name="addtemplate" method="PHP_FUNCTION" type="text" length="0">
           <PHP_FUNCTION>
            migrate2utf_data_addtemplate(RECORDID)
index b5e0f8e31d641728a0329d7f4f0c4753f4e77140..de721ad4e6497e0128e0752ff71e5e4dc44bc4db 100755 (executable)
         <FIELD name="tolerance" method="NO_CONV" type="varchar" length="255" default="0.0" />
       </FIELDS>
     </TABLE>
-    <TABLE name="question_sessions" />
+    <TABLE name="question_sessions">
+      <FIELDS>
+        <FIELD name="comment" method="PLAIN_SQL_UPDATE" type="text" length="0">
+          <SQL_DETECT_USER>
+           SELECT qa.userid
+           FROM {$CFG->prefix}question_sessions qs,
+                {$CFG->prefix}quiz_attempts qa
+           WHERE qa.id = qs.attemptid
+                 AND qs.id = RECORDID
+          </SQL_DETECT_USER>
+          <SQL_DETECT_COURSE>
+           SELECT q.course
+           FROM {$CFG->prefix}quiz q,
+                {$CFG->prefix}question_sessions qs,
+                {$CFG->prefix}quiz_attempts qa
+           WHERE q.id = qa.quiz
+                 AND qa.id = qs.attemptid
+                 AND qs.id = RECORDID
+          </SQL_DETECT_COURSE>
+        </FIELD>
+      </FIELDS>
+    </TABLE>
     <TABLE name="question_multichoice">
       <FIELDS>
         <FIELD name="answers" method="NO_CONV" type="varchar" length="255" />
             migrate2utf8_question_qtype(RECORDID)
           </PHP_FUNCTION>
         </FIELD>
+        <FIELD name="version" method="NO_CONV" type="varchar" length="255" />
         <FIELD name="questiontext" method="PHP_FUNCTION" type="text" length="0">
           <PHP_FUNCTION>
             migrate2utf8_question_questiontext(RECORDID)