2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
15 /* Constances, refer to /include/lib/constants.inc.php */
\r
17 define('WORKSPACE_COURSE', 1); // aka Course Files
\r
18 define('WORKSPACE_PERSONAL', 2); // aka My Files
\r
19 define('WORKSPACE_ASSIGNMENT', 3);
\r
20 define('WORKSPACE_GROUP', 4);
\r
22 define('LINK_CAT_COURSE', 1);
\r
23 define('LINK_CAT_GROUP', 2);
\r
24 define('LINK_CAT_SELF', 3);
\r
27 * This class handles different types of conversions for the ATutor tables.
\r
28 * Table entries based on the course's Primary Language will be converted by convertTableByClass($,$)
\r
29 * Table entries based on the System Defualt Language will be converted by convertTableBySysDefualt()
\r
31 * @author Harris Wong
\r
32 * @precondition MySQL connected, mbstring lib enabled.
\r
33 * @date Dec 12, 2007
\r
35 class ConversionDriver{
\r
37 var $sys_default_lang;
\r
42 * @param table_prefix
\r
44 function ConversionDriver($table_prefix){
\r
45 $this->sys_default_lang = 'iso-8859-1';
\r
46 $this->table_prefix = $table_prefix;
\r
50 * This function runs all the table that uses the system default language
\r
52 function convertTableBySysDefault(){
\r
55 $temp_table = new CourseCategoriesTable($this->table_prefix, 'course_cats', $this->sys_default_lang);
\r
56 if (!$temp_table->convert()){
\r
57 $errors[]= $this->table_prefix.'course_cats was not converted.';
\r
58 $_SESSION['redo_conversion'][$course_title]['CourseCategoriesTable'] = array($this->table_prefix, 'course_cats', $char_set, $course_id);
\r
61 $temp_table = new MembersTable($this->table_prefix, 'members', $this->sys_default_lang);
\r
62 if (!$temp_table->convert()){
\r
63 $errors[]= $this->table_prefix.'members was not converted.';
\r
64 $_SESSION['redo_conversion'][$course_title]['MembersTable'] = array($this->table_prefix, 'members', $char_set, $course_id);
\r
69 * This function runs all the table that uses the system default language
\r
70 * Particular for 1.6.1, since 1.6 didn't convret all table
\r
72 function convertTableBySysDefault_161(){
\r
75 $temp_table = new AdminsTable($this->table_prefix, 'admins', $this->sys_default_lang);
\r
76 if (!$temp_table->convert()){
\r
77 $errors[]= $this->table_prefix.'admins was not converted.';
\r
78 $_SESSION['redo_conversion'][$course_title]['AdminsTable'] = array($this->table_prefix, 'admins', $this->sys_default_lang, $course_id);
\r
81 $temp_table = new AdminLogTable($this->table_prefix, 'admin_log', $this->sys_default_lang);
\r
82 if (!$temp_table->convert()){
\r
83 $errors[]= $this->table_prefix.'admin_log was not converted.';
\r
84 $_SESSION['redo_conversion'][$course_title]['AdminLogTable'] = array($this->table_prefix, 'admin_log', $this->sys_default_lang, $course_id);
\r
87 $temp_table = new AutoEnrollTable($this->table_prefix, 'auto_enroll', $this->sys_default_lang);
\r
88 if (!$temp_table->convert()){
\r
89 $errors[]= $this->table_prefix.'auto_enroll was not converted.';
\r
90 $_SESSION['redo_conversion'][$course_title]['AutoEnrollTable'] = array($this->table_prefix, 'auto_enroll', $this->sys_default_lang, $course_id);
\r
93 $temp_table = new AutoEnrollCoursesTable($this->table_prefix, 'auto_enroll_courses', $this->sys_default_lang);
\r
94 if (!$temp_table->convert()){
\r
95 $errors[]= $this->table_prefix.'auto_enroll_courses was not converted.';
\r
96 $_SESSION['redo_conversion'][$course_title]['AutoEnrollCourses'] = array($this->table_prefix, 'auto_enroll_courses', $this->sys_default_lang, $course_id);
\r
99 $temp_table = new ConfigTable($this->table_prefix, 'config', $this->sys_default_lang);
\r
100 if (!$temp_table->convert()){
\r
101 $errors[]= $this->table_prefix.'config was not converted.';
\r
102 $_SESSION['redo_conversion'][$course_title]['ConfigTable'] = array($this->table_prefix, 'config', $this->sys_default_lang, $course_id);
\r
105 $temp_table = new CourseAccessTable($this->table_prefix, 'course_access', $this->sys_default_lang);
\r
106 if (!$temp_table->convert()){
\r
107 $errors[]= $this->table_prefix.'course_access was not converted.';
\r
108 $_SESSION['redo_conversion'][$course_title]['CourseAccessTable'] = array($this->table_prefix, 'course_access', $this->sys_default_lang, $course_id);
\r
111 $temp_table = new CourseStatsTable($this->table_prefix, 'course_stats', $this->sys_default_lang);
\r
112 if (!$temp_table->convert()){
\r
113 $errors[]= $this->table_prefix.'course_stats was not converted.';
\r
114 $_SESSION['redo_conversion'][$course_title]['CourseStatsTable'] = array($this->table_prefix, 'course_stats', $this->sys_default_lang, $course_id);
\r
117 $temp_table = new FeedsTable($this->table_prefix, 'feeds', $this->sys_default_lang);
\r
118 if (!$temp_table->convert()){
\r
119 $errors[]= $this->table_prefix.'feeds was not converted.';
\r
120 $_SESSION['redo_conversion'][$course_title]['FeedsTable'] = array($this->table_prefix, 'feeds', $this->sys_default_lang, $course_id);
\r
123 $temp_table = new FileStorageGroupsTable($this->table_prefix, 'file_storage_groups', $this->sys_default_lang);
\r
124 if (!$temp_table->convert()){
\r
125 $errors[]= $this->table_prefix.'file_storage_groups was not converted.';
\r
126 $_SESSION['redo_conversion'][$course_title]['FileStorageGroupsTable'] = array($this->table_prefix, 'file_storage_groups', $this->sys_default_lang, $course_id);
\r
129 $temp_table = new ForumsAccessedTable($this->table_prefix, 'forums_accessed', $this->sys_default_lang);
\r
130 if (!$temp_table->convert()){
\r
131 $errors[]= $this->table_prefix.'forums_accessed was not converted.';
\r
132 $_SESSION['redo_conversion'][$course_title]['ForumsAccessedTable'] = array($this->table_prefix, 'forums_accessed', $this->sys_default_lang, $course_id);
\r
135 $temp_table = new ForumsCoursesTable($this->table_prefix, 'forums_courses', $this->sys_default_lang);
\r
136 if (!$temp_table->convert()){
\r
137 $errors[]= $this->table_prefix.'forums_courses was not converted.';
\r
138 $_SESSION['redo_conversion'][$course_title]['ForumsCoursesTable'] = array($this->table_prefix, 'forums_courses', $this->sys_default_lang, $course_id);
\r
141 $temp_table = new ForumsGroupsTable($this->table_prefix, 'forums_groups', $this->sys_default_lang);
\r
142 if (!$temp_table->convert()){
\r
143 $errors[]= $this->table_prefix.'forums_groups was not converted.';
\r
144 $_SESSION['redo_conversion'][$course_title]['ForumsGroupsTable'] = array($this->table_prefix, 'forums_groups', $this->sys_default_lang, $course_id);
\r
147 $temp_table = new ForumsSubscriptionsTable($this->table_prefix, 'forums_subscriptions', $this->sys_default_lang);
\r
148 if (!$temp_table->convert()){
\r
149 $errors[]= $this->table_prefix.'forums_subscriptions was not converted.';
\r
150 $_SESSION['redo_conversion'][$course_title]['ForumsSubscriptionsTable'] = array($this->table_prefix, 'forums_subscriptions', $this->sys_default_lang, $course_id);
\r
153 $temp_table = new GroupsMembersTable($this->table_prefix, 'groups_members', $this->sys_default_lang);
\r
154 if (!$temp_table->convert()){
\r
155 $errors[]= $this->table_prefix.'groups_members was not converted.';
\r
156 $_SESSION['redo_conversion'][$course_title]['GroupsMembersTable'] = array($this->table_prefix, 'groups_members', $this->sys_default_lang, $course_id);
\r
159 $temp_table = new HandbookNotesTable($this->table_prefix, 'handbook_notes', $this->sys_default_lang);
\r
160 if (!$temp_table->convert()){
\r
161 $errors[]= $this->table_prefix.'handbook_notes was not converted.';
\r
162 $_SESSION['redo_conversion'][$course_title]['HandbookNotesTable'] = array($this->table_prefix, 'handbook_notes', $this->sys_default_lang, $course_id);
\r
165 $temp_table = new InstructorApprovalsTable($this->table_prefix, 'instructor_approvals', $this->sys_default_lang);
\r
166 if (!$temp_table->convert()){
\r
167 $errors[]= $this->table_prefix.'instructor_approvals was not converted.';
\r
168 $_SESSION['redo_conversion'][$course_title]['InstructorApprovalsTable'] = array($this->table_prefix, 'instructor_approvals', $this->sys_default_lang, $course_id);
\r
171 $temp_table = new LanguagesTable($this->table_prefix, 'languages', $this->sys_default_lang);
\r
172 if (!$temp_table->convert()){
\r
173 $errors[]= $this->table_prefix.'languages was not converted.';
\r
174 $_SESSION['redo_conversion'][$course_title]['LanguagesTable'] = array($this->table_prefix, 'languages', $this->sys_default_lang, $course_id);
\r
177 $temp_table = new LanguagePagesTable($this->table_prefix, 'language_pages', $this->sys_default_lang);
\r
178 if (!$temp_table->convert()){
\r
179 $errors[]= $this->table_prefix.'language_pages was not converted.';
\r
180 $_SESSION['redo_conversion'][$course_title]['LanguagePagesTable'] = array($this->table_prefix, 'language_pages', $this->sys_default_lang, $course_id);
\r
183 $temp_table = new LanguageTextTable($this->table_prefix, 'language_text', $this->sys_default_lang);
\r
184 if (!$temp_table->convert()){
\r
185 $errors[]= $this->table_prefix.'language_text was not converted.';
\r
186 $_SESSION['redo_conversion'][$course_title]['LanguageTextTable'] = array($this->table_prefix, 'language_text', $this->sys_default_lang, $course_id);
\r
189 $temp_table = new MailQueueTable($this->table_prefix, 'mail_queue', $this->sys_default_lang);
\r
190 if (!$temp_table->convert()){
\r
191 $errors[]= $this->table_prefix.'mail_queue was not converted.';
\r
192 $_SESSION['redo_conversion'][$course_title]['MailQueueTable'] = array($this->table_prefix, 'mail_queue', $this->sys_default_lang, $course_id);
\r
195 $temp_table = new MasterListTable($this->table_prefix, 'master_list', $this->sys_default_lang);
\r
196 if (!$temp_table->convert()){
\r
197 $errors[]= $this->table_prefix.'master_list was not converted.';
\r
198 $_SESSION['redo_conversion'][$course_title]['MasterListTable'] = array($this->table_prefix, 'master_list', $this->sys_default_lang, $course_id);
\r
201 $temp_table = new MemberTrackTable($this->table_prefix, 'member_track', $this->sys_default_lang);
\r
202 if (!$temp_table->convert()){
\r
203 $errors[]= $this->table_prefix.'member_track was not converted.';
\r
204 $_SESSION['redo_conversion'][$course_title]['MemberTrackTable'] = array($this->table_prefix, 'member_track', $this->sys_default_lang, $course_id);
\r
207 $temp_table = new ModulesTable($this->table_prefix, 'modules', $this->sys_default_lang);
\r
208 if (!$temp_table->convert()){
\r
209 $errors[]= $this->table_prefix.'modules was not converted.';
\r
210 $_SESSION['redo_conversion'][$course_title]['ModulesTable'] = array($this->table_prefix, 'modules', $this->sys_default_lang, $course_id);
\r
213 $temp_table = new PollsMembersTable($this->table_prefix, 'polls_members', $this->sys_default_lang);
\r
214 if (!$temp_table->convert()){
\r
215 $errors[]= $this->table_prefix.'polls_members was not converted.';
\r
216 $_SESSION['redo_conversion'][$course_title]['PollsMembersTable'] = array($this->table_prefix, 'polls_members', $this->sys_default_lang, $course_id);
\r
219 $temp_table = new RelatedContentTable($this->table_prefix, 'related_content', $this->sys_default_lang);
\r
220 if (!$temp_table->convert()){
\r
221 $errors[]= $this->table_prefix.'related_content was not converted.';
\r
222 $_SESSION['redo_conversion'][$course_title]['RelatedContentTable'] = array($this->table_prefix, 'related_content', $this->sys_default_lang, $course_id);
\r
225 $temp_table = new TestsGroupsTable($this->table_prefix, 'tests_groups', $this->sys_default_lang);
\r
226 if (!$temp_table->convert()){
\r
227 $errors[]= $this->table_prefix.'tests_groups was not converted.';
\r
228 $_SESSION['redo_conversion'][$course_title]['TestsGroupsTable'] = array($this->table_prefix, 'tests_groups', $this->sys_default_lang, $course_id);
\r
231 $temp_table = new TestsQuestionsAssocTable($this->table_prefix, 'tests_questions_assoc', $this->sys_default_lang);
\r
232 if (!$temp_table->convert()){
\r
233 $errors[]= $this->table_prefix.'tests_questions_assoc was not converted.';
\r
234 $_SESSION['redo_conversion'][$course_title]['TestsQuestionsAssocTable'] = array($this->table_prefix, 'tests_questions_assoc', $this->sys_default_lang, $course_id);
\r
237 $temp_table = new TestsResultsTable($this->table_prefix, 'tests_results', $this->sys_default_lang);
\r
238 if (!$temp_table->convert()){
\r
239 $errors[]= $this->table_prefix.'tests_results was not converted.';
\r
240 $_SESSION['redo_conversion'][$course_title]['TestsResultsTable'] = array($this->table_prefix, 'tests_results', $this->sys_default_lang, $course_id);
\r
243 $temp_table = new ThemesTable($this->table_prefix, 'themes', $this->sys_default_lang);
\r
244 if (!$temp_table->convert()){
\r
245 $errors[]= $this->table_prefix.'themes was not converted.';
\r
246 $_SESSION['redo_conversion'][$course_title]['ThemesTable'] = array($this->table_prefix, 'themes', $this->sys_default_lang, $course_id);
\r
249 $temp_table = new UsersOnlineTable($this->table_prefix, 'users_online', $this->sys_default_lang);
\r
250 if (!$temp_table->convert()){
\r
251 $errors[]= $this->table_prefix.'users_online was not converted.';
\r
252 $_SESSION['redo_conversion'][$course_title]['UsersOnlineTable'] = array($this->table_prefix, 'users_online', $this->sys_default_lang, $course_id);
\r
257 * This function runs through all the table that are class dependent.
\r
259 function convertTableByClass($course_title, $char_set, $course_id){
\r
261 //Run through all ATutor table and convert only those rows with the above courses.
\r
262 //todo: implement a driver class inside the TableConversion class.
\r
263 $temp_table = new AssignmentsTable($this->table_prefix, 'assignments', $char_set, $course_id);
\r
264 if (!$temp_table->convert()){
\r
265 $errors[]= $course_title.': '.$this->table_prefix.'assignments was not converted.';
\r
266 $_SESSION['redo_conversion'][$course_title]['AssignmentsTable'] = array($this->table_prefix, 'assignments', $char_set, $course_id);
\r
269 $temp_table = new BackupsTable($this->table_prefix, 'backups', $char_set, $course_id);
\r
270 if (!$temp_table->convert()){
\r
271 $errors[]= $course_title.': '.$this->table_prefix.'backups was not converted.';
\r
272 $_SESSION['redo_conversion'][$course_title]['BackupsTable'] = array($this->table_prefix, 'backups', $char_set, $course_id);
\r
275 $temp_table = new BlogPostsTable($this->table_prefix, 'blog_posts', $char_set, $course_id);
\r
276 if (!$temp_table->convert()){
\r
277 $errors[]= $course_title.': '.$this->table_prefix.'blog_posts was not converted.';
\r
278 $_SESSION['redo_conversion'][$course_title]['BlogPostsTable'] = array($this->table_prefix, 'blog_posts', $char_set, $course_id);
\r
281 $temp_table = new ContentTable($this->table_prefix, 'content', $char_set, $course_id);
\r
282 if (!$temp_table->convert()){
\r
283 $errors[]= $course_title.': '.$this->table_prefix.'content was not converted.';
\r
284 $_SESSION['redo_conversion'][$course_title]['ContentTable'] = array($this->table_prefix, 'content', $char_set, $course_id);
\r
287 $temp_table = new CoursesTable($this->table_prefix, 'courses', $char_set, $course_id);
\r
288 if (!$temp_table->convert()){
\r
289 $errors[]= $course_title.': '.$this->table_prefix.'courses was not converted.';
\r
290 $_SESSION['redo_conversion'][$course_title]['CoursesTable'] = array($this->table_prefix, 'courses', $char_set, $course_id);
\r
293 $temp_table = new CourseEnrollmentTable($this->table_prefix, 'course_enrollment', $char_set, $course_id);
\r
294 if (!$temp_table->convert()){
\r
295 $errors[]= $course_title.': '.$this->table_prefix.'course_enrollment was not converted.';
\r
296 $_SESSION['redo_conversion'][$course_title]['CourseEnrollmentTable'] = array($this->table_prefix, 'course_enrollment', $char_set, $course_id);
\r
299 $temp_table = new ExternalResourcesTable($this->table_prefix, 'external_resources', $char_set, $course_id);
\r
300 if (!$temp_table->convert()){
\r
301 $errors[]= $course_title.': '.$this->table_prefix.'external_resources was not converted.';
\r
302 $_SESSION['redo_conversion'][$course_title]['ExternalResourcesTable'] = array($this->table_prefix, 'external_resources', $char_set, $course_id);
\r
305 $temp_table = new FaqTopicsTable($this->table_prefix, 'faq_topics', $char_set, $course_id);
\r
306 if (!$temp_table->convert()){
\r
307 $errors[]= $course_title.': '.$this->table_prefix.'faq_topics was not converted.';
\r
308 $_SESSION['redo_conversion'][$course_title]['FaqTopicsTable'] = array($this->table_prefix, 'faq_topics', $char_set, $course_id);
\r
311 $temp_table = new FoldersTable($this->table_prefix, 'folders', $char_set, $course_id);
\r
312 if (!$temp_table->convert()){
\r
313 $errors[]= $course_title.': '.$this->table_prefix.'folders was not converted.';
\r
314 $_SESSION['redo_conversion'][$course_title]['FoldersTable'] = array($this->table_prefix, 'folders', $char_set, $course_id);
\r
317 $temp_table = new FilesTable($this->table_prefix, 'files', $char_set, $course_id);
\r
318 if (!$temp_table->convert()){
\r
319 $errors[]= $course_title.': '.$this->table_prefix.'files was not converted.';
\r
320 $_SESSION['redo_conversion'][$course_title]['FilesTable'] = array($this->table_prefix, 'files', $char_set, $course_id);
\r
323 $temp_table = new ForumsTable($this->table_prefix, 'forums', $char_set, $course_id);
\r
324 if (!$temp_table->convert()){
\r
325 $errors[]= $course_title.': '.$this->table_prefix.'forums was not converted.';
\r
326 $_SESSION['redo_conversion'][$course_title]['ForumsTable'] = array($this->table_prefix, 'forums', $char_set, $course_id);
\r
329 $temp_table = new GlossaryTable($this->table_prefix, 'glossary', $char_set, $course_id);
\r
330 if (!$temp_table->convert()){
\r
331 $errors[]= $course_title.': '.$this->table_prefix.'glossary was not converted.';
\r
332 $_SESSION['redo_conversion'][$course_title]['GlossaryTable'] = array($this->table_prefix, 'glossary', $char_set, $course_id);
\r
335 $temp_table = new GroupsTypesTable($this->table_prefix, 'groups_types', $char_set, $course_id);
\r
336 if (!$temp_table->convert()){
\r
337 $errors[]= $course_title.': '.$this->table_prefix.'groups_types was not converted.';
\r
338 $_SESSION['redo_conversion'][$course_title]['GroupsTypesTable'] = array($this->table_prefix, 'groups_types', $char_set, $course_id);
\r
341 $temp_table = new LinksCategoriesTable($this->table_prefix, 'links_categories', $char_set, $course_id);
\r
342 if (!$temp_table->convert()){
\r
343 $errors[]= $course_title.': '.$this->table_prefix.'links_categories was not converted.';
\r
344 $_SESSION['redo_conversion'][$course_title]['LinksCategoriesTable'] = array($this->table_prefix, 'links_categories', $char_set, $course_id);
\r
347 $temp_table = new MessagesTable($this->table_prefix, 'messages', $char_set, $course_id);
\r
348 if (!$temp_table->convert()){
\r
349 $errors[]= $course_title.': '.$this->table_prefix.'messages was not converted.';
\r
350 $_SESSION['redo_conversion'][$course_title]['MessagesTable'] = array($this->table_prefix, 'messages', $char_set, $course_id);
\r
353 $temp_table = new MessagesSentTable($this->table_prefix, 'messages_sent', $char_set, $course_id);
\r
354 if (!$temp_table->convert()){
\r
355 $errors[]= $course_title.': '.$this->table_prefix.'messages_sent was not converted.';
\r
356 $_SESSION['redo_conversion'][$course_title]['MessagesSentTable'] = array($this->table_prefix, 'messages_sent', $char_set, $course_id);
\r
359 $temp_table = new NewsTable($this->table_prefix, 'news', $char_set, $course_id);
\r
360 if (!$temp_table->convert()){
\r
361 $errors[]= $course_title.': '.$this->table_prefix.'news was not converted.';
\r
362 $_SESSION['redo_conversion'][$course_title]['NewsTable'] = array($this->table_prefix, 'news', $char_set, $course_id);
\r
365 $temp_table = new PollsTable($this->table_prefix, 'polls', $char_set, $course_id);
\r
366 if (!$temp_table->convert()){
\r
367 $errors[]= $course_title.': '.$this->table_prefix.'polls was not converted.';
\r
368 $_SESSION['redo_conversion'][$course_title]['PollsTable'] = array($this->table_prefix, 'polls', $char_set, $course_id);
\r
371 $temp_table = new ReadingListTable($this->table_prefix, 'reading_list', $char_set, $course_id);
\r
372 if (!$temp_table->convert()){
\r
373 $errors[]= $course_title.': '.$this->table_prefix.'reading_list was not converted.';
\r
374 $_SESSION['redo_conversion'][$course_title]['ReadingListTable'] = array($this->table_prefix, 'reading_list', $char_set, $course_id);
\r
377 $temp_table = new TestsTable($this->table_prefix, 'tests', $char_set, $course_id);
\r
378 if (!$temp_table->convert()){
\r
379 $errors[]= $course_title.': '.$this->table_prefix.'tests was not converted.';
\r
380 $_SESSION['redo_conversion'][$course_title]['TestsTable'] = array($this->table_prefix, 'tests', $char_set, $course_id);
\r
383 $temp_table = new TestQuestionsTable($this->table_prefix, 'tests_questions', $char_set, $course_id);
\r
384 if (!$temp_table->convert()){
\r
385 $errors[]= $course_title.': '.$this->table_prefix.'tests_questions was not converted.';
\r
386 $_SESSION['redo_conversion'][$course_title]['TestQuestionsTable'] = array($this->table_prefix, 'tests_questions', $char_set, $course_id);
\r
389 $temp_table = new TestsQuestionsCategoriesTable($this->table_prefix, 'tests_questions_categories', $char_set, $course_id);
\r
390 if (!$temp_table->convert()){
\r
391 $errors[]= $course_title.': '.$this->table_prefix.'tests_questions_categories was not converted.';
\r
392 $_SESSION['redo_conversion'][$course_title]['TestsQuestionsCategoriesTable'] = array($this->table_prefix, 'tests_questions_categories', $char_set, $course_id);
\r
397 * This function runs through all the table that are class dependent.
\r
398 * Particular for the tables that haven't been converted during 1.5.5 to 1.6
\r
400 function convertTableByClass_161($course_title, $char_set, $course_id){
\r
402 //Run through all ATutor table and convert only those rows with the above courses.
\r
403 //todo: implement a driver class inside the TableConversion class.
\r
404 /* $temp_table = new MessagesTable($this->table_prefix, 'messages', $char_set, $course_id);
\r
405 if (!$temp_table->convert()){
\r
406 $errors[]= $course_title.': '.$this->table_prefix.'messages was not converted.';
\r
407 $_SESSION['redo_conversion'][$course_title]['MessagesTable'] = array($this->table_prefix, 'messages', $char_set, $course_id);
\r
413 * This function will alter all table's charset to UTF-8
\r
415 function alter_all_charset(){
\r
417 $sql = 'SHOW TABLES';
\r
418 $result = mysql_query($sql);
\r
419 if (mysql_numrows($result) > 0) {
\r
420 while ($row = mysql_fetch_array($result)){
\r
421 $sql = 'ALTER TABLE `'.$row[0].'` CONVERT TO CHARACTER SET utf8';
\r
430 * This class will handle utf8 conversion on all tables associated with a specific course.
\r
431 * This class can be potentially upgraded to a automated table parser to optimize codes, instead of having
\r
432 * different abstract classes for each individual table inside ATutor.
\r
433 * Note: Keeping in mind that this class will not be used a lot after 1.6 conversion.
\r
435 * @author Harris Wong
\r
436 * @precondition MySQL connected, mbstring lib enabled.
\r
437 * @date Nov 28, 2007
\r
443 var $from_encoding;
\r
449 * @param table prefix
\r
450 * @param table is the table name of which we want to covert
\r
451 * @param from_encoding is the encoding which the content will be converted from.
\r
452 * @param foreign_ID is the primary key/foreign key of the table. $foreign_ID will be the primary key when
\r
453 * the table has a "course_id" column, foreign key when it doesn't.
\r
454 * foreign_ID is an empty string if this table does not depend on courses, such as members,
\r
455 * course categories tables.
\r
457 function ATutorTable($table_prefix, $table, $from_encoding, $foreign_ID=''){
\r
458 $this->table_prefix = $table_prefix;
\r
459 $this->table = $table;
\r
460 $this->from_encoding = $from_encoding;
\r
461 $this->foreign_ID= $foreign_ID;
\r
462 $this->to_encoding = "UTF-8";
\r
463 //check if mb_string library is enabled, die o/w
\r
464 if (!extension_loaded('mbstring')){
\r
465 die("Please have mbstring library enabled");
\r
469 $this->alterTable();
\r
475 * Perform mysql ALTER table function, to switch to UTF-8 tables.
\r
477 function alterTable(){
\r
478 $query = 'ALTER TABLE `'.$this->table_prefix.$this->table.'` CONVERT TO CHARACTER SET utf8';
\r
479 mysql_query($query);
\r
485 * This method will get all the contents from this table with the given courseID.
\r
486 * @param courseDependent = false when this table isn't related to course encoding, true if it is related (default)
\r
487 * @return result set, and null on failure or 0 rows
\r
489 function getContent($courseDependent = true){
\r
490 if ($courseDependent) {
\r
491 $sql = "SELECT * FROM `".$this->table_prefix.$this->table."` WHERE course_id=".$this->foreign_ID;
\r
493 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table;
\r
495 $result = mysql_query($sql);
\r
496 if ($result && mysql_num_rows($result)>0){
\r
504 * Abstract class that convert the table contents to UTF8
\r
505 * @return mysql_query's return object
\r
507 function convert(){/* Abstract */}
\r
512 * This runs the sql statement
\r
513 * @param value_array contains all the new values mapped by their column names
\r
514 * @param primary_key is the primary key of this table.
\r
516 function generate_sql($value_array, $primary_key_col, $primary_key){
\r
517 $sql = "UPDATE `".$this->table_prefix.$this->table."` SET ";
\r
519 foreach($value_array as $column_name=>$column_value){
\r
520 $column_value = mysql_real_escape_string($column_value);
\r
521 $column_name = mysql_real_escape_string($column_name);
\r
522 $sql .= "`$column_name`='$column_value'";
\r
523 if ($i < sizeof($value_array)) {
\r
528 //If there are more than 1 key
\r
529 if (is_array($primary_key_col)){
\r
532 foreach ($primary_key_col as $k=>$v){
\r
533 $v = mysql_real_escape_string($v);
\r
534 $sql .= $v.'='.$primary_key[$k];
\r
535 if ($j < sizeof($primary_key_col)){
\r
541 $sql .= " WHERE `$primary_key_col`=";
\r
542 if (preg_match('/^[0-9]+$/', $primary_key)==1){
\r
543 $sql .= $primary_key;
\r
545 //prim key is a string, put it around a pair of quotes
\r
546 $sql .= "'$primary_key'";
\r
557 * Default language iso-8859-1.
\r
558 * Note: This class is independent from courses
\r
560 class AdminsTable extends ATutorTable{
\r
561 function convert(){
\r
562 $rs = $this->getContent(false);
\r
564 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
565 //Store the key for updating purposes.
\r
566 $key_col = 'login';
\r
567 //Convert all neccessary entries
\r
568 $value_array['real_name'] = mb_convert_encoding($row['real_name'], $this->to_encoding, $this->from_encoding);
\r
570 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
571 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
572 echo mysql_error();
\r
579 * Class for AdminLog
\r
580 * Default language iso-8859-1.
\r
581 * Note: This class is independent from courses
\r
583 class AdminLogTable extends ATutorTable{
\r
584 function convert(){
\r
585 $rs = $this->getContent(false);
\r
587 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
588 //Store the key for updating purposes.
\r
590 //Convert all neccessary entries
\r
591 $value_array['operation'] = mb_convert_encoding($row['operation'], $this->to_encoding, $this->from_encoding);
\r
592 $value_array['table'] = mb_convert_encoding($row['table'], $this->to_encoding, $this->from_encoding);
\r
593 $value_array['details'] = mb_convert_encoding($row['details'], $this->to_encoding, $this->from_encoding);
\r
595 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
596 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
603 * Class for Assignments
\r
605 class AssignmentsTable extends ATutorTable{
\r
606 function convert(){
\r
607 $rs = $this->getContent();
\r
609 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
610 //Store the key for updating purposes.
\r
611 $key_col = 'assignment_id';
\r
612 //Convert all neccessary entries
\r
613 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
615 //Convert Folders table, that is related to assignments.
\r
616 $folders = new FoldersTable($this->table_prefix, 'folders', $this->from_encoding, $row[$key_col]);
\r
617 $result &= $folders->convert(WORKSPACE_ASSIGNMENT);
\r
618 //Convert Files table, that is related to assignments.
\r
619 $files_table = new FilesTable($this->table_prefix, 'files', $this->from_encoding, $row[$key_col]);
\r
620 $result &= $files_table->convert(WORKSPACE_ASSIGNMENT);
\r
623 //echo (mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]))) ;
\r
624 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
626 //Needs to alter related tables
\r
628 new FoldersTable($this->table_prefix, 'folders', '');
\r
629 new FilesTable($this->table_prefix, 'files', '');
\r
636 * Class for auto_enroll
\r
637 * Default language iso-8859-1.
\r
638 * Note: This class is independent from courses
\r
640 class AutoEnrollTable extends ATutorTable{
\r
641 function convert(){
\r
642 $rs = $this->getContent(false);
\r
644 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
645 //Store the key for updating purposes.
\r
646 $key_col = 'auto_enroll_id';
\r
647 //Convert all neccessary entries
\r
648 $value_array['associate_string'] = mb_convert_encoding($row['associate_string'], $this->to_encoding, $this->from_encoding);
\r
649 $value_array['name'] = mb_convert_encoding($row['name'], $this->to_encoding, $this->from_encoding);
\r
652 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
653 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
660 * Class for auto_enroll_courses
\r
661 * Default language iso-8859-1.
\r
662 * Note: This class is independent from courses
\r
664 class AutoEnrollCoursesTable extends ATutorTable{
\r
665 //Nothing to convert in this table except the table structure.
\r
666 function convert(){
\r
673 * Class for Backups
\r
675 class BackupsTable extends ATutorTable{
\r
676 function convert(){
\r
677 $rs = $this->getContent();
\r
679 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
680 //Store the key for updating purposes.
\r
681 $key_col = 'backup_id';
\r
682 //Convert all neccessary entries
\r
683 $value_array['date'] = $row['date'];
\r
684 $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);
\r
685 $value_array['system_file_name'] = mb_convert_encoding($row['system_file_name'], $this->to_encoding, $this->from_encoding);
\r
686 $value_array['file_name'] = mb_convert_encoding($row['file_name'], $this->to_encoding, $this->from_encoding);
\r
687 $value_array['contents'] = mb_convert_encoding($row['contents'], $this->to_encoding, $this->from_encoding);
\r
689 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
690 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
697 * Class for Blog posts
\r
699 class BlogPostsTable extends ATutorTable{
\r
700 function convert(){
\r
701 $rs = $this->getContent();
\r
703 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
704 //Store the key for updating purposes.
\r
705 $key_col = 'post_id';
\r
706 //Convert all neccessary entries
\r
707 $value_array['date'] = $row['date'];
\r
708 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
709 $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);
\r
710 //Convert sub post comment.
\r
711 $commentPosts = new BlogPostsCommentsTable($this->table_prefix, 'blog_posts_comments', $this->from_encoding, $row[$key_col]);
\r
712 $result &= $commentPosts->convert();
\r
714 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
715 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
717 //Needs to alter related tables
\r
719 new BlogPostsCommentsTable($this->table_prefix, 'blog_posts_comments', '');
\r
726 * Class for Blog posts comments
\r
727 * Used only by BlogPostsTable
\r
728 * Foreign key = post_id
\r
730 class BlogPostsCommentsTable extends ATutorTable{
\r
732 function getContent(){
\r
733 $sql = "SELECT * FROM `".$this->table_prefix.$this->table."` WHERE post_id=".$this->foreign_ID;
\r
734 $result = mysql_query($sql);
\r
735 if ($result && mysql_num_rows($result)>0){
\r
741 function convert(){
\r
742 $rs = $this->getContent();
\r
744 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
745 //Store the key for updating purposes.
\r
746 $key_col = 'comment_id';
\r
747 //Convert all neccessary entries
\r
748 $value_array['date'] = $row['date'];
\r
749 $value_array['text'] = mb_convert_encoding($row['text'], $this->to_encoding, $this->from_encoding);
\r
751 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
752 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
760 * Default language iso-8859-1.
\r
761 * Note: This class is independent from courses
\r
763 class ConfigTable extends ATutorTable{
\r
764 function convert(){
\r
765 //nothing to convert
\r
771 * Class for course_access
\r
772 * Default language iso-8859-1.
\r
773 * Note: This class is independent from courses
\r
775 class CourseAccessTable extends ATutorTable{
\r
776 function convert(){
\r
777 //nothing to convert
\r
783 * Class for course_stats
\r
784 * Default language iso-8859-1.
\r
785 * Note: This class is independent from courses
\r
787 class CourseStatsTable extends ATutorTable{
\r
788 function convert(){
\r
789 //nothing to convert
\r
795 * Class for Content
\r
797 class ContentTable extends ATutorTable{
\r
798 function convert(){
\r
799 $rs = $this->getContent();
\r
801 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
802 //Store the key for updating purposes.
\r
803 $key_col = 'content_id';
\r
804 //Convert all neccessary entries
\r
805 $value_array['last_modified'] = $row['last_modified'];
\r
806 $value_array['keywords'] = mb_convert_encoding($row['keywords'], $this->to_encoding, $this->from_encoding);
\r
807 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
808 $value_array['text'] = mb_convert_encoding($row['text'], $this->to_encoding, $this->from_encoding);
\r
810 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
811 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
819 * Class for Courses
\r
821 class CoursesTable extends ATutorTable{
\r
822 function convert(){
\r
823 $rs = $this->getContent();
\r
825 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
826 //Store the key for updating purposes.
\r
827 $key_col = 'course_id';
\r
828 //Convert all neccessary entries
\r
829 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
830 $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);
\r
831 // $value_array['preferences'] = mb_convert_encoding($row['preferences'], $this->to_encoding, $this->from_encoding);
\r
832 $value_array['copyright'] = mb_convert_encoding($row['copyright'], $this->to_encoding, $this->from_encoding);
\r
833 $value_array['banner'] = mb_convert_encoding($row['banner'], $this->to_encoding, $this->from_encoding);
\r
834 /* The following should not needed to be converted after they are deprecated */
\r
835 // $value_array['header'] = mb_convert_encoding($row['header'], $this->to_encoding, $this->from_encoding);
\r
836 // $value_array['footer'] = mb_convert_encoding($row['footer'], $this->to_encoding, $this->from_encoding);
\r
837 // $value_array['banner_text'] = mb_convert_encoding($row['banner_text'], $this->to_encoding, $this->from_encoding);
\r
838 // $value_array['banner_styles'] = mb_convert_encoding($row['banner_styles'], $this->to_encoding, $this->from_encoding);
\r
841 // echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
842 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
850 * Class for Courses enrollment
\r
852 class CourseEnrollmentTable extends ATutorTable{
\r
853 function convert(){
\r
854 $rs = $this->getContent();
\r
856 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
857 //Store the key for updating purposes.
\r
858 $key_col = 'course_id';
\r
859 $key_col2 = 'member_id';
\r
860 //Convert all neccessary entries
\r
861 $value_array['role'] = mb_convert_encoding($row['role'], $this->to_encoding, $this->from_encoding);
\r
863 //echo $this->generate_sql($value_array, array($key_col, $key_col2), array($row[$key_col], $row[$key_col2]));
\r
864 $result &= mysql_query($this->generate_sql($value_array, array($key_col, $key_col2), array($row[$key_col], $row[$key_col2])));
\r
872 * Class for Course Categories
\r
873 * Course Categories are created by admins, the language encoding should be based on
\r
874 * the admin's language setting for >= 1.5.1
\r
875 * Otherwise, default it to iso-8859-1.
\r
876 * Note: This class is independent from courses
\r
878 class CourseCategoriesTable extends ATutorTable{
\r
879 function convert(){
\r
880 $rs = $this->getContent(false);
\r
882 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
883 //Store the key for updating purposes.
\r
884 $key_col = 'cat_id';
\r
885 //Convert all neccessary entries
\r
886 $value_array['cat_name'] = mb_convert_encoding($row['cat_name'], $this->to_encoding, $this->from_encoding);
\r
888 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
889 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
897 * Class for External resources
\r
899 class ExternalResourcesTable extends ATutorTable{
\r
900 function convert(){
\r
901 $rs = $this->getContent();
\r
903 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
904 //Store the key for updating purposes.
\r
905 $key_col = 'resource_id';
\r
906 //Convert all neccessary entries
\r
907 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
908 $value_array['author'] = mb_convert_encoding($row['author'], $this->to_encoding, $this->from_encoding);
\r
909 $value_array['publisher'] = mb_convert_encoding($row['publisher'], $this->to_encoding, $this->from_encoding);
\r
910 $value_array['comments'] = mb_convert_encoding($row['comments'], $this->to_encoding, $this->from_encoding);
\r
912 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
913 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
921 * Class for Faq topics
\r
923 class FaqTopicsTable extends ATutorTable{
\r
924 function convert(){
\r
925 $rs = $this->getContent();
\r
927 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
928 //Store the key for updating purposes.
\r
929 $key_col = 'topic_id';
\r
930 //Convert all neccessary entries
\r
931 $value_array['name'] = mb_convert_encoding($row['name'], $this->to_encoding, $this->from_encoding);
\r
932 //Convert faq entries
\r
933 $faqEntries = new FaqEntriesTable($this->table_prefix, 'faq_entries', $this->from_encoding, $row[$key_col]);
\r
934 $faqEntries->convert();
\r
936 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
937 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
939 //Needs to alter related tables
\r
941 new FaqEntriesTable($this->table_prefix, 'faq_entries', '');
\r
948 * Class for Faq Entries
\r
949 * Used only by FaqTopicsTable
\r
950 * Foreign key = topic_id
\r
952 class FaqEntriesTable extends ATutorTable{
\r
954 function getContent(){
\r
955 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE topic_id='.$this->foreign_ID;
\r
956 $result = mysql_query($sql);
\r
957 if ($result && mysql_num_rows($result)>0){
\r
963 function convert(){
\r
964 $rs = $this->getContent();
\r
966 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
967 //Store the key for updating purposes.
\r
968 $key_col = 'entry_id';
\r
969 //Convert all neccessary entries
\r
970 $value_array['revised_date'] = $row['revised_date'];
\r
971 $value_array['question'] = mb_convert_encoding($row['question'], $this->to_encoding, $this->from_encoding);
\r
972 $value_array['answer'] = mb_convert_encoding($row['answer'], $this->to_encoding, $this->from_encoding);
\r
974 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
975 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
984 * Default language iso-8859-1.
\r
985 * Note: This class is independent from courses
\r
987 class FeedsTable extends ATutorTable{
\r
988 function convert(){
\r
989 $rs = $this->getContent(false);
\r
991 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
992 //Store the key for updating purposes.
\r
993 $key_col = 'feed_id';
\r
994 //Convert all neccessary entries
\r
995 $value_array['url'] = mb_convert_encoding($row['url'], $this->to_encoding, $this->from_encoding);
\r
998 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
999 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1006 * Class for Forums
\r
1008 class ForumsTable extends ATutorTable{
\r
1010 function getContent(){
\r
1011 $sql = 'SELECT this_forum.* FROM `'.$this->table_prefix.$this->table.'` this_forum NATURAL JOIN `'.$this->table_prefix.'forums_courses` this_course WHERE this_course.course_id='.$this->foreign_ID;
\r
1012 $result = mysql_query($sql);
\r
1013 if ($result && mysql_num_rows($result)>0){
\r
1019 function convert(){
\r
1020 $rs = $this->getContent();
\r
1022 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1023 //Store the key for updating purposes.
\r
1024 $key_col = 'forum_id';
\r
1025 //Convert all neccessary entries
\r
1026 $value_array['last_post'] = $row['last_post'];
\r
1027 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
1028 $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);
\r
1029 //Convert faq entries
\r
1030 $forumThread= new ForumsThreadsTable($this->table_prefix, 'forums_threads', $this->from_encoding, $row[$key_col]);
\r
1031 $result &= $forumThread->convert();
\r
1033 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1034 $result = mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1036 //Needs to alter related tables
\r
1038 new ForumsThreadsTable($this->table_prefix, 'forums_threads', '');
\r
1045 * Class for forums_accessed
\r
1046 * Default language iso-8859-1.
\r
1047 * Note: This class is independent from courses
\r
1049 class ForumsAccessedTable extends ATutorTable{
\r
1050 function convert(){
\r
1051 //nothing to convert
\r
1057 * Class for forums_courses
\r
1058 * Default language iso-8859-1.
\r
1059 * Note: This class is independent from courses
\r
1061 class ForumsCoursesTable extends ATutorTable{
\r
1062 function convert(){
\r
1063 //nothing to convert
\r
1069 * Class for forums_groups
\r
1070 * Default language iso-8859-1.
\r
1071 * Note: This class is independent from courses
\r
1073 class ForumsGroupsTable extends ATutorTable{
\r
1074 function convert(){
\r
1075 //nothing to convert
\r
1081 * Class for forums_subscriptions
\r
1082 * Default language iso-8859-1.
\r
1083 * Note: This class is independent from courses
\r
1085 class ForumsSubscriptionsTable extends ATutorTable{
\r
1086 function convert(){
\r
1087 //nothing to convert
\r
1093 * Class for Forums threads
\r
1094 * Used only by ForumsTable
\r
1095 * Foreign key = forum_id
\r
1097 class ForumsThreadsTable extends ATutorTable{
\r
1099 function getContent(){
\r
1100 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE forum_id='.$this->foreign_ID;
\r
1101 $result = mysql_query($sql);
\r
1102 if ($result && mysql_num_rows($result)>0){
\r
1108 function convert(){
\r
1109 $rs = $this->getContent();
\r
1111 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1112 //Store the key for updating purposes.
\r
1113 $key_col = 'post_id';
\r
1114 //Convert all neccessary entries
\r
1115 $value_array['last_comment'] = $row['last_comment'];
\r
1116 $value_array['subject'] = mb_convert_encoding($row['subject'], $this->to_encoding, $this->from_encoding);
\r
1117 $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);
\r
1119 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1120 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1128 * Class for Folders
\r
1129 * Associated with Groups, Links
\r
1131 class FoldersTable extends ATutorTable{
\r
1134 * owner_id means category_id, owner_type refers to the different link type defined in the constants.inc.php.
\r
1135 * @param $owner_type are defined by the constances, which are course, groups, self
\r
1137 function getContent($owner_type){
\r
1138 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE owner_type='.$owner_type.' AND owner_id='.$this->foreign_ID;
\r
1139 $result = mysql_query($sql);
\r
1140 if ($result && mysql_num_rows($result)>0){
\r
1147 * @param $owner_type are defined by the constances, which are course, groups, self; defaulted to be WORKSPACE_COURSE
\r
1149 function convert($owner_type=WORKSPACE_COURSE){
\r
1150 $rs = $this->getContent($owner_type);
\r
1152 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1153 //Store the key for updating purposes.
\r
1154 $key_col = 'folder_id';
\r
1155 //Convert all neccessary entries
\r
1156 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
1158 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1159 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1167 * Associated with Groups, Links
\r
1169 class FilesTable extends ATutorTable{
\r
1172 * owner_id means category_id, owner_type refers to the different link type defined in the constants.inc.php.
\r
1173 * @param $owner_type are defined by the constances, which are course, groups, self
\r
1175 function getContent($owner_type){
\r
1176 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE owner_type='.$owner_type.' AND owner_id='.$this->foreign_ID;
\r
1177 $result = mysql_query($sql);
\r
1178 if ($result && mysql_num_rows($result)>0){
\r
1185 * @param $owner_type are defined by the constances, which are course, groups, self; defaulted to be WORKSPACE_COURSE
\r
1187 function convert($owner_type=WORKSPACE_COURSE){
\r
1188 $rs = $this->getContent($owner_type);
\r
1190 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1191 //Store the key for updating purposes.
\r
1192 $key_col = 'file_id';
\r
1193 //Convert all neccessary entries
\r
1194 $value_array['date'] = $row['date'];
\r
1195 $value_array['file_name'] = mb_convert_encoding($row['file_name'], $this->to_encoding, $this->from_encoding);
\r
1196 $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);
\r
1197 //Convert faq entries
\r
1198 $filesComments= new FilesCommentsTable($this->table_prefix, 'files_comments', $this->from_encoding, $row[$key_col]);
\r
1199 $result &= $filesComments->convert();
\r
1201 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1202 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1204 //Needs to alter related tables
\r
1206 new FilesCommentsTable($this->table_prefix, 'files_comments', '');
\r
1214 * Class for Files comments
\r
1215 * Used only by FilesTable
\r
1216 * Foreign key = file_id
\r
1218 class FilesCommentsTable extends ATutorTable{
\r
1220 function getContent(){
\r
1221 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE file_id='.$this->foreign_ID;
\r
1222 $result = mysql_query($sql);
\r
1223 if ($result && mysql_num_rows($result)>0){
\r
1229 function convert(){
\r
1230 $rs = $this->getContent();
\r
1232 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1233 //Store the key for updating purposes.
\r
1234 $key_col = 'comment_id';
\r
1235 //Convert all neccessary entries
\r
1236 $value_array['date'] = $row['date'];
\r
1237 $value_array['comment'] = mb_convert_encoding($row['comment'], $this->to_encoding, $this->from_encoding);
\r
1239 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1240 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1247 * Class for file_storage_groups
\r
1248 * Default language iso-8859-1.
\r
1249 * Note: This class is independent from courses
\r
1251 class FileStorageGroupsTable extends ATutorTable{
\r
1252 function convert(){
\r
1253 //nothing to convert
\r
1259 * Class for Glossary
\r
1261 class GlossaryTable extends ATutorTable{
\r
1262 function convert(){
\r
1263 $rs = $this->getContent();
\r
1265 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1266 //Store the key for updating purposes.
\r
1267 $key_col = 'word_id';
\r
1268 //Convert all neccessary entries
\r
1269 $value_array['word'] = mb_convert_encoding($row['word'], $this->to_encoding, $this->from_encoding);
\r
1270 $value_array['definition'] = mb_convert_encoding($row['definition'], $this->to_encoding, $this->from_encoding);
\r
1272 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1273 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1281 * Class for Group types
\r
1283 class GroupsTypesTable extends ATutorTable{
\r
1284 function convert(){
\r
1285 $rs = $this->getContent();
\r
1287 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1288 //Store the key for updating purposes.
\r
1289 $key_col = 'type_id';
\r
1290 //Convert all neccessary entries
\r
1291 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
1293 //Convert group table
\r
1294 $groups = new GroupsTable($this->table_prefix, 'groups', $this->from_encoding, $row[$key_col]);
\r
1295 $result &= $groups->convert();
\r
1296 //Convert links table, that has owner_type=group
\r
1297 $linkscats = new LinksCategoriesTable($this->table_prefix, 'links_categories', $this->from_encoding, $row[$key_col]);
\r
1298 $result &= $linkscats->convert(LINK_CAT_GROUP);
\r
1299 //Convert folder tables, that has owner_type=group
\r
1300 $folders = new FoldersTable($this->table_prefix, 'folders', $this->from_encoding, $row[$key_col]);
\r
1301 $result &= $folders->convert(WORKSPACE_GROUP);
\r
1302 //Convert file tables, that has owner_type=group
\r
1303 $files_table = new FilesTable($this->table_prefix, 'files', $this->from_encoding, $row[$key_col]);
\r
1304 $result &= $files_table->convert(WORKSPACE_GROUP);
\r
1307 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1308 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1310 //Needs to alter related tables
\r
1312 new GroupsTable($this->table_prefix, 'groups', '');
\r
1313 new LinksCategoriesTable($this->table_prefix, 'links_categories', '');
\r
1314 new FoldersTable($this->table_prefix, 'folders', '');
\r
1315 new FilesTable($this->table_prefix, 'files', '');
\r
1322 * Class for Groups
\r
1323 * Used only by GroupTypesTable
\r
1324 * Foreign key = type_id
\r
1326 class GroupsTable extends ATutorTable{
\r
1328 function getContent(){
\r
1329 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE type_id='.$this->foreign_ID;
\r
1330 $result = mysql_query($sql);
\r
1331 if ($result && mysql_num_rows($result)>0){
\r
1337 function convert(){
\r
1338 $rs = $this->getContent();
\r
1340 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1341 //Store the key for updating purposes.
\r
1342 $key_col = 'group_id';
\r
1343 //Convert all neccessary entries
\r
1344 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
1345 $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);
\r
1347 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1348 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1355 * Class for groups_members
\r
1356 * Default language iso-8859-1.
\r
1357 * Note: This class is independent from courses
\r
1359 class GroupsMembersTable extends ATutorTable{
\r
1360 function convert(){
\r
1361 //nothing to convert
\r
1367 * Class for handbooks_notes
\r
1368 * Default language iso-8859-1.
\r
1369 * Note: This class is independent from courses
\r
1371 class HandbookNotesTable extends ATutorTable{
\r
1372 function convert(){
\r
1373 $rs = $this->getContent(false);
\r
1375 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1376 //Store the key for updating purposes.
\r
1377 $key_col = 'note_id';
\r
1378 //Convert all neccessary entries
\r
1379 $value_array['section'] = mb_convert_encoding($row['section'], $this->to_encoding, $this->from_encoding);
\r
1380 $value_array['page'] = mb_convert_encoding($row['page'], $this->to_encoding, $this->from_encoding);
\r
1381 $value_array['note'] = mb_convert_encoding($row['note'], $this->to_encoding, $this->from_encoding);
\r
1383 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1384 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1391 * Class for instructor_approvals
\r
1392 * Default language iso-8859-1.
\r
1393 * Note: This class is independent from courses
\r
1395 class InstructorApprovalsTable extends ATutorTable{
\r
1396 function convert(){
\r
1397 $rs = $this->getContent(false);
\r
1399 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1400 //Store the key for updating purposes.
\r
1401 $key_col = 'member_id';
\r
1402 //Convert all neccessary entries
\r
1403 $value_array['notes'] = mb_convert_encoding($row['notes'], $this->to_encoding, $this->from_encoding);
\r
1405 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1406 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1413 * Class for lanaguages
\r
1414 * Default language iso-8859-1.
\r
1415 * Note: This class is independent from courses
\r
1417 class LanguagesTable extends ATutorTable{
\r
1418 function convert(){
\r
1419 //will only have english language remains.
\r
1425 * Class for lanaguage_pages
\r
1426 * Default language iso-8859-1.
\r
1427 * Note: This class is independent from courses
\r
1429 class LanguagePagesTable extends ATutorTable{
\r
1430 function convert(){
\r
1431 //will only have iso88591, which is in ascii
\r
1437 * Class for language_text
\r
1438 * Default language iso-8859-1.
\r
1439 * Note: This class is independent from courses
\r
1441 class LanguageTextTable extends ATutorTable{
\r
1442 function convert(){
\r
1443 //will only have iso88591, which is in ascii
\r
1449 * Class for Links Categories
\r
1450 * Links' owner_id can be of courses, groups, self.
\r
1452 class LinksCategoriesTable extends ATutorTable{
\r
1455 * owner_id means category_id, owner_type refers to the different link type defined in the constants.inc.php.
\r
1456 * @param $owner_type are defined by the constances
\r
1458 function getContent($owner_type){
\r
1459 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE owner_type='.$owner_type.' AND owner_id='.$this->foreign_ID;
\r
1460 $result = mysql_query($sql);
\r
1461 if ($result && mysql_num_rows($result)>0){
\r
1468 * @param $owner_type are defined by the constances, which are course, groups, self; defaulted to be LINK_CAT_COURSE
\r
1470 function convert($owner_type=LINK_CAT_COURSE){
\r
1471 $rs = $this->getContent($owner_type);
\r
1473 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1474 //Store the key for updating purposes.
\r
1475 $key_col = 'cat_id';
\r
1476 //Convert all neccessary entries
\r
1477 $value_array['name'] = mb_convert_encoding($row['name'], $this->to_encoding, $this->from_encoding);
\r
1478 //Convert links table
\r
1479 $linkscats = new LinksTable($this->table_prefix, 'links', $this->from_encoding, $row[$key_col]);
\r
1480 $result &= $linkscats->convert();
\r
1482 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1483 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1485 //Needs to alter related tables
\r
1487 new LinksTable($this->table_prefix, 'links', '');
\r
1495 * Used only by LinksCategoriesTable
\r
1496 * Foreign key = cat_id
\r
1498 class LinksTable extends ATutorTable{
\r
1500 function getContent(){
\r
1501 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE cat_id='.$this->foreign_ID;
\r
1502 $result = mysql_query($sql);
\r
1503 if ($result && mysql_num_rows($result)>0){
\r
1509 function convert(){
\r
1510 $rs = $this->getContent();
\r
1512 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1513 //Store the key for updating purposes.
\r
1514 $key_col = 'link_id';
\r
1515 //Convert all neccessary entries
\r
1516 $value_array['LinkName'] = mb_convert_encoding($row['LinkName'], $this->to_encoding, $this->from_encoding);
\r
1517 $value_array['Description'] = mb_convert_encoding($row['Description'], $this->to_encoding, $this->from_encoding);
\r
1518 $value_array['SubmitName'] = mb_convert_encoding($row['SubmitName'], $this->to_encoding, $this->from_encoding);
\r
1520 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1521 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1528 * Class for mail_queue
\r
1529 * Default language iso-8859-1.
\r
1530 * Note: This class is independent from courses
\r
1532 class MailQueueTable extends ATutorTable{
\r
1533 function convert(){
\r
1534 $rs = $this->getContent(false);
\r
1536 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1537 //Store the key for updating purposes.
\r
1538 $key_col = 'mail_id';
\r
1539 //Convert all neccessary entries
\r
1540 $value_array['to_name'] = mb_convert_encoding($row['to_name'], $this->to_encoding, $this->from_encoding);
\r
1541 $value_array['from_name'] = mb_convert_encoding($row['from_name'], $this->to_encoding, $this->from_encoding);
\r
1542 $value_array['subject'] = mb_convert_encoding($row['subject'], $this->to_encoding, $this->from_encoding);
\r
1543 $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);
\r
1545 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1546 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1553 * Class for master_list
\r
1554 * Default language iso-8859-1.
\r
1555 * Note: This class is independent from courses
\r
1557 class MasterListTable extends ATutorTable{
\r
1558 function convert(){
\r
1559 //nothong to convert
\r
1565 * Class for Members
\r
1566 * Note: This class is independent from courses
\r
1568 class MembersTable extends ATutorTable{
\r
1569 function convert(){
\r
1570 $rs = $this->getContent(false);
\r
1572 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1573 //Store the key for updating purposes.
\r
1574 $key_col = 'member_id';
\r
1575 //Convert all neccessary entries
\r
1576 $value_array['first_name'] = mb_convert_encoding($row['first_name'], $this->to_encoding, $this->from_encoding);
\r
1577 $value_array['second_name'] = mb_convert_encoding($row['second_name'], $this->to_encoding, $this->from_encoding);
\r
1578 $value_array['last_name'] = mb_convert_encoding($row['last_name'], $this->to_encoding, $this->from_encoding);
\r
1579 $value_array['address'] = mb_convert_encoding($row['address'], $this->to_encoding, $this->from_encoding);
\r
1580 $value_array['city'] = mb_convert_encoding($row['city'], $this->to_encoding, $this->from_encoding);
\r
1581 $value_array['province'] = mb_convert_encoding($row['province'], $this->to_encoding, $this->from_encoding);
\r
1582 $value_array['creation_date'] = $row['creation_date'];
\r
1584 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1585 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1592 * Class for member_track
\r
1593 * Default language iso-8859-1.
\r
1594 * Note: This class is independent from courses
\r
1596 class MemberTrackTable extends ATutorTable{
\r
1597 function convert(){
\r
1598 //nothong to convert
\r
1604 * Class for Messages
\r
1606 class MessagesTable extends ATutorTable{
\r
1607 function convert(){
\r
1608 $rs = $this->getContent();
\r
1610 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1611 //Store the key for updating purposes.
\r
1612 $key_col = 'message_id';
\r
1613 //Convert all neccessary entries
\r
1614 $value_array['date_sent'] = $row['date_sent'];
\r
1615 $value_array['subject'] = mb_convert_encoding($row['subject'], $this->to_encoding, $this->from_encoding);
\r
1616 $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);
\r
1618 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1619 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1627 * Class for Messages Sent
\r
1629 class MessagesSentTable extends ATutorTable{
\r
1630 function convert(){
\r
1631 $rs = $this->getContent();
\r
1633 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1634 //Store the key for updating purposes.
\r
1635 $key_col = 'message_id';
\r
1636 //Convert all neccessary entries
\r
1637 $value_array['date_sent'] = $row['date_sent'];
\r
1638 $value_array['subject'] = mb_convert_encoding($row['subject'], $this->to_encoding, $this->from_encoding);
\r
1639 $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);
\r
1641 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1642 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1650 * Class for modules
\r
1651 * Default language iso-8859-1.
\r
1652 * Note: This class is independent from courses
\r
1654 class ModulesTable extends ATutorTable{
\r
1655 function convert(){
\r
1656 //nothong to convert
\r
1665 class NewsTable extends ATutorTable{
\r
1666 function convert(){
\r
1667 $rs = $this->getContent();
\r
1669 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1670 //Store the key for updating purposes.
\r
1671 $key_col = 'news_id';
\r
1672 //Convert all neccessary entries
\r
1673 $value_array['date'] = $row['date'];
\r
1674 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
1675 $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);
\r
1677 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1678 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1688 class PollsTable extends ATutorTable{
\r
1689 function convert(){
\r
1690 $rs = $this->getContent();
\r
1692 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1693 //Store the key for updating purposes.
\r
1694 $key_col = 'poll_id';
\r
1695 //Convert all neccessary entries
\r
1696 $value_array['created_date'] = $row['created_date'];
\r
1697 $value_array['question'] = mb_convert_encoding($row['question'], $this->to_encoding, $this->from_encoding);
\r
1698 $value_array['choice1'] = mb_convert_encoding($row['choice1'], $this->to_encoding, $this->from_encoding);
\r
1699 $value_array['choice2'] = mb_convert_encoding($row['choice2'], $this->to_encoding, $this->from_encoding);
\r
1700 $value_array['choice3'] = mb_convert_encoding($row['choice3'], $this->to_encoding, $this->from_encoding);
\r
1701 $value_array['choice4'] = mb_convert_encoding($row['choice4'], $this->to_encoding, $this->from_encoding);
\r
1702 $value_array['choice5'] = mb_convert_encoding($row['choice5'], $this->to_encoding, $this->from_encoding);
\r
1703 $value_array['choice6'] = mb_convert_encoding($row['choice6'], $this->to_encoding, $this->from_encoding);
\r
1704 $value_array['choice7'] = mb_convert_encoding($row['choice7'], $this->to_encoding, $this->from_encoding);
\r
1706 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1707 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1714 * Class for PollsMembers
\r
1715 * Default language iso-8859-1.
\r
1716 * Note: This class is independent from courses
\r
1718 class PollsMembersTable extends ATutorTable{
\r
1719 function convert(){
\r
1720 //nothong to convert
\r
1726 * Class for RelatedContent
\r
1727 * Default language iso-8859-1.
\r
1728 * Note: This class is independent from courses
\r
1730 class RelatedContentTable extends ATutorTable{
\r
1731 function convert(){
\r
1732 //nothong to convert
\r
1738 * Class for Readlig list
\r
1740 class ReadingListTable extends ATutorTable{
\r
1741 function convert(){
\r
1742 $rs = $this->getContent();
\r
1744 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1745 //Store the key for updating purposes.
\r
1746 $key_col = 'reading_id';
\r
1747 //Convert all neccessary entries
\r
1748 $value_array['comment'] = mb_convert_encoding($row['comment'], $this->to_encoding, $this->from_encoding);
\r
1750 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1751 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1761 class TestsTable extends ATutorTable{
\r
1762 function convert(){
\r
1763 $rs = $this->getContent();
\r
1765 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1766 //Store the key for updating purposes.
\r
1767 $key_col = 'test_id';
\r
1768 //Convert all neccessary entries
\r
1769 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
1770 $value_array['instructions'] = mb_convert_encoding($row['instructions'], $this->to_encoding, $this->from_encoding);
\r
1772 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1773 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1781 * Class for Test questions
\r
1783 class TestQuestionsTable extends ATutorTable{
\r
1784 function convert(){
\r
1785 $rs = $this->getContent();
\r
1787 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1788 //Store the key for updating purposes.
\r
1789 $key_col = 'question_id';
\r
1790 //Convert all neccessary entries
\r
1791 $value_array['question'] = mb_convert_encoding($row['question'], $this->to_encoding, $this->from_encoding);
\r
1792 $value_array['feedback'] = mb_convert_encoding($row['feedback'], $this->to_encoding, $this->from_encoding);
\r
1793 $value_array['question'] = mb_convert_encoding($row['question'], $this->to_encoding, $this->from_encoding);
\r
1794 $value_array['choice_0'] = mb_convert_encoding($row['choice_0'], $this->to_encoding, $this->from_encoding);
\r
1795 $value_array['choice_1'] = mb_convert_encoding($row['choice_1'], $this->to_encoding, $this->from_encoding);
\r
1796 $value_array['choice_2'] = mb_convert_encoding($row['choice_2'], $this->to_encoding, $this->from_encoding);
\r
1797 $value_array['choice_3'] = mb_convert_encoding($row['choice_3'], $this->to_encoding, $this->from_encoding);
\r
1798 $value_array['choice_4'] = mb_convert_encoding($row['choice_4'], $this->to_encoding, $this->from_encoding);
\r
1799 $value_array['choice_5'] = mb_convert_encoding($row['choice_5'], $this->to_encoding, $this->from_encoding);
\r
1800 $value_array['choice_6'] = mb_convert_encoding($row['choice_6'], $this->to_encoding, $this->from_encoding);
\r
1801 $value_array['choice_7'] = mb_convert_encoding($row['choice_7'], $this->to_encoding, $this->from_encoding);
\r
1802 $value_array['choice_8'] = mb_convert_encoding($row['choice_8'], $this->to_encoding, $this->from_encoding);
\r
1803 $value_array['choice_9'] = mb_convert_encoding($row['choice_9'], $this->to_encoding, $this->from_encoding);
\r
1804 $value_array['option_0'] = mb_convert_encoding($row['option_0'], $this->to_encoding, $this->from_encoding);
\r
1805 $value_array['option_1'] = mb_convert_encoding($row['option_1'], $this->to_encoding, $this->from_encoding);
\r
1806 $value_array['option_2'] = mb_convert_encoding($row['option_2'], $this->to_encoding, $this->from_encoding);
\r
1807 $value_array['option_3'] = mb_convert_encoding($row['option_3'], $this->to_encoding, $this->from_encoding);
\r
1808 $value_array['option_4'] = mb_convert_encoding($row['option_4'], $this->to_encoding, $this->from_encoding);
\r
1809 $value_array['option_5'] = mb_convert_encoding($row['option_5'], $this->to_encoding, $this->from_encoding);
\r
1810 $value_array['option_6'] = mb_convert_encoding($row['option_6'], $this->to_encoding, $this->from_encoding);
\r
1811 $value_array['option_7'] = mb_convert_encoding($row['option_7'], $this->to_encoding, $this->from_encoding);
\r
1812 $value_array['option_8'] = mb_convert_encoding($row['option_8'], $this->to_encoding, $this->from_encoding);
\r
1813 $value_array['option_9'] = mb_convert_encoding($row['option_9'], $this->to_encoding, $this->from_encoding);
\r
1815 //Convert links table
\r
1816 $tests_answers = new TestsAnswersTable($this->table_prefix, 'tests_answers', $this->from_encoding, $row[$key_col]);
\r
1817 $result &= $tests_answers->convert();
\r
1820 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1821 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1823 //Needs to alter related tables
\r
1825 new TestsAnswersTable($this->table_prefix, 'tests_answers', '');
\r
1833 * Class for Test answers
\r
1834 * Used only by TestQuestionTable
\r
1835 * Foreign key = question_id, since question is one-to-many answers mapping.
\r
1837 class TestsAnswersTable extends ATutorTable{
\r
1839 function getContent(){
\r
1840 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE question_id='.$this->foreign_ID;
\r
1841 $result = mysql_query($sql);
\r
1842 if ($result && mysql_num_rows($result)>0){
\r
1848 function convert(){
\r
1849 $rs = $this->getContent();
\r
1851 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1852 //Store the key for updating purposes.
\r
1853 $key_col1 = 'question_id';
\r
1854 $key_col2 = 'result_id';
\r
1855 $key_col3 = 'member_id';
\r
1856 //Convert all neccessary entries
\r
1857 $value_array['answer'] = mb_convert_encoding($row['answer'], $this->to_encoding, $this->from_encoding);
\r
1858 $value_array['notes'] = mb_convert_encoding($row['notes'], $this->to_encoding, $this->from_encoding);
\r
1860 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1861 $result &= mysql_query($this->generate_sql($value_array, array($key_col1, $key_col2, $key_col3),
\r
1862 array($row[$key_col1], $row[$key_col2], $row[$key_col3])));
\r
1869 * Class for tests_groups
\r
1870 * Default language iso-8859-1.
\r
1871 * Note: This class is independent from courses
\r
1873 class TestsGroupsTable extends ATutorTable{
\r
1874 function convert(){
\r
1875 //nothong to convert
\r
1881 * Class for tests_questions_assoc
\r
1882 * Default language iso-8859-1.
\r
1883 * Note: This class is independent from courses
\r
1885 class TestsQuestionsAssocTable extends ATutorTable{
\r
1886 function convert(){
\r
1887 $rs = $this->getContent(false);
\r
1889 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1890 //Store the key for updating purposes.
\r
1891 $key_col = 'test_id';
\r
1892 $key_col2 = 'question_id';
\r
1893 //Convert all neccessary entries
\r
1894 $value_array['weight'] = mb_convert_encoding($row['weight'], $this->to_encoding, $this->from_encoding);
\r
1896 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1897 $result &= mysql_query($this->generate_sql($value_array, array($key_col, $key_col2), array($row[$key_col], $row[$key_col2])));
\r
1904 * Class for Tests questions category
\r
1906 class TestsQuestionsCategoriesTable extends ATutorTable{
\r
1907 function convert(){
\r
1908 $rs = $this->getContent();
\r
1910 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1911 //Store the key for updating purposes.
\r
1912 $key_col = 'category_id';
\r
1913 //Convert all neccessary entries
\r
1914 $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);
\r
1916 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1917 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1925 * Class for tests_results
\r
1926 * Default language iso-8859-1.
\r
1927 * Note: This class is independent from courses
\r
1929 class TestsResultsTable extends ATutorTable{
\r
1930 function convert(){
\r
1931 //nothong to convert
\r
1938 * Class for themes
\r
1939 * Default language iso-8859-1.
\r
1940 * Note: This class is independent from courses
\r
1942 class ThemesTable extends ATutorTable{
\r
1943 function convert(){
\r
1944 $rs = $this->getContent(false);
\r
1946 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1947 //Store the key for updating purposes.
\r
1948 $key_col = 'title';
\r
1949 //Convert all neccessary entries
\r
1950 $value_array['extra_info'] = mb_convert_encoding($row['extra_info'], $this->to_encoding, $this->from_encoding);
\r
1952 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1953 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r
1961 * Class for users_online
\r
1962 * Default language iso-8859-1.
\r
1963 * Note: This class is independent from courses
\r
1965 class UsersOnlineTable extends ATutorTable{
\r
1966 function convert(){
\r
1967 $rs = $this->getContent(false);
\r
1969 while ($rs!=false && $row = mysql_fetch_assoc($rs)){
\r
1970 //Store the key for updating purposes.
\r
1971 $key_col = 'member_id';
\r
1972 //Convert all neccessary entries
\r
1973 $value_array['login'] = mb_convert_encoding($row['login'], $this->to_encoding, $this->from_encoding);
\r
1975 //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);
\r
1976 $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));
\r