fix for 5209

This commit is contained in:
toyomoyo 2006-04-18 06:43:29 +00:00
parent 98ae4e63da
commit 8f23f49004
4 changed files with 70 additions and 1 deletions

View File

@ -342,6 +342,8 @@
<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)

View File

@ -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;

View File

@ -148,6 +148,11 @@
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)

View File

@ -39,7 +39,28 @@
<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" />
@ -109,6 +130,7 @@
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)