mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
utf8 migration support scripts
This commit is contained in:
parent
bbbb201364
commit
1e4d9ff6dc
36 changed files with 4767 additions and 0 deletions
65
mod/assignment/db/migrate2utf8.php
Executable file
65
mod/assignment/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,65 @@
|
|||
<?
|
||||
function migrate2utf8_assignment_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
if (!$assignment = get_record('assignment', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($assignment->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($assignment->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($assignment->name, $fromenc);
|
||||
|
||||
$newassignment = new object;
|
||||
$newassignment->id = $recordid;
|
||||
$newassignment->name = $result;
|
||||
update_record('assignment',$newassignment);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_assignment_description($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
if (!$assignment = get_record('assignment', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($assignment->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($assignment->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($assignment->description, $fromenc);
|
||||
|
||||
$newassignment = new object;
|
||||
$newassignment->id = $recordid;
|
||||
$newassignment->description = $result;
|
||||
update_record('assignment',$newassignment);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
65
mod/assignment/db/migrate2utf8.xml
Executable file
65
mod/assignment/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,65 @@
|
|||
<DBMIGRATION type="mod/assignment" VERSION = "2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="assignment_submissions">
|
||||
<FIELDS>
|
||||
<FIELD name="data1" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ass.userid
|
||||
FROM {$CFG->prefix}assignment_submissions ass
|
||||
WHERE ass.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT a.course
|
||||
FROM {$CFG->prefix}assignment a,
|
||||
{$CFG->prefix}assignment_submissions ass
|
||||
WHERE a.id = ass.assignment
|
||||
AND ass.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="data2" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ass.userid
|
||||
FROM {$CFG->prefix}assignment_submissions ass
|
||||
WHERE ass.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT a.course
|
||||
FROM {$CFG->prefix}assignment a,
|
||||
{$CFG->prefix}assignment_submissions ass
|
||||
WHERE a.id = ass.assignment
|
||||
AND ass.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="comment" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ass.teacher as userid
|
||||
FROM {$CFG->prefix}assignment_submissions ass
|
||||
WHERE ass.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT a.course
|
||||
FROM {$CFG->prefix}assignment a,
|
||||
{$CFG->prefix}assignment_submissions ass
|
||||
WHERE a.id = ass.assignment
|
||||
AND ass.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="assignment">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_assignment_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="description" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_assignment_description(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="assignmenttype" method="NO_CONV" type="varchar" length="50" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
66
mod/chat/db/migrate2utf8.php
Executable file
66
mod/chat/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,66 @@
|
|||
<?
|
||||
function migrate2utf8_chat_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
if (!$chat = get_record('chat', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($chat->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($chat->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($assignment->name, $fromenc);
|
||||
|
||||
$newchat = new object;
|
||||
$newchat->id = $recordid;
|
||||
$newchat->name = $result;
|
||||
update_record('chat',$newchat);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_chat_intro($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
if (!$chat = get_record('chat', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($chat->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($chat->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($assignment->intro, $fromenc);
|
||||
|
||||
$newchat = new object;
|
||||
$newchat->id = $recordid;
|
||||
$newchat->intro = $result;
|
||||
update_record('chat',$newchat);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
36
mod/chat/db/migrate2utf8.xml
Executable file
36
mod/chat/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,36 @@
|
|||
<DBMIGRATION type="mod/chat" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="chat_messages">
|
||||
<FIELDS>
|
||||
<FIELD name="message" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT chm.userid
|
||||
FROM {$CFG->prefix}chat_messages chm
|
||||
WHERE chm.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT ch.course
|
||||
FROM {$CFG->prefix}chat ch,
|
||||
{$CFG->prefix}chat_messages chm
|
||||
WHERE ch.id = chm.chatid
|
||||
AND chm.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="chat">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<SQL_DETECT_COURSE>
|
||||
migrate2utf8_chat_name(RECORDID)
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
|
||||
<SQL_DETECT_COURSE>
|
||||
migrate2utf8_chat_intro(RECORDID)
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
110
mod/choice/db/migrate2utf8.php
Executable file
110
mod/choice/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,110 @@
|
|||
<?
|
||||
function migrate2utf8_choice_options_text($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT ch.*
|
||||
FROM {$CFG->prefix}choice ch,
|
||||
{$CFG->prefix}choice_options cho
|
||||
WHERE ch.id = cho.choiceid
|
||||
AND cho.id = $recordid";
|
||||
|
||||
if (!$choice = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$choiceoption = get_record('choice_option','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($choice->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($choice->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($choiceotion->text, $fromenc);
|
||||
|
||||
$newchoiceoption = new object;
|
||||
$newchoiceoption->id = $recordid;
|
||||
$newchoiceoption->text = $result;
|
||||
update_record('choice_option',$newchoiceoption);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_choice_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
if (!$choice = get_record('choice', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($choice->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($choice->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($choice->name, $fromenc);
|
||||
|
||||
$newchoice = new object;
|
||||
$newchoice->id = $recordid;
|
||||
$newchoice->name = $result;
|
||||
update_record('choice',$newchoice);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_choice_text($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
if (!$choice = get_record('choice', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($choice->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($choice->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($choice->text, $fromenc);
|
||||
|
||||
$newchoice = new object;
|
||||
$newchoice->id = $recordid;
|
||||
$newchoice->text = $result;
|
||||
update_record('choice',$newchoice);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
27
mod/choice/db/migrate2utf8.xml
Executable file
27
mod/choice/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,27 @@
|
|||
<DBMIGRATION type="mod/choice" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="choice_options">
|
||||
<FIELDS>
|
||||
<FIELD name="text" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_choice_options_text(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="choice">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_choice_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="text" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_choice_text(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
354
mod/data/db/migrate2utf8.php
Executable file
354
mod/data/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,354 @@
|
|||
<?
|
||||
function migrate2utf8_data_fields_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT d.course
|
||||
FROM {$CFG->prefix}data_fields df,
|
||||
{$CFG->prefix}data d
|
||||
WHERE d.id = df.dataid
|
||||
AND df.id = $recordid";
|
||||
|
||||
if (!$data = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$datafield = get_record('data_fields','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($datafield->name, $fromenc);
|
||||
|
||||
$newdatafield = new object;
|
||||
$newdatafield->id = $recordid;
|
||||
$newdatafield->name = $result;
|
||||
update_record('data_fields',$newdatafield);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_fields_description($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT d.course
|
||||
FROM {$CFG->prefix}data_fields df,
|
||||
{$CFG->prefix}data d
|
||||
WHERE d.id = df.dataid
|
||||
AND df.id = $recordid";
|
||||
|
||||
if (!$data = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$datafield = get_record('data_fields','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($datafield->description, $fromenc);
|
||||
|
||||
$newdatafield = new object;
|
||||
$newdatafield->id = $recordid;
|
||||
$newdatafield->description = $result;
|
||||
update_record('data_fields',$newdatafield);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($data->name, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->name = $result;
|
||||
update_record('data',$newdata);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_intro($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($data->intro, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->intro = $result;
|
||||
update_record('data',$newdata);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_singletemplate($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($data->singletemplate, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->singletemplate = $result;
|
||||
update_record('data',$newdata);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_listtemplate($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($data->listtemplate, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->listtemplate = $result;
|
||||
update_record('data',$newdata);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_addtemplate($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($data->addtemplate, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->addtemplate = $result;
|
||||
update_record('data',$newdata);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_rsstemplate($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($data->rsstemplate, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->rsstemplate = $result;
|
||||
update_record('data',$newdata);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_listtemplateheader($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($data->listtemplateheade, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->listtemplateheader = $result;
|
||||
update_record('data',$newdata);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_listtemplatefooter($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($data->listtemplatefooter, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->listtemplatefooter = $result;
|
||||
update_record('data',$newdata);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
100
mod/data/db/migrate2utf8.xml
Executable file
100
mod/data/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,100 @@
|
|||
<DBMIGRATION type="mod/data" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="data_comments">
|
||||
<FIELDS>
|
||||
<FIELD name="content" method="NO_CONV" type="text" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="data_content">
|
||||
<FIELDS>
|
||||
<FIELD name="content" method="PLAIN_SQL_UPDATE" type="longtext" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT dr.userid
|
||||
FROM {$CFG->prefix}data_records dr,
|
||||
{$CFG->prefix}data_content dc
|
||||
WHERE dr.id = dc.recordid
|
||||
AND dc.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT d.course
|
||||
FROM {$CFG->prefix}data_records dr,
|
||||
{$CFG->prefix}data d,
|
||||
{$CFG->prefix}data_content dc
|
||||
WHERE d.id = dr.dataid
|
||||
AND dr.id = dc.recordid
|
||||
AND dc.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="data_fields">
|
||||
<FIELDS>
|
||||
<FIELD name="type" method="NO_CONV" type="varchar" length="255" />
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_fields_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="description" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_fields_description(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="param1" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param2" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param3" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param4" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param5" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param6" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param7" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param8" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param9" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="param10" method="NO_CONV" type="text" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="data">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_intro(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="singletemplate" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_singletemplate(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="listtemplate" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_listtemplate(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="addtemplate" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_addtemplate(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="rsstemplate" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_rsstemplate(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="listtemplateheader" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_listtemplateheader(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="listtemplatefooter" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_listtemplatefooter(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
172
mod/exercise/db/migrate2utf8.php
Executable file
172
mod/exercise/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,172 @@
|
|||
<?
|
||||
function migrate2utf8_exercise_elements_description($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT ex.course
|
||||
FROM {$CFG->prefix}exercise ex,
|
||||
{$CFG->prefix}exercise_elements exe
|
||||
WHERE ex.id = exe.exerciseid
|
||||
AND exe.id = $recordid";
|
||||
|
||||
if (!$exercise = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$exerciseelement = get_record('exercise_elements','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($exercise->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($exercise->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($exerciseelement->description, $fromenc);
|
||||
|
||||
$newexerciseelement = new object;
|
||||
$newexerciseelement->id = $recordid;
|
||||
$newexerciseelement->description = $result;
|
||||
update_record('exercise_elements',$newexerciseelement);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_exercise_grades_feedback($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT ex.course
|
||||
FROM {$CFG->prefix}exercise ex,
|
||||
{$CFG->prefix}exercise_rubrics exr
|
||||
WHERE ex.id = exr.exerciseid
|
||||
AND exr.id = $recordid";
|
||||
|
||||
if (!$exercise = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$exercisegrade = get_record('exercise_grades','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($exercise->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($exercise->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($exercisegrade->feedback, $fromenc);
|
||||
|
||||
$newexercisegrade = new object;
|
||||
$newexercisegrade->id = $recordid;
|
||||
$newexercisegrade->feedback = $result;
|
||||
update_record('exercise_grades',$newexercisegrade);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_exercise_rubrics_description($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT ex.course
|
||||
FROM {$CFG->prefix}exercise ex,
|
||||
{$CFG->prefix}exercise_rubrics exr
|
||||
WHERE ex.id = exr.exerciseid
|
||||
AND exr.id = $recordid";
|
||||
|
||||
if (!$exercise = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$exerciserubric = get_record('exercise_rubrics','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($exercise->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($exercise->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($exerciserubric->description, $fromenc);
|
||||
|
||||
$newexerciserubric = new object;
|
||||
$newexerciserubric->id = $recordid;
|
||||
$newexerciserubric->description = $result;
|
||||
update_record('exercise_rubrics',$newexerciserubric);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_exercise_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$exercise = get_record('exercise','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($exercise->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($exercise->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($exercise->name, $fromenc);
|
||||
|
||||
$newexercise = new object;
|
||||
$newexercise->id = $recordid;
|
||||
$newexercise->name = $result;
|
||||
update_record('exercise',$newexercise);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_exercise_password($recordid){
|
||||
global $CFG;
|
||||
|
||||
///um
|
||||
}
|
||||
?>
|
95
mod/exercise/db/migrate2utf8.xml
Executable file
95
mod/exercise/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,95 @@
|
|||
<DBMIGRATION type="mod/exercise" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="exercise_assessments">
|
||||
<FIELDS>
|
||||
<FIELD name="generalcomment" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT exa.userid
|
||||
FROM {$CFG->prefix}exercise_assessments exa
|
||||
WHERE exa.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT ex.course
|
||||
FROM {$CFG->prefix}exercise ex,
|
||||
{$CFG->prefix}exercise_assessments exa
|
||||
WHERE ex.id = exa.exerciseid
|
||||
AND exa.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="teachercomment" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT exa.userid
|
||||
FROM {$CFG->prefix}exercise_assessments exa
|
||||
WHERE exa.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT ex.course
|
||||
FROM {$CFG->prefix}exercise ex,
|
||||
{$CFG->prefix}exercise_assessments exa
|
||||
WHERE ex.id = exa.exerciseid
|
||||
AND exa.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="exercise_elements">
|
||||
<FIELDS>
|
||||
<FIELD name="description" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_exercise_elements_description(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="exercise_grades">
|
||||
<FIELDS>
|
||||
<FIELD name="feedback" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_exercise_grades_feedback(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="exercise_rubrics">
|
||||
<FIELDS>
|
||||
<FIELD name="description" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_exercise_rubrics_description(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="exercise_submissions">
|
||||
<FIELDS>
|
||||
<FIELD name="title" method="PLAIN_SQL_UPDATE" type="varchar" length="100">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT exs.userid
|
||||
FROM {$CFG->prefix}exercise_submissions exs
|
||||
WHERE exs.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT ex.course
|
||||
FROM {$CFG->prefix}exercise ex,
|
||||
{$CFG->prefix}exercise_submissions exs
|
||||
WHERE ex.id = exs.exerciseid
|
||||
AND exs.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="exercise">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_exercise_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="password" method="PHP_FUNCTION" type="varchar" length="32">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_exercise_password(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
67
mod/forum/db/migrate2utf8.php
Executable file
67
mod/forum/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,67 @@
|
|||
<?
|
||||
function migrate2utf8_forum_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$forum = get_record('forum','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($forum->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($forum->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($forum->name, $fromenc);
|
||||
|
||||
$newforum = new object;
|
||||
$newforum->id = $recordid;
|
||||
$newforum->name = $result;
|
||||
update_record('forum',$newforum);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_forum_intro($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$forum = get_record('forum','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($forum->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($forum->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($forum->intro, $fromenc);
|
||||
|
||||
$newforum = new object;
|
||||
$newforum->id = $recordid;
|
||||
$newforum->intro = $result;
|
||||
update_record('forum',$newforum);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
67
mod/forum/db/migrate2utf8.xml
Executable file
67
mod/forum/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,67 @@
|
|||
<DBMIGRATION type="mod/forum" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="forum_discussions">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT fd.userid
|
||||
FROM {$CFG->prefix}forum_discussions fd
|
||||
WHERE fd.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT f.course
|
||||
FROM {$CFG->prefix}forum_discussions fd
|
||||
WHERE fd.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="forum_posts">
|
||||
<FIELDS>
|
||||
<FIELD name="subject" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT fp.userid
|
||||
FROM {$CFG->prefix}forum_posts fp
|
||||
WHERE fp.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT fd.course
|
||||
FROM {$CFG->prefix}forum_discussions fd,
|
||||
{$CFG->prefix}forum_posts fp
|
||||
WHERE fd.id = fp.discussion
|
||||
AND fp.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="message" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT fp.userid
|
||||
FROM {$CFG->prefix}forum_posts fp
|
||||
WHERE fp.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT fd.course
|
||||
FROM {$CFG->prefix}forum_discussions fd,
|
||||
{$CFG->prefix}forum_posts fp
|
||||
WHERE fd.id = fp.discussion
|
||||
AND fp.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="attachment" method="NO_CONV" type="varchar" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="forum">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_forum_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_forum_intro(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
110
mod/glossary/db/migrate2utf8.php
Executable file
110
mod/glossary/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,110 @@
|
|||
<?
|
||||
function migrate2utf8_glossary_categories_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
$SQL = "SELECT g.course
|
||||
FROM {$CFG->prefix}glossary g,
|
||||
{$CFG->prefix}glossary_categories gc
|
||||
WHERE g.id = gc.glossaryid
|
||||
AND gc.id = $recordid";
|
||||
|
||||
if (!$glossary = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$glossarycategory = get_record_sql('glossary_categories','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($glossary->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($glossary->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($glossarycategory->name, $fromenc);
|
||||
|
||||
$newglossarycategory = new object;
|
||||
$newglossarycategory->id = $recordid;
|
||||
$newglossarycategory->name = $result;
|
||||
update_record('forum',$newglossarycategory);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_glossary_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$glossary = get_record('glossary','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($glossary->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($glossary->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($glossary->name, $fromenc);
|
||||
|
||||
$newglossary = new object;
|
||||
$newglossary->id = $recordid;
|
||||
$newglossary->name = $result;
|
||||
update_record('glossary',$newglossary);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_glossary_intro($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$glossary = get_record('glossary','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($glossary->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($glossary->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($glossary->intro, $fromenc);
|
||||
|
||||
$newglossary = new object;
|
||||
$newglossary->id = $recordid;
|
||||
$newglossary->intro = $result;
|
||||
update_record('glossary',$newglossary);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
113
mod/glossary/db/migrate2utf8.xml
Executable file
113
mod/glossary/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,113 @@
|
|||
<DBMIGRATION type="mod/glossary" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="glossary_entries">
|
||||
<FIELDS>
|
||||
<FIELD name="concept" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ge.userid
|
||||
FROM {$CFG->prefix}glossary_entries ge
|
||||
WHERE ge.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT g.course
|
||||
FROM {$CFG->prefix}glossary g,
|
||||
{$CFG->prefix}glossary_entries ge
|
||||
WHERE g.id = ge.glossaryid
|
||||
AND ge.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="definition" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ge.userid
|
||||
FROM {$CFG->prefix}glossary_entries ge
|
||||
WHERE ge.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT g.course
|
||||
FROM {$CFG->prefix}glossary g,
|
||||
{$CFG->prefix}glossary_entries ge
|
||||
WHERE g.id = ge.glossaryid
|
||||
AND ge.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="attachment" method="NO_CONV" type="varchar" length="100" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="glossary_categories">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_glossary_categories(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="glossary_comments">
|
||||
<FIELDS>
|
||||
<FIELD name="comment" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT gco.userid
|
||||
FROM {$CFG->prefix}glossary_comments gco
|
||||
WHERE gco.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT g.course
|
||||
FROM {$CFG->prefix}glossary g,
|
||||
{$CFG->prefix}glossary_entries ge,
|
||||
{$CFG->prefix}glossary_comments gco
|
||||
WHERE g.id = ge.glossaryid
|
||||
AND ge.id = gco.entryid
|
||||
AND gco.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="glossary_alias">
|
||||
<FIELDS>
|
||||
<FIELD name="alias" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ge.userid
|
||||
FROM {$CFG->prefix}glossary_entries ge,
|
||||
{$CFG->prefix}glossary_alias ga
|
||||
WHERE ga.entryid = ge.id
|
||||
AND ge.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT g.course
|
||||
FROM {$CFG->prefix}glossary g,
|
||||
{$CFG->prefix}glossary_entries ge,
|
||||
{$CFG->prefix}glossary_alias ga
|
||||
WHERE g.id = ge.glossaryid
|
||||
AND ge.id = ga.entryid
|
||||
AND ga.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="glossary_formats">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="NO_CONV" type="varchar" length="50" />
|
||||
<FIELD name="popupformatname" method="NO_CONV" type="varchar" length="50" />
|
||||
<FIELD name="defaultmode" method="NO_CONV" type="varchar" length="50" />
|
||||
<FIELD name="defaulthook" method="NO_CONV" type="varchar" length="50" />
|
||||
<FIELD name="sortkey" method="NO_CONV" type="varchar" length="50" />
|
||||
<FIELD name="sortorder" method="NO_CONV" type="varchar" length="50" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="glossary">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_glossary_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_glossary_intro(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="displayformat" method="NO_CONV" type="varchar" length="50" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
186
mod/hotpot/db/migrate2utf8.php
Executable file
186
mod/hotpot/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,186 @@
|
|||
<?
|
||||
function migrate2utf_hotpot_questions_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
$SQL = "SELECT h.course
|
||||
FROM {$CFG->prefix}hotpot h,
|
||||
{$CFG->prefix}hotpot_questions hq
|
||||
WHERE h.id = hq.hotpot
|
||||
AND hq.id = $recordid";
|
||||
|
||||
if (!$hotpot = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$hotpotquestion = get_record_sql('hotpot_questions','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($hotpot->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($hotpot->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($hotpotquestion->name, $fromenc);
|
||||
|
||||
$newhotpotquestion = new object;
|
||||
$newhotpotquestion->id = $recordid;
|
||||
$newhotpotquestion->name = $result;
|
||||
update_record('forum',$newhotpotquestion);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_hotpot_questions_text($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
$SQL = "SELECT h.course
|
||||
FROM {$CFG->prefix}hotpot h,
|
||||
{$CFG->prefix}hotpot_questions hq
|
||||
WHERE h.id = hq.hotpot
|
||||
AND hq.id = $recordid";
|
||||
|
||||
if (!$hotpot = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$hotpotquestion = get_record_sql('hotpot_questions','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($hotpot->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($hotpot->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($hotpotquestion->text, $fromenc);
|
||||
|
||||
$newhotpotquestion = new object;
|
||||
$newhotpotquestion->id = $recordid;
|
||||
$newhotpotquestion->text = $result;
|
||||
update_record('forum',$newhotpotquestion);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_hotpot_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$hotpot = get_record('hotpot','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($hotpot->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($hotpot->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($hotpot->name, $fromenc);
|
||||
|
||||
$newhotpot = new object;
|
||||
$newhotpot->id = $recordid;
|
||||
$newhotpot->name = $result;
|
||||
update_record('hotpot',$newhotpot);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_glossary_summary($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$hotpot = get_record('hotpot','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($hotpot->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($hotpot->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($hotpot->summary, $fromenc);
|
||||
|
||||
$newglossary = new object;
|
||||
$newglossary->id = $recordid;
|
||||
$newglossary->summary = $result;
|
||||
update_record('hotpot',$newhotpot);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_glossary_password($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$hotpot = get_record('hotpot','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($hotpot->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($hotpot->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($hotpot->password, $fromenc);
|
||||
|
||||
$newglossary = new object;
|
||||
$newglossary->id = $recordid;
|
||||
$newglossary->password = $result;
|
||||
update_record('hotpot',$newhotpot);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
61
mod/hotpot/db/migrate2utf8.xml
Executable file
61
mod/hotpot/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,61 @@
|
|||
<DBMIGRATION type="mod/hotpot" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="hotpot_details">
|
||||
<FIELDS>
|
||||
<FIELD name="details" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
</SQL_DETECT_USER>
|
||||
SELECT ha.userid
|
||||
FROM {$CFG->prefix}hotpot_attempts ha,
|
||||
{$CFG->prefix}hotpot_details hd
|
||||
WHERE AND ha.id = hd.attempt
|
||||
AND hd.id = RECORDID
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT h.course
|
||||
FROM {$CFG->prefix}hotpot h,
|
||||
{$CFG->prefix}hotpot_attempts ha,
|
||||
{$CFG->prefix}hotpot_details hd
|
||||
WHERE h.id = ha.hotpot
|
||||
AND ha.id = hd.attempt
|
||||
AND hd.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="hotpot_questions">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_hotpot_questions_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="text" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_hotpot_questions_text(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="hotpot">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_hotpot_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="reference" method="NO_CONV" type="varchar" length="255" />
|
||||
<FIELD name="summary" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_hotpot_summary(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="password" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_hotpot_password(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="subnet" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
67
mod/journal/db/migrate2utf8.php
Executable file
67
mod/journal/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,67 @@
|
|||
<?
|
||||
function migrate2utf_journal_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$journal = get_record('journal','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($journal->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($journal->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($journal->name, $fromenc);
|
||||
|
||||
$newjournal = new object;
|
||||
$newjournal->id = $recordid;
|
||||
$newjournal->name = $result;
|
||||
update_record('journal',$newjournal);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_glossary_intro($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$journal = get_record('journal','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($journal->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($journal->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($journal->intro, $fromenc);
|
||||
|
||||
$newjournal = new object;
|
||||
$newjournal->id = $recordid;
|
||||
$newjournal->intro = $result;
|
||||
update_record('journal',$newjournal);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
50
mod/journal/db/migrate2utf8.xml
Executable file
50
mod/journal/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,50 @@
|
|||
<DBMIGRATION type="mod/journel" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="journal_entries">
|
||||
<FIELDS>
|
||||
<FIELD name="text" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT je.userid
|
||||
FROM {$CFG->prefix}journal_entries je
|
||||
WHERE je.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT j.course
|
||||
FROM {$CFG->prefix}journal j,
|
||||
{$CFG->prefix}journal_entries
|
||||
WHERE j.id = je.journal
|
||||
AND je.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="comment" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT je.userid
|
||||
FROM {$CFG->prefix}journal_entries je
|
||||
WHERE je.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT j.course
|
||||
FROM {$CFG->prefix}journal j,
|
||||
{$CFG->prefix}journal_entries
|
||||
WHERE j.id = je.journal
|
||||
AND je.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="journal">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_journal_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_journal_intro(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
67
mod/label/db/migrate2utf8.php
Executable file
67
mod/label/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,67 @@
|
|||
<?
|
||||
function migrate2utf_label_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$label = get_record('label','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($label->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($label->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($label->name, $fromenc);
|
||||
|
||||
$newlabel = new object;
|
||||
$newlabel->id = $recordid;
|
||||
$newlabel->name = $result;
|
||||
update_record('label',$newlabel);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_label_content($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$label = get_record('label','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($label->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($label->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($label->content, $fromenc);
|
||||
|
||||
$newlabel = new object;
|
||||
$newlabel->id = $recordid;
|
||||
$newlabel->content = $result;
|
||||
update_record('label',$newlabel);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
18
mod/label/db/migrate2utf8.xml
Executable file
18
mod/label/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,18 @@
|
|||
<DBMIGRATION type="mod/label" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="label">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_label_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="content" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_label_content(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
67
mod/lams/db/migrate2utf8.php
Executable file
67
mod/lams/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,67 @@
|
|||
<?
|
||||
function migrate2utf_lams_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$lams = get_record('lams','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($lams->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($lams->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($lams->name, $fromenc);
|
||||
|
||||
$newlams = new object;
|
||||
$newlams->id = $recordid;
|
||||
$newlams->name = $result;
|
||||
update_record('lams',$newlams);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_lams_introduction($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$lams = get_record('lams','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($lams->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($lams->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($lams->introduction, $fromenc);
|
||||
|
||||
$newlams = new object;
|
||||
$newlams->id = $recordid;
|
||||
$newlams->introduction = $result;
|
||||
update_record('lams',$newlams);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
18
mod/lams/db/migrate2utf8.xml
Executable file
18
mod/lams/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,18 @@
|
|||
<DBMIGRATION type="mod/lams" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="lams">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lams_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="introduction" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lams_introduction(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
221
mod/lesson/db/migrate2utf8.php
Executable file
221
mod/lesson/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,221 @@
|
|||
<?
|
||||
function migrate2utf8_lesson_answers_answer($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT l.course
|
||||
FROM {$CFG->prefix}lesson l,
|
||||
{$CFG->prefix}lesson_answers la
|
||||
WHERE l.id = la.lessonid
|
||||
AND la.id = $recordid";
|
||||
|
||||
if (!$lessonanswers = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$lesson = get_record('lesson','id',$lessonanswers->course)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($lessonanswers->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($lessonanswers->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($lessonanswers->answer, $fromenc);
|
||||
|
||||
$newlessonanswers = new object;
|
||||
$newlessonanswers->id = $recordid;
|
||||
$newlessonanswers->answer = $result;
|
||||
update_record('lesson_answers',$newlessonanswers);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_lesson_answers_response($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT l.course
|
||||
FROM {$CFG->prefix}lesson l,
|
||||
{$CFG->prefix}lesson_answers la
|
||||
WHERE l.id = la.lessonid
|
||||
AND la.id = $recordid";
|
||||
|
||||
if (!$lessonanswers = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$lesson = get_record('lesson','id',$lessonanswers->course)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($lessonanswers->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($lessonanswers->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($lessonanswers->response, $fromenc);
|
||||
|
||||
$newlessonanswers = new object;
|
||||
$newlessonanswers->id = $recordid;
|
||||
$newlessonanswers->response = $result;
|
||||
update_record('lesson_answers',$newlessonanswers);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_lesson_default_password($recordid){
|
||||
|
||||
///um
|
||||
|
||||
}
|
||||
|
||||
|
||||
function migrate2utf8_lesson_pages_contents($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT l.course
|
||||
FROM {$CFG->prefix}lesson l,
|
||||
{$CFG->prefix}lesson_pages lp
|
||||
WHERE l.id = lp.lessonid
|
||||
AND lp.id = $recordid";
|
||||
|
||||
if (!$lessonpages = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$lesson = get_record('lesson','id',$lessonpages->course)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($lessonpages->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($lessonpages->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($lessonpages->contents, $fromenc);
|
||||
|
||||
$newlessonpages = new object;
|
||||
$newlessonpages->id = $recordid;
|
||||
$newlessonpages->contents = $result;
|
||||
update_record('lesson_answers',$newlessonpages);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_lesson_pages_title($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT l.course
|
||||
FROM {$CFG->prefix}lesson l,
|
||||
{$CFG->prefix}lesson_pages lp
|
||||
WHERE l.id = lp.lessonid
|
||||
AND lp.id = $recordid";
|
||||
|
||||
if (!$lessonpages = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$lesson = get_record('lesson','id',$lessonpages->course)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($lessonpages->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($lessonpages->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($lessonpages->title, $fromenc);
|
||||
|
||||
$newlessonpages = new object;
|
||||
$newlessonpages->id = $recordid;
|
||||
$newlessonpages->title = $result;
|
||||
update_record('lesson_answers',$newlessonpages);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_lesson_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$lesson = get_record('lesson','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($lesson->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($lesson->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($lesson->name, $fromenc);
|
||||
|
||||
$newlesson = new object;
|
||||
$newlesson->id = $recordid;
|
||||
$newlesson->name = $result;
|
||||
update_record('lesson',$newlesson);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_lesson_password($recordid){
|
||||
///um
|
||||
}
|
||||
?>
|
80
mod/lesson/db/migrate2utf8.xml
Executable file
80
mod/lesson/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,80 @@
|
|||
<DBMIGRATION type="mod/lesson" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="lesson_attempt">
|
||||
<FIELDS>
|
||||
<FIELD name="useranswer" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT la.userid
|
||||
FROM {$CFG->prefix}lesson_attempt la
|
||||
WHERE la.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT l.course
|
||||
FROM {$CFG->prefix}lesson l,
|
||||
{$CFG->prefix}lesson_attempt la
|
||||
WHERE l.id = la.lessonid
|
||||
AND la.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="lesson_high_scores">
|
||||
<FIELDS>
|
||||
<FIELD name="nickname" method="NO_CONV" type="varchar" length="5" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="lesson_answers">
|
||||
<FIELDS>
|
||||
<FIELD name="answer" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lesson_answers_answer(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="response" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lesson_answers_answer(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="lesson_default">
|
||||
<FIELDS>
|
||||
<FIELD name="password" method="PHP_FUNCTION" type="varchar" length="32">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lesson_default_password(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="bgcolor" method="NO_CONV" type="varchar" length="7" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="lesson_pages">
|
||||
<FIELDS>
|
||||
<FIELD name="title" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lesson_pages_title(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="contents" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lesson_pages_content(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="lesson">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lesson_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="password" method="PHP_FUNCTION" type="varchar" length="32">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_lesson_password(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="bgcolor" method="NO_CONV" type="varchar" length="7" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
502
mod/quiz/db/migrate2utf8.php
Executable file
502
mod/quiz/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,502 @@
|
|||
<?
|
||||
function migrate2utf8_quiz_questions_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
{$CFG->prefix}quiz_questions 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('quiz_questions','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quizquestions->name, $fromenc);
|
||||
|
||||
$newquizquestion = new object;
|
||||
$newquizquestion->id = $recordid;
|
||||
$newquizquestion->name = $result;
|
||||
update_record('quiz_question',$newquizquestion);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_questions_questiontext($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
{$CFG->prefix}quiz_questions 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('quiz_questions','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quizquestions->questiontext, $fromenc);
|
||||
|
||||
$newquizquestion = new object;
|
||||
$newquizquestion->id = $recordid;
|
||||
$newquizquestion->questiontext = $result;
|
||||
update_record('quiz_question',$newquizquestion);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function migrate2utf8_quiz_numerical_units_unit($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
{$CFG->prefix}quiz_questions qq,
|
||||
{$CFG->prefix}quiz_numerical_units qnu
|
||||
WHERE qc.id = qq.category
|
||||
AND qq.id = qnu.question
|
||||
AND qnu.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quiznumericalunits = get_record('quiz_numerical_units','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quiznumericalunits->unit, $fromenc);
|
||||
|
||||
$newquiznumericalunits = new object;
|
||||
$newquiznumericalunits->id = $recordid;
|
||||
$newquiznumericalunits->unit = $result;
|
||||
update_record('quiz_numerical_units',$newquiznumericalunits);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_match_sub_questiontext($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
{$CFG->prefix}quiz_questions qq,
|
||||
{$CFG->prefix}quiz_match_sub qms
|
||||
WHERE qc.id = qq.category
|
||||
AND qq.id = qms.question
|
||||
AND qms.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizmatchsub = get_record('quiz_match_sub','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quizmatchsub->questiontext, $fromenc);
|
||||
|
||||
$newquizmatchsub = new object;
|
||||
$newquizmatchsub->id = $recordid;
|
||||
$newquizmatchsub->questiontext = $result;
|
||||
update_record('quiz_numerical_units',$newquizmatchsub);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_match_sub_answertext($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
{$CFG->prefix}quiz_questions qq,
|
||||
{$CFG->prefix}quiz_match_sub qms
|
||||
WHERE qc.id = qq.category
|
||||
AND qq.id = qms.question
|
||||
AND qms.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizmatchsub = get_record('quiz_match_sub','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quizmatchsub->answertext, $fromenc);
|
||||
|
||||
$newquizmatchsub = new object;
|
||||
$newquizmatchsub->id = $recordid;
|
||||
$newquizmatchsub->answertext = $result;
|
||||
update_record('quiz_numerical_units',$newquizmatchsub);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_answer_answer($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
{$CFG->prefix}quiz_questions qq,
|
||||
{$CFG->prefix}quiz_answer qa
|
||||
WHERE qc.id = qq.category
|
||||
AND qq.id = qa.question
|
||||
AND qa.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizanswer= get_record('quiz_answer','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quizanswer->answer, $fromenc);
|
||||
|
||||
$newquizanswer = new object;
|
||||
$newquizanswer->id = $recordid;
|
||||
$newquizanswer->answer = $result;
|
||||
update_record('quiz_answer',$newquizanswer);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_dataset_definitions_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
{$CFG->prefix}quiz_dataset_definitions qdd
|
||||
WHERE qc.id = qdd.category
|
||||
AND qdd.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizdatasetdefinition = get_record('quiz_answer','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quizdatasetdefinition->name, $fromenc);
|
||||
|
||||
$newquizdatasetdefinition = new object;
|
||||
$newquizdatasetdefinition->id = $recordid;
|
||||
$newquizdatasetdefinition->name = $result;
|
||||
update_record('quiz_dataset_definition',$newquizdatasetdefinition);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_categories_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
WHERE qc.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizcategory = get_record('quiz_categories','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quizcategory->name, $fromenc);
|
||||
|
||||
$newquizcategory = new object;
|
||||
$newquizcategory->id = $recordid;
|
||||
$newquizcategory->name = $result;
|
||||
update_record('quiz_category',$newquizcategory);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_categories_info($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT qc.course
|
||||
FROM {$CFG->prefix}quiz_categories qc,
|
||||
WHERE qc.id = $recordid";
|
||||
|
||||
if (!$quiz = get_record_sql($SQL)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quizcategory = get_record('quiz_categories','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quizcategory->info, $fromenc);
|
||||
|
||||
$newquizcategory = new object;
|
||||
$newquizcategory->id = $recordid;
|
||||
$newquizcategory->info = $result;
|
||||
update_record('quiz_category',$newquizcategory);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quiz = get_record('quiz','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quiz->name, $fromenc);
|
||||
|
||||
$newquiz = new object;
|
||||
$newquiz->id = $recordid;
|
||||
$newquiz->name = $result;
|
||||
update_record('quiz',$newquiz);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function migrate2utf8_quiz_intro($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quiz = get_record('quiz','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quiz->intro, $fromenc);
|
||||
|
||||
$newquiz = new object;
|
||||
$newquiz->id = $recordid;
|
||||
$newquiz->intro = $result;
|
||||
update_record('quiz',$newquiz);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_quiz_password($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$quiz = get_record('quiz','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$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
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($quiz->password, $fromenc);
|
||||
|
||||
$newquiz = new object;
|
||||
$newquiz->id = $recordid;
|
||||
$newquiz->password = $result;
|
||||
update_record('quiz',$newquiz);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
208
mod/quiz/db/migrate2utf8.xml
Executable file
208
mod/quiz/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,208 @@
|
|||
<DBMIGRATION type="mod/quiz" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="quiz_shortanswer">
|
||||
<FIELDS>
|
||||
<FIELD name="answers" method="NO_CONV" type="text" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_numerical">
|
||||
<FIELDS>
|
||||
<FIELD name="tolerance" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_newest_states">
|
||||
<FIELDS>
|
||||
<FIELD name="sumpenalty" method="NO_CONV" type="varchar" length="10" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_multichoice">
|
||||
<FIELDS>
|
||||
<FIELD name="answers" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_multianswers">
|
||||
<FIELDS>
|
||||
<FIELD name="answers" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_match">
|
||||
<FIELDS>
|
||||
<FIELD name="subquestions" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_essay">
|
||||
<FIELDS>
|
||||
<FIELD name="answer" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_dataset_items">
|
||||
<FIELDS>
|
||||
<FIELD name="value" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_calculated">
|
||||
<FIELDS>
|
||||
<FIELD name="tolerance" method="NO_CONV" type="varchar" length="20" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_attempts">
|
||||
<FIELDS>
|
||||
<FIELD name="sumgrades" method="NO_CONV" type="varchar" length="10" />
|
||||
<FIELD name="layout" method="NO_CONV" type="text" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_states">
|
||||
<FIELDS>
|
||||
<FIELD name="answer" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT qa.userid
|
||||
FROM {$CFG->prefix}quiz_states qs,
|
||||
{$CFG->prefix}quiz_attempts qa
|
||||
WHERE qa.id = qs.attempt
|
||||
AND qs.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT q.course
|
||||
FROM {$CFG->prefix}quiz q,
|
||||
{$CFG->prefix}quiz_states qs,
|
||||
{$CFG->prefix}quiz_attempts qa
|
||||
WHERE q.id = qa.quiz
|
||||
AND qa.id = qs.attempt
|
||||
AND qs.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="grade" method="NO_CONV" type="varchar" length="10" />
|
||||
<FIELD name="raw_grade" method="NO_CONV" type="varchar" length="10" />
|
||||
<FIELD name="penalty" method="NO_CONV" type="varchar" length="10" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_questions">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_questions_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="questiontext" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_questions_questiontext(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="image" method="NO_CONV" type="varchar" length="255" />
|
||||
<FIELD name="stamp" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_numerical_units">
|
||||
<FIELDS>
|
||||
<FIELD name="unit" method="PHP_FUNCTION" type="varchar" length="50">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_numerical_units_unit(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_match_sub">
|
||||
<FIELDS>
|
||||
<FIELD name="questiontext" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_quiz_match_sub_questionext(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="answertext" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_quiz_match_sub_answertext(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_answer">
|
||||
<FIELDS>
|
||||
<FIELD name="answer" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_answer_answer(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="fraction" method="NO_CONV" type="varchar" length="10" />
|
||||
<FIELD name="feedback" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_answer_feedback(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_dataset_definitions">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_dataset_definitions_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="options" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_essay_states">
|
||||
<FIELDS>
|
||||
<FIELD name="fraction" method="NO_CONV" type="varchar" length="10" />
|
||||
<FIELD name="response" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT qa.userid
|
||||
FROM {$CFG->prefix}quiz_states qs,
|
||||
{$CFG->prefix}quiz_attempts qa,
|
||||
{$CFG->prefix}quiz_essay_states qes
|
||||
WHERE qa.id = qs.attempt
|
||||
AND qs.id = qes.stateid
|
||||
AND qes.id = RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT q.course
|
||||
FROM {$CFG->prefix}quiz q,
|
||||
{$CFG->prefix}quiz_attempts qa,
|
||||
{$CFG->prefix}quiz_states qs,
|
||||
{$CFG->prefix}quiz_essay_states qes
|
||||
WHERE q.id = qa.quiz
|
||||
AND qa.id = qs.attempt
|
||||
AND qs.id = qes.stateid
|
||||
AND qes.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="options" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz_categories">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_categories_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="info" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_categories_info(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="stamp" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="quiz">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_intro(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="questions" method="NO_CONV" type="varchar" length="255" />
|
||||
<FIELD name="password" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_quiz_password(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="subnet" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
133
mod/resource/db/migrate2utf8.php
Executable file
133
mod/resource/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,133 @@
|
|||
<?
|
||||
function migrate2utf_resource_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$resource = get_record('resource','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($resource->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($resource->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($resource->name, $fromenc);
|
||||
|
||||
$newresource = new object;
|
||||
$newresource->id = $recordid;
|
||||
$newresource->name = $result;
|
||||
update_record('resource',$newresource);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_resource_reference($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$resource = get_record('resource','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($resource->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($resource->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($resource->reference, $fromenc);
|
||||
|
||||
$newresource = new object;
|
||||
$newresource->id = $recordid;
|
||||
$newresource->reference = $result;
|
||||
update_record('resource',$newresource);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_resource_summary($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$resource = get_record('resource','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($resource->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($resource->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($resource->summary, $fromenc);
|
||||
|
||||
$newresource = new object;
|
||||
$newresource->id = $recordid;
|
||||
$newresource->summary = $result;
|
||||
update_record('resource',$newresource);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_resource_alltext($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$resource = get_record('resource','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($resource->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($resource->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($resource->alltext, $fromenc);
|
||||
|
||||
$newresource = new object;
|
||||
$newresource->id = $recordid;
|
||||
$newresource->alltext = $result;
|
||||
update_record('resource',$newresource);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
31
mod/resource/db/migrate2utf8.xml
Executable file
31
mod/resource/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,31 @@
|
|||
<DBMIGRATION type="mod/resource" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="resource">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_resource_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="type" method="NO_CONV" type="varchar" length="30" />
|
||||
<FIELD name="reference" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_resource_reference(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="summary" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_resource_summary(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="alltext" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_resource_alltext(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="popup" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="options" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
707
mod/scorm/db/migrate2utf8.php
Executable file
707
mod/scorm/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,707 @@
|
|||
<?
|
||||
function migrate2utf_scorm_scoes_manifest($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->manifest, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->manifest = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_organization($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->organization, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->organization = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_parent($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->parent, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->parent = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function migrate2utf_scorm_scoes_identifier($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->identifier, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->identifier = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_launch($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->launch, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->launch = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_parameters($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->parameters, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->parameters = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_scormtype($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->scormtype, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->scormtype = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_title($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->title, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->title = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_prerequisites($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->prerequisites, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->prerequisites = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_maxtimeallowed($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->maxtimeallowed, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->maxtimeallowed = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_timelimitaction($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->timelimitaction, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->timelimitaction = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_datafromlms($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->datafromlms, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->datafromlms = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_scoes_masteryscore($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes ss
|
||||
WHERE s.id = ss.scorm
|
||||
AND ss.id = $recordid";
|
||||
|
||||
if (!$scorm = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scormscoes = get_record('scorm_scoes','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scormscoes->masteryscore, $fromenc);
|
||||
|
||||
$newscormscoes = new object;
|
||||
$newscormscoes->id = $recordid;
|
||||
$newscormscoes->masteryscore = $result;
|
||||
update_record('scorm_scoes',$newscormscoes);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function migrate2utf_scorm_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scorm = get_record('scorm','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scorm->name, $fromenc);
|
||||
|
||||
$newscorm = new object;
|
||||
$newscorm->id = $recordid;
|
||||
$newscorm->name = $result;
|
||||
update_record('scorm',$newscorm);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_reference($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scorm = get_record('scorm','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scorm->reference, $fromenc);
|
||||
|
||||
$newscorm = new object;
|
||||
$newscorm->id = $recordid;
|
||||
$newscorm->reference = $result;
|
||||
update_record('scorm',$newscorm);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_summary($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scorm = get_record('scorm','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scorm->summary, $fromenc);
|
||||
|
||||
$newscorm = new object;
|
||||
$newscorm->id = $recordid;
|
||||
$newscorm->summary = $result;
|
||||
update_record('scorm',$newscorm);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_scorm_options($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$scorm = get_record('scorm','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($scorm->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($scorm->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($scorm->options, $fromenc);
|
||||
|
||||
$newscorm = new object;
|
||||
$newscorm->id = $recordid;
|
||||
$newscorm->options = $result;
|
||||
update_record('scorm',$newscorm);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
131
mod/scorm/db/migrate2utf8.xml
Executable file
131
mod/scorm/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,131 @@
|
|||
<DBMIGRATION type="mod/scorm" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="scorm_scoes_track">
|
||||
<FIELDS>
|
||||
<FIELD name="element" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT sst.userid
|
||||
FROM {$CFG->prefix}scorm_scoes_track sst
|
||||
WHERE ge.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes_track sst
|
||||
WHERE s.id = sst.scormid
|
||||
AND sst.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="value" method="PLAIN_SQL_UPDATE" type="longtext" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT sst.userid
|
||||
FROM {$CFG->prefix}scorm_scoes_track sst
|
||||
WHERE ge.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT s.course
|
||||
FROM {$CFG->prefix}scorm s,
|
||||
{$CFG->prefix}scorm_scoes_track sst
|
||||
WHERE s.id = sst.scormid
|
||||
AND sst.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="attachment" method="NO_CONV" type="varchar" length="100" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="scorm_scoes">
|
||||
<FIELDS>
|
||||
<FIELD name="manifest" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_manifest(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="organization" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_organization(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="parent" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_parent(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="identifier" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_identifier(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="launch" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_launch(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="parameters" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_parameters(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="scormtype" method="PHP_FUNCTION" type="varchar" length="5">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_scormtype(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="title" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_title(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="prerequisites" method="PHP_FUNCTION" type="varchar" length="200">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_prerequisites(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="maxtimeallowed" method="PHP_FUNCTION" type="varchar" length="19">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_maxtimeallowed(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="timelimitaction" method="PHP_FUNCTION" type="varchar" length="19">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_timelimitaction(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="datafromlms" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_datafromlms(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="masteryscore" method="PHP_FUNCTION" type="varchar" length="200">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_scoes_masteryscore(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="scorm">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="reference" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_reference(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="version" method="NO_CONV" type="varchar" length="9" />
|
||||
<FIELD name="summary" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_summary(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="options" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_scorm_options(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
68
mod/survey/db/migrate2utf8.php
Executable file
68
mod/survey/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,68 @@
|
|||
<?
|
||||
|
||||
function migrate2utf8_survey_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$survey = get_record('survey','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($survey->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($survey->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($survey->name, $fromenc);
|
||||
|
||||
$newsurvey = new object;
|
||||
$newsurvey->id = $recordid;
|
||||
$newsurvey->name = $result;
|
||||
update_record('survey',$newsurvey);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_survey_intro($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$survey = get_record('survey','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($survey->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($survey->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($survey->intro, $fromenc);
|
||||
|
||||
$newsurvey = new object;
|
||||
$newsurvey->id = $recordid;
|
||||
$newsurvey->intro = $result;
|
||||
update_record('survey',$newsurvey);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
75
mod/survey/db/migrate2utf8.xml
Executable file
75
mod/survey/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,75 @@
|
|||
<DBMIGRATION type="mod/survey" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="survey_questions">
|
||||
<FIELDS>
|
||||
<FIELD name="options" method="NO_CONV" type="text" length="0" />
|
||||
<FIELD name="shorttext" method="NO_CONV" type="varchar" length="30" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="survey_analysis">
|
||||
<FIELDS>
|
||||
<FIELD name="notes" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT sa.userid
|
||||
FROM {$CFG->prefix}survey_analysis sa
|
||||
WHERE sa.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT s.course
|
||||
FROM {$CFG->prefix}survey s,
|
||||
{$CFG->prefix}survey_analysis sa
|
||||
WHERE s.id = sa.survey
|
||||
AND sa.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="survey_answers">
|
||||
<FIELDS>
|
||||
<FIELD name="answerone" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT sa.userid
|
||||
FROM {$CFG->prefix}survey_answers sa
|
||||
WHERE sa.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT s.course
|
||||
FROM {$CFG->prefix}survey s,
|
||||
{$CFG->prefix}survey_answers sa
|
||||
WHERE s.id = sa.survey
|
||||
AND sa.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="answertwo" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT sa.userid
|
||||
FROM {$CFG->prefix}survey_answers sa
|
||||
WHERE sa.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT s.course
|
||||
FROM {$CFG->prefix}survey s,
|
||||
{$CFG->prefix}survey_answers sa
|
||||
WHERE s.id = sa.survey
|
||||
AND sa.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="survey">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_survey_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="intro" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_survey_intro(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="questions" method="NO_CONV" type="varchar" length="255" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
133
mod/wiki/db/migrate2utf8.php
Executable file
133
mod/wiki/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,133 @@
|
|||
<?
|
||||
function migrate2utf8_wiki_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$wiki = get_record('wiki','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($wiki->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($wiki->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($wiki->name, $fromenc);
|
||||
|
||||
$newwiki = new object;
|
||||
$newwiki->id = $recordid;
|
||||
$newwiki->name = $result;
|
||||
update_record('wiki',$newwiki);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_wiki_summary($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$wiki = get_record('wiki','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($wiki->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($wiki->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($wiki->summary, $fromenc);
|
||||
|
||||
$newwiki = new object;
|
||||
$newwiki->id = $recordid;
|
||||
$newwiki->summary = $result;
|
||||
update_record('wiki',$newwiki);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_wiki_pagename($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$wiki = get_record('wiki','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($wiki->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($wiki->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($wiki->pagename, $fromenc);
|
||||
|
||||
$newwiki = new object;
|
||||
$newwiki->id = $recordid;
|
||||
$newwiki->pagename = $result;
|
||||
update_record('wiki',$newwiki);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_wiki_initialcontent($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$wiki = get_record('wiki','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($wiki->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($wiki->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($wiki->initialcontent, $fromenc);
|
||||
|
||||
$newwiki = new object;
|
||||
$newwiki->id = $recordid;
|
||||
$newwiki->initialcontent = $result;
|
||||
update_record('wiki',$newwiki);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
?>
|
108
mod/wiki/db/migrate2utf8.xml
Executable file
108
mod/wiki/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,108 @@
|
|||
<DBMIGRATION type="mod/wiki" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="wiki_entries">
|
||||
<FIELDS>
|
||||
<FIELD name="pagename" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT we.userid
|
||||
FROM {$CFG->prefix}wiki_entries we
|
||||
WHERE we.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}wiki w,
|
||||
{$CFG->prefix}wiki_entries we
|
||||
WHERE w.id = we.wikiid
|
||||
AND we.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="wiki_pages">
|
||||
<FIELDS>
|
||||
<FIELD name="pagename" method="PLAIN_SQL_UPDATE" type="varchar" length="160">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT wp.userid
|
||||
FROM {$CFG->prefix}wiki_pages wp
|
||||
WHERE wp.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}wiki w,
|
||||
{$CFG->prefix}wiki_pages wp
|
||||
WHERE w.id = wp.wiki
|
||||
AND we.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="content" method="PLAIN_SQL_UPDATE" type="mediumtext" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT wp.userid
|
||||
FROM {$CFG->prefix}wiki_pages wp
|
||||
WHERE wp.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}wiki w,
|
||||
{$CFG->prefix}wiki_pages wp
|
||||
WHERE w.id = wp.wiki
|
||||
AND we.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="author" method="PLAIN_SQL_UPDATE" type="varchar" length="100">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT wp.userid
|
||||
FROM {$CFG->prefix}wiki_pages wp
|
||||
WHERE wp.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}wiki w,
|
||||
{$CFG->prefix}wiki_pages wp
|
||||
WHERE w.id = wp.wiki
|
||||
AND we.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="ref" method="PLAIN_SQL_UPDATE" type="mediumtext" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT wp.userid
|
||||
FROM {$CFG->prefix}wiki_pages wp
|
||||
WHERE wp.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}wiki w,
|
||||
{$CFG->prefix}wiki_pages wp
|
||||
WHERE w.id = wp.wiki
|
||||
AND we.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="meta" method="NO_CONV" type="mediumtext" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="wiki">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_wiki_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="summary" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_wiki_summary(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="pagename" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_wiki_pagename(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="wtype" method="NO_CONV" type="enum('teacher', 'group', 'student')" length="0" />
|
||||
<FIELD name="initialcontent" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_wiki_initialcontent(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
247
mod/workshop/db/migrate2utf8.php
Executable file
247
mod/workshop/db/migrate2utf8.php
Executable file
|
@ -0,0 +1,247 @@
|
|||
<?
|
||||
function migrate2utf_workshop_stockcomments_comments($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_stockcomments ws
|
||||
WHERE w.id = ws.workshopid
|
||||
AND ws.id = $recordid";
|
||||
|
||||
if (!$workshop = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$workshopstockcomments = get_record('workshop_stockcomments','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($workshop->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($workshop->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($workshopstockcomments->comment, $fromenc);
|
||||
|
||||
$newworkshopstockcomments = new object;
|
||||
$newworkshopstockcomments->id = $recordid;
|
||||
$newworkshopstockcomments->comment = $result;
|
||||
update_record('workshop_stockcomments',$newworkshopstockcomments);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_workshop_rubrics_description($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_stockcomments ws
|
||||
WHERE w.id = ws.workshopid
|
||||
AND ws.id = $recordid";
|
||||
|
||||
if (!$workshop = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$workshoprubrics = get_record('workshop_stockcomments','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($workshop->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($workshop->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($workshoprubrics->description, $fromenc);
|
||||
|
||||
$newworkshoprubrics = new object;
|
||||
$newworkshoprubrics->id = $recordid;
|
||||
$newworkshoprubrics->description = $result;
|
||||
update_record('workshop_rubricss',$newworkshoprubrics);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_workshop_grades_feedback($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_grades wg
|
||||
WHERE w.id = wg.workshopid
|
||||
AND wg.id = $recordid";
|
||||
|
||||
if (!$workshop = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$workshopgrades = get_record('workshop_grades','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($workshop->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($workshop->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($workshopgrades->feedback, $fromenc);
|
||||
|
||||
$newworkshopgrades = new object;
|
||||
$newworkshopgrades->id = $recordid;
|
||||
$newworkshopgrades->feedback = $result;
|
||||
update_record('workshop_grades',$newworkshopgrades);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_workshop_elements_description($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$SQL = "SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_elements we
|
||||
WHERE w.id = we.workshopid
|
||||
AND we.id = $recordid";
|
||||
|
||||
if (!$workshop = get_record_sql($SQL) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$workshopelements = get_record('workshop_elements','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($workshop->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($workshop->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($workshopelements->description, $fromenc);
|
||||
|
||||
$newworkshopelements = new object;
|
||||
$newworkshopelements->id = $recordid;
|
||||
$newworkshopelements->description = $result;
|
||||
update_record('workshop_elements',$newworkshopelements);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_workshop_name($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$workshop = get_record('workshop','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($workshop->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($workshop->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($workshop->name, $fromenc);
|
||||
|
||||
$newworkshop = new object;
|
||||
$newworkshop->id = $recordid;
|
||||
$newworkshop->name = $result;
|
||||
update_record('workshop',$newworkshop);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_workshop_description($recordid){
|
||||
global $CFG;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$workshop = get_record('workshop','id',$recordid) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($workshop->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($workshop->course); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
$textlib = textlib_get_instance();
|
||||
/// Convert the text
|
||||
$result = $textlib->convert($workshop->description, $fromenc);
|
||||
|
||||
$newworkshop = new object;
|
||||
$newworkshop->id = $recordid;
|
||||
$newworkshop->description = $result;
|
||||
update_record('workshop',$newworkshop);
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf_workshop_password($recordid){
|
||||
global $CFG;
|
||||
}
|
||||
?>
|
142
mod/workshop/db/migrate2utf8.xml
Executable file
142
mod/workshop/db/migrate2utf8.xml
Executable file
|
@ -0,0 +1,142 @@
|
|||
<DBMIGRATION type="mod/workshop" VERSION="2005120100">
|
||||
<TABLES>
|
||||
<TABLE name="workshop_submissions">
|
||||
<FIELDS>
|
||||
<FIELD name="title" method="PLAIN_SQL_UPDATE" type="varchar" length="100">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ws.userid
|
||||
FROM {$CFG->prefix}workshop_submissions ws
|
||||
WHERE ws.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_submissions ws
|
||||
WHERE w.id = ws.workshopid
|
||||
AND ws.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="description" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ws.userid
|
||||
FROM {$CFG->prefix}workshop_submissions ws
|
||||
WHERE ws.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_submissions ws
|
||||
WHERE w.id = ws.workshopid
|
||||
AND ws.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="workshop_stockcomments">
|
||||
<FIELDS>
|
||||
<FIELD name="comments" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_workshop_stockcomments_comments(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="workshop_rubrics">
|
||||
<FIELDS>
|
||||
<FIELD name="description" method="PHP_FUNCTION" type="text" length="0">
|
||||
<SQL_DETECT_COURSE>
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_workshop_rubrics_description(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="workshop_grades">
|
||||
<FIELDS>
|
||||
<FIELD name="feedback" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_workshop_grades_feedback(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="workshop_elements">
|
||||
<FIELDS>
|
||||
<FIELD name="description" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_workshop_elements_description(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="workshop_comments">
|
||||
<FIELDS>
|
||||
<FIELD name="comments" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT wc.userid
|
||||
FROM {$CFG->prefix}workshop_comments wc
|
||||
WHERE wc.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_comments wc
|
||||
WHERE w.id = wc.workshopid
|
||||
AND wc.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="workshop_assessments">
|
||||
<FIELDS>
|
||||
<FIELD name="generalcomment" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ws.userid
|
||||
FROM {$CFG->prefix}workshop_assessments wa
|
||||
WHERE wa.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_assessments wa
|
||||
WHERE w.id = wa.workshopid
|
||||
AND wa.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
<FIELD name="teachercomment" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT ws.userid
|
||||
FROM {$CFG->prefix}workshop_assessments wa
|
||||
WHERE wa.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}workshop w,
|
||||
{$CFG->prefix}workshop_assessments wa
|
||||
WHERE w.id = wa.workshopid
|
||||
AND wa.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="workshop">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_workshop_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="description" method="PLAIN_SQL_UPDATE" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_workshop_description(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="password" method="PHP_FUNCTION" type="varchar" length="32">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_workshop_password(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
Loading…
Add table
Add a link
Reference in a new issue