|
|
|
|
@ -46,8 +46,8 @@ class AddCourse |
|
|
|
|
$try_new_fsc_id = $try_new_fsc_db = $try_new_fsc_dir = 0; |
|
|
|
|
|
|
|
|
|
while (!$keys_are_unique) { |
|
|
|
|
$keys_course_id = $prefix_for_all . $unique_prefix . $wanted_code . $final_suffix['CourseId']; |
|
|
|
|
$keys_course_repository = $prefix_for_path . $unique_prefix . $wanted_code . $final_suffix['CourseDir']; |
|
|
|
|
$keys_course_id = $prefix_for_all.$unique_prefix.$wanted_code.$final_suffix['CourseId']; |
|
|
|
|
$keys_course_repository = $prefix_for_path.$unique_prefix.$wanted_code.$final_suffix['CourseDir']; |
|
|
|
|
$keys_are_unique = true; |
|
|
|
|
|
|
|
|
|
// Check whether they are unique. |
|
|
|
|
@ -58,12 +58,12 @@ class AddCourse |
|
|
|
|
|
|
|
|
|
if (Database::num_rows($result)) { |
|
|
|
|
$keys_are_unique = false; |
|
|
|
|
$try_new_fsc_id ++; |
|
|
|
|
$try_new_fsc_id++; |
|
|
|
|
$final_suffix['CourseId'] = substr(md5(uniqid(rand())), 0, 4); |
|
|
|
|
} |
|
|
|
|
if (file_exists(api_get_path(SYS_COURSE_PATH).$keys_course_repository)) { |
|
|
|
|
$keys_are_unique = false; |
|
|
|
|
$try_new_fsc_dir ++; |
|
|
|
|
$try_new_fsc_dir++; |
|
|
|
|
$final_suffix['CourseDir'] = substr(md5(uniqid(rand())), 0, 4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -91,12 +91,12 @@ class AddCourse |
|
|
|
|
$perm = api_get_permissions_for_new_directories(); |
|
|
|
|
$perm_file = api_get_permissions_for_new_files(); |
|
|
|
|
$htmlpage = "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <title>Not authorized</title>\n </head>\n <body>\n </body>\n</html>"; |
|
|
|
|
$cp = api_get_path(SYS_COURSE_PATH) . $course_repository; |
|
|
|
|
$cp = api_get_path(SYS_COURSE_PATH).$course_repository; |
|
|
|
|
|
|
|
|
|
//Creating document folder |
|
|
|
|
mkdir($cp, $perm); |
|
|
|
|
mkdir($cp . '/document', $perm); |
|
|
|
|
$cpt = $cp . '/document/index.html'; |
|
|
|
|
mkdir($cp.'/document', $perm); |
|
|
|
|
$cpt = $cp.'/document/index.html'; |
|
|
|
|
$fd = fopen($cpt, 'w'); |
|
|
|
|
fwrite($fd, $htmlpage); |
|
|
|
|
fclose($fd); |
|
|
|
|
@ -118,49 +118,49 @@ class AddCourse |
|
|
|
|
@copy($cpt, $cp . '/document/video/index.html'); */ |
|
|
|
|
|
|
|
|
|
//Creatind dropbox folder |
|
|
|
|
mkdir($cp . '/dropbox', $perm); |
|
|
|
|
$cpt = $cp . '/dropbox/index.html'; |
|
|
|
|
mkdir($cp.'/dropbox', $perm); |
|
|
|
|
$cpt = $cp.'/dropbox/index.html'; |
|
|
|
|
$fd = fopen($cpt, 'w'); |
|
|
|
|
fwrite($fd, $htmlpage); |
|
|
|
|
fclose($fd); |
|
|
|
|
@chmod($cpt, $perm_file); |
|
|
|
|
mkdir($cp . '/group', $perm); |
|
|
|
|
@copy($cpt, $cp . '/group/index.html'); |
|
|
|
|
mkdir($cp . '/page', $perm); |
|
|
|
|
@copy($cpt, $cp . '/page/index.html'); |
|
|
|
|
mkdir($cp . '/scorm', $perm); |
|
|
|
|
@copy($cpt, $cp . '/scorm/index.html'); |
|
|
|
|
mkdir($cp . '/upload', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/index.html'); |
|
|
|
|
mkdir($cp . '/upload/forum', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/forum/index.html'); |
|
|
|
|
mkdir($cp . '/upload/forum/images', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/forum/images/index.html'); |
|
|
|
|
mkdir($cp . '/upload/test', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/test/index.html'); |
|
|
|
|
mkdir($cp . '/upload/blog', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/blog/index.html'); |
|
|
|
|
mkdir($cp . '/upload/learning_path', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/learning_path/index.html'); |
|
|
|
|
mkdir($cp . '/upload/learning_path/images', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/learning_path/images/index.html'); |
|
|
|
|
mkdir($cp . '/upload/calendar', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/calendar/index.html'); |
|
|
|
|
mkdir($cp . '/upload/calendar/images', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/calendar/images/index.html'); |
|
|
|
|
mkdir($cp . '/work', $perm); |
|
|
|
|
@copy($cpt, $cp . '/work/index.html'); |
|
|
|
|
mkdir($cp . '/upload/announcements', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/announcements/index.html'); |
|
|
|
|
mkdir($cp . '/upload/announcements/images', $perm); |
|
|
|
|
@copy($cpt, $cp . '/upload/announcements/images/index.html'); |
|
|
|
|
mkdir($cp.'/group', $perm); |
|
|
|
|
@copy($cpt, $cp.'/group/index.html'); |
|
|
|
|
mkdir($cp.'/page', $perm); |
|
|
|
|
@copy($cpt, $cp.'/page/index.html'); |
|
|
|
|
mkdir($cp.'/scorm', $perm); |
|
|
|
|
@copy($cpt, $cp.'/scorm/index.html'); |
|
|
|
|
mkdir($cp.'/upload', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/index.html'); |
|
|
|
|
mkdir($cp.'/upload/forum', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/forum/index.html'); |
|
|
|
|
mkdir($cp.'/upload/forum/images', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/forum/images/index.html'); |
|
|
|
|
mkdir($cp.'/upload/test', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/test/index.html'); |
|
|
|
|
mkdir($cp.'/upload/blog', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/blog/index.html'); |
|
|
|
|
mkdir($cp.'/upload/learning_path', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/learning_path/index.html'); |
|
|
|
|
mkdir($cp.'/upload/learning_path/images', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/learning_path/images/index.html'); |
|
|
|
|
mkdir($cp.'/upload/calendar', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/calendar/index.html'); |
|
|
|
|
mkdir($cp.'/upload/calendar/images', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/calendar/images/index.html'); |
|
|
|
|
mkdir($cp.'/work', $perm); |
|
|
|
|
@copy($cpt, $cp.'/work/index.html'); |
|
|
|
|
mkdir($cp.'/upload/announcements', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/announcements/index.html'); |
|
|
|
|
mkdir($cp.'/upload/announcements/images', $perm); |
|
|
|
|
@copy($cpt, $cp.'/upload/announcements/images/index.html'); |
|
|
|
|
|
|
|
|
|
//Oral expression question type |
|
|
|
|
mkdir($cp . '/exercises', $perm); |
|
|
|
|
@copy($cpt, $cp . '/exercises/index.html'); |
|
|
|
|
mkdir($cp.'/exercises', $perm); |
|
|
|
|
@copy($cpt, $cp.'/exercises/index.html'); |
|
|
|
|
|
|
|
|
|
// Create .htaccess in the dropbox directory. |
|
|
|
|
$fp = fopen($cp . '/dropbox/.htaccess', 'w'); |
|
|
|
|
$fp = fopen($cp.'/dropbox/.htaccess', 'w'); |
|
|
|
|
fwrite( |
|
|
|
|
$fp, |
|
|
|
|
"AuthName AllowLocalAccess |
|
|
|
|
@ -302,7 +302,7 @@ class AddCourse |
|
|
|
|
{ |
|
|
|
|
$list = self::get_course_tables(); |
|
|
|
|
foreach ($list as $table) { |
|
|
|
|
$sql = "DROP TABLE IF EXISTS " . DB_COURSE_PREFIX . $table; |
|
|
|
|
$sql = "DROP TABLE IF EXISTS ".DB_COURSE_PREFIX.$table; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -326,47 +326,47 @@ class AddCourse |
|
|
|
|
if ($media == 'images') { |
|
|
|
|
$code_path = api_get_path( |
|
|
|
|
SYS_CODE_PATH |
|
|
|
|
) . 'default_course_document/images/'; |
|
|
|
|
).'default_course_document/images/'; |
|
|
|
|
} |
|
|
|
|
if ($media == 'audio') { |
|
|
|
|
$code_path = api_get_path( |
|
|
|
|
SYS_CODE_PATH |
|
|
|
|
) . 'default_course_document/audio/'; |
|
|
|
|
).'default_course_document/audio/'; |
|
|
|
|
} |
|
|
|
|
if ($media == 'flash') { |
|
|
|
|
$code_path = api_get_path( |
|
|
|
|
SYS_CODE_PATH |
|
|
|
|
) . 'default_course_document/flash/'; |
|
|
|
|
).'default_course_document/flash/'; |
|
|
|
|
} |
|
|
|
|
if ($media == 'video') { |
|
|
|
|
$code_path = api_get_path( |
|
|
|
|
SYS_CODE_PATH |
|
|
|
|
) . 'default_course_document/video/'; |
|
|
|
|
).'default_course_document/video/'; |
|
|
|
|
} |
|
|
|
|
if ($media == 'certificates') { |
|
|
|
|
$code_path = api_get_path( |
|
|
|
|
SYS_CODE_PATH |
|
|
|
|
) . 'default_course_document/certificates/'; |
|
|
|
|
).'default_course_document/certificates/'; |
|
|
|
|
} |
|
|
|
|
if (is_dir($path)) { |
|
|
|
|
$handle = opendir($path); |
|
|
|
|
while (false !== ($file = readdir($handle))) { |
|
|
|
|
if (is_dir($path . $file) && strpos($file, '.') !== 0) { |
|
|
|
|
if (is_dir($path.$file) && strpos($file, '.') !== 0) { |
|
|
|
|
$files[]['dir'] = str_replace( |
|
|
|
|
$code_path, |
|
|
|
|
'', |
|
|
|
|
$path . $file . '/' |
|
|
|
|
$path.$file.'/' |
|
|
|
|
); |
|
|
|
|
$files = self::browse_folders( |
|
|
|
|
$path . $file . '/', |
|
|
|
|
$path.$file.'/', |
|
|
|
|
$files, |
|
|
|
|
$media |
|
|
|
|
); |
|
|
|
|
} elseif (is_file($path . $file) && strpos($file, '.') !== 0) { |
|
|
|
|
} elseif (is_file($path.$file) && strpos($file, '.') !== 0) { |
|
|
|
|
$files[]['file'] = str_replace( |
|
|
|
|
$code_path, |
|
|
|
|
'', |
|
|
|
|
$path . $file |
|
|
|
|
$path.$file |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -441,117 +441,117 @@ class AddCourse |
|
|
|
|
|
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 1, '" . TOOL_COURSE_DESCRIPTION . "','course_description/','info.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 1, '".TOOL_COURSE_DESCRIPTION."','course_description/','info.gif','".self::string2binary( |
|
|
|
|
api_get_setting( |
|
|
|
|
'course_create_active_tools', |
|
|
|
|
'course_description' |
|
|
|
|
) |
|
|
|
|
) . "','0','squaregrey.gif', 0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif', 0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 2, '" . TOOL_CALENDAR_EVENT . "','calendar/agenda.php','agenda.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 2, '".TOOL_CALENDAR_EVENT."','calendar/agenda.php','agenda.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'agenda') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 3, '" . TOOL_DOCUMENT . "','document/document.php','folder_document.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 3, '".TOOL_DOCUMENT."','document/document.php','folder_document.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'documents') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 4, '" . TOOL_LEARNPATH . "','lp/lp_controller.php','scorms.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 4, '".TOOL_LEARNPATH."','lp/lp_controller.php','scorms.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'learning_path') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 5, '" . TOOL_LINK . "','link/link.php','links.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 5, '".TOOL_LINK."','link/link.php','links.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'links') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 6, '" . TOOL_QUIZ . "','exercise/exercise.php','quiz.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 6, '".TOOL_QUIZ."','exercise/exercise.php','quiz.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'quiz') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 7, '" . TOOL_ANNOUNCEMENT . "','announcements/announcements.php','valves.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 7, '".TOOL_ANNOUNCEMENT."','announcements/announcements.php','valves.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'announcements') |
|
|
|
|
) . "','0','squaregrey.gif', 0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif', 0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 8, '" . TOOL_FORUM . "','forum/index.php','forum.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 8, '".TOOL_FORUM."','forum/index.php','forum.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'forums') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 9, '" . TOOL_DROPBOX . "','dropbox/index.php','dropbox.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 9, '".TOOL_DROPBOX."','dropbox/index.php','dropbox.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'dropbox') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 10, '" . TOOL_USER . "','user/user.php','members.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 10, '".TOOL_USER."','user/user.php','members.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'users') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 11, '" . TOOL_GROUP . "','group/group.php','group.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 11, '".TOOL_GROUP."','group/group.php','group.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'groups') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 12, '" . TOOL_CHAT . "','chat/chat.php','chat.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 12, '".TOOL_CHAT."','chat/chat.php','chat.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'chat') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 13, '" . TOOL_STUDENTPUBLICATION . "','work/work.php','works.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 13, '".TOOL_STUDENTPUBLICATION."','work/work.php','works.gif','".self::string2binary( |
|
|
|
|
api_get_setting( |
|
|
|
|
'course_create_active_tools', |
|
|
|
|
'student_publications' |
|
|
|
|
) |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 14, '" . TOOL_SURVEY . "','survey/survey_list.php','survey.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 14, '".TOOL_SURVEY."','survey/survey_list.php','survey.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'survey') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 15, '" . TOOL_WIKI . "','wiki/index.php','wiki.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 15, '".TOOL_WIKI."','wiki/index.php','wiki.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'wiki') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 16, '" . TOOL_GRADEBOOK . "','gradebook/index.php','gradebook.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 16, '".TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'gradebook') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 17, '" . TOOL_GLOSSARY . "','glossary/index.php','glossary.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 17, '".TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'glossary') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 18, '" . TOOL_NOTEBOOK . "','notebook/index.php','notebook.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 18, '".TOOL_NOTEBOOK."','notebook/index.php','notebook.gif','".self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'notebook') |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','interaction','0')" |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$setting = intval(self::string2binary( |
|
|
|
|
@ -560,45 +560,45 @@ class AddCourse |
|
|
|
|
|
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 19, '" . TOOL_ATTENDANCE . "','attendance/index.php','attendance.gif','" . $setting. "','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
VALUES ($course_id, 19, '".TOOL_ATTENDANCE."','attendance/index.php','attendance.gif','".$setting."','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 20, '" . TOOL_COURSE_PROGRESS . "','course_progress/index.php','course_progress.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 20, '".TOOL_COURSE_PROGRESS."','course_progress/index.php','course_progress.gif','".self::string2binary( |
|
|
|
|
intval(api_get_setting('course_create_active_tools', 'course_progress')) |
|
|
|
|
) . "','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
)."','0','squaregrey.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (api_get_setting('search_enabled') === 'true') { |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 23, '" . TOOL_SEARCH . "','search/','info.gif','" . self::string2binary( |
|
|
|
|
VALUES ($course_id, 23, '".TOOL_SEARCH."','search/','info.gif','".self::string2binary( |
|
|
|
|
api_get_setting( |
|
|
|
|
'course_create_active_tools', |
|
|
|
|
'enable_search' |
|
|
|
|
) |
|
|
|
|
) . "','0','search.gif',0,'_self','authoring','0')" |
|
|
|
|
)."','0','search.gif',0,'_self','authoring','0')" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 24,'" . TOOL_BLOGS . "','blog/blog_admin.php','blog_admin.gif','" . intval(self::string2binary( |
|
|
|
|
VALUES ($course_id, 24,'".TOOL_BLOGS."','blog/blog_admin.php','blog_admin.gif','".intval(self::string2binary( |
|
|
|
|
api_get_setting('course_create_active_tools', 'blogs')) |
|
|
|
|
) . "','1','squaregrey.gif',0,'_self','admin','0')"; |
|
|
|
|
)."','1','squaregrey.gif',0,'_self','admin','0')"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
/* Course homepage tools for course admin only */ |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 25, '" . TOOL_TRACKING . "','tracking/courseLog.php','statistics.gif','$visible_for_course_admin','1','', 0,'_self','admin','0')" |
|
|
|
|
VALUES ($course_id, 25, '".TOOL_TRACKING."','tracking/courseLog.php','statistics.gif','$visible_for_course_admin','1','', 0,'_self','admin','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 26, '" . TOOL_COURSE_SETTING . "','course_info/infocours.php','reference.gif','$visible_for_course_admin','1','', 0,'_self','admin','0')" |
|
|
|
|
VALUES ($course_id, 26, '".TOOL_COURSE_SETTING."','course_info/infocours.php','reference.gif','$visible_for_course_admin','1','', 0,'_self','admin','0')" |
|
|
|
|
); |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id) |
|
|
|
|
VALUES ($course_id, 27, '" . TOOL_COURSE_MAINTENANCE . "','course_info/maintenance.php','backup.gif','$visible_for_course_admin','1','',0,'_self', 'admin','0')" |
|
|
|
|
VALUES ($course_id, 27, '".TOOL_COURSE_MAINTENANCE."','course_info/maintenance.php','backup.gif','$visible_for_course_admin','1','',0,'_self', 'admin','0')" |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$alert = api_get_setting('email_alert_manager_on_new_quiz'); |
|
|
|
|
@ -685,7 +685,7 @@ class AddCourse |
|
|
|
|
$perm = api_get_permissions_for_new_directories(); |
|
|
|
|
$perm_file = api_get_permissions_for_new_files(); |
|
|
|
|
|
|
|
|
|
$chat_path = $sys_course_path . $course_repository . '/document/chat_files'; |
|
|
|
|
$chat_path = $sys_course_path.$course_repository.'/document/chat_files'; |
|
|
|
|
|
|
|
|
|
if (!is_dir($chat_path)) { |
|
|
|
|
@mkdir($chat_path, api_get_permissions_for_new_directories()); |
|
|
|
|
@ -717,11 +717,11 @@ class AddCourse |
|
|
|
|
'certificates', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$default_course_path = api_get_path(SYS_CODE_PATH) . 'default_course_document/'; |
|
|
|
|
$default_course_path = api_get_path(SYS_CODE_PATH).'default_course_document/'; |
|
|
|
|
|
|
|
|
|
$default_document_array = array(); |
|
|
|
|
foreach ($folders_to_copy_from_default_course as $folder) { |
|
|
|
|
$default_course_folder_path = $default_course_path . $folder . '/'; |
|
|
|
|
$default_course_folder_path = $default_course_path.$folder.'/'; |
|
|
|
|
$files = self::browse_folders( |
|
|
|
|
$default_course_folder_path, |
|
|
|
|
array(), |
|
|
|
|
@ -750,30 +750,30 @@ class AddCourse |
|
|
|
|
//hack until feature #5242 is implemented |
|
|
|
|
if ($media_type == 'images') { |
|
|
|
|
$media_type = 'images/gallery'; |
|
|
|
|
$images_folder = $sys_course_path . $course_repository . "/document/images/"; |
|
|
|
|
$images_folder = $sys_course_path.$course_repository."/document/images/"; |
|
|
|
|
|
|
|
|
|
if (!is_dir($images_folder)) { |
|
|
|
|
//Creating index.html |
|
|
|
|
mkdir($images_folder, $perm); |
|
|
|
|
$fd = fopen($images_folder . 'index.html', 'w'); |
|
|
|
|
$fd = fopen($images_folder.'index.html', 'w'); |
|
|
|
|
fwrite($fd, $htmlpage); |
|
|
|
|
@chmod($images_folder . 'index.html', $perm_file); |
|
|
|
|
@chmod($images_folder.'index.html', $perm_file); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$course_documents_folder = $sys_course_path . $course_repository . "/document/$media_type/"; |
|
|
|
|
$default_course_path = api_get_path(SYS_CODE_PATH) . 'default_course_document' . $path_documents; |
|
|
|
|
$course_documents_folder = $sys_course_path.$course_repository."/document/$media_type/"; |
|
|
|
|
$default_course_path = api_get_path(SYS_CODE_PATH).'default_course_document'.$path_documents; |
|
|
|
|
|
|
|
|
|
if (!is_dir($course_documents_folder)) { |
|
|
|
|
// Creating index.html |
|
|
|
|
mkdir($course_documents_folder, $perm); |
|
|
|
|
$fd = fopen( |
|
|
|
|
$course_documents_folder . 'index.html', |
|
|
|
|
$course_documents_folder.'index.html', |
|
|
|
|
'w' |
|
|
|
|
); |
|
|
|
|
fwrite($fd, $htmlpage); |
|
|
|
|
@chmod( |
|
|
|
|
$course_documents_folder . 'index.html', |
|
|
|
|
$course_documents_folder.'index.html', |
|
|
|
|
$perm_file |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
@ -781,15 +781,15 @@ class AddCourse |
|
|
|
|
if (is_array($array_media) && count($array_media) > 0) { |
|
|
|
|
foreach ($array_media as $key => $value) { |
|
|
|
|
if (isset($value['dir']) && !empty($value['dir'])) { |
|
|
|
|
if (!is_dir($course_documents_folder . $value['dir'])) { |
|
|
|
|
if (!is_dir($course_documents_folder.$value['dir'])) { |
|
|
|
|
//Creating folder |
|
|
|
|
mkdir( |
|
|
|
|
$course_documents_folder . $value['dir'], |
|
|
|
|
$course_documents_folder.$value['dir'], |
|
|
|
|
$perm |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
//Creating index.html (for light protection) |
|
|
|
|
$index_html = $course_documents_folder . $value['dir'] . '/index.html'; |
|
|
|
|
$index_html = $course_documents_folder.$value['dir'].'/index.html'; |
|
|
|
|
$fd = fopen($index_html, 'w'); |
|
|
|
|
fwrite($fd, $htmlpage); |
|
|
|
|
@chmod($index_html, $perm_file); |
|
|
|
|
@ -811,12 +811,12 @@ class AddCourse |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($media_type == 'images/gallery') { |
|
|
|
|
$folder_path = 'gallery/' . $folder_path; |
|
|
|
|
$folder_path = 'gallery/'.$folder_path; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) |
|
|
|
|
VALUES ($course_id,'$path_documents" . $folder_path . "','" . $title . "','folder','0')" |
|
|
|
|
VALUES ($course_id,'$path_documents".$folder_path."','".$title."','folder','0')" |
|
|
|
|
); |
|
|
|
|
$image_id = Database:: insert_id(); |
|
|
|
|
|
|
|
|
|
@ -841,33 +841,33 @@ class AddCourse |
|
|
|
|
|
|
|
|
|
if (isset($value['file']) && !empty($value['file'])) { |
|
|
|
|
if (!file_exists( |
|
|
|
|
$course_documents_folder . $value['file'] |
|
|
|
|
$course_documents_folder.$value['file'] |
|
|
|
|
) |
|
|
|
|
) { |
|
|
|
|
//Copying file |
|
|
|
|
copy( |
|
|
|
|
$default_course_path . $value['file'], |
|
|
|
|
$course_documents_folder . $value['file'] |
|
|
|
|
$default_course_path.$value['file'], |
|
|
|
|
$course_documents_folder.$value['file'] |
|
|
|
|
); |
|
|
|
|
chmod( |
|
|
|
|
$course_documents_folder . $value['file'], |
|
|
|
|
$course_documents_folder.$value['file'], |
|
|
|
|
$perm_file |
|
|
|
|
); |
|
|
|
|
//echo $default_course_path.$value['file']; echo ' - '; echo $course_documents_folder.$value['file']; echo '<br />'; |
|
|
|
|
$temp = explode('/', $value['file']); |
|
|
|
|
$file_size = filesize( |
|
|
|
|
$course_documents_folder . $value['file'] |
|
|
|
|
$course_documents_folder.$value['file'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
//hack until feature #5242 is implemented |
|
|
|
|
if ($media_type == 'images/gallery') { |
|
|
|
|
$value["file"] = 'gallery/' . $value["file"]; |
|
|
|
|
$value["file"] = 'gallery/'.$value["file"]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Inserting file in the DB |
|
|
|
|
Database::query( |
|
|
|
|
"INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) |
|
|
|
|
VALUES ($course_id,'$path_documents" . $value["file"] . "','" . $temp[count($temp) - 1] . "','file','$file_size')" |
|
|
|
|
VALUES ($course_id,'$path_documents".$value["file"]."','".$temp[count($temp) - 1]."','file','$file_size')" |
|
|
|
|
); |
|
|
|
|
$image_id = Database:: insert_id(); |
|
|
|
|
if ($image_id) { |
|
|
|
|
@ -875,7 +875,7 @@ class AddCourse |
|
|
|
|
$sql = "UPDATE $TABLETOOLDOCUMENT SET id = iid WHERE iid = $image_id"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
if ($path_documents . $value['file'] == '/certificates/default.html') { |
|
|
|
|
if ($path_documents.$value['file'] == '/certificates/default.html') { |
|
|
|
|
$example_cert_id = $image_id; |
|
|
|
|
} |
|
|
|
|
$docId = Database::insert( |
|
|
|
|
@ -925,7 +925,7 @@ class AddCourse |
|
|
|
|
'c_id' => $course_id, |
|
|
|
|
'url' => 'http://www.google.com', |
|
|
|
|
'title' => 'Google', |
|
|
|
|
'description' => get_lang('Google') , |
|
|
|
|
'description' => get_lang('Google'), |
|
|
|
|
'category_id' => 0, |
|
|
|
|
'on_homepage' => 0, |
|
|
|
|
'target' => '_self', |
|
|
|
|
@ -935,7 +935,7 @@ class AddCourse |
|
|
|
|
'c_id' => $course_id, |
|
|
|
|
'url' => 'http://www.wikipedia.org', |
|
|
|
|
'title' => 'Wikipedia', |
|
|
|
|
'description' => get_lang('Wikipedia') , |
|
|
|
|
'description' => get_lang('Wikipedia'), |
|
|
|
|
'category_id' => 0, |
|
|
|
|
'on_homepage' => 0, |
|
|
|
|
'target' => '_self', |
|
|
|
|
@ -943,7 +943,7 @@ class AddCourse |
|
|
|
|
] |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
foreach($links as $params) { |
|
|
|
|
foreach ($links as $params) { |
|
|
|
|
$link->save($params); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -963,8 +963,8 @@ class AddCourse |
|
|
|
|
|
|
|
|
|
/* Introduction text */ |
|
|
|
|
$intro_text = '<p style="text-align: center;"> |
|
|
|
|
<img src="' . api_get_path(REL_CODE_PATH) . 'img/mascot.png" alt="Mr. Chamilo" title="Mr. Chamilo" /> |
|
|
|
|
<h2>' . get_lang('IntroductionText') . '</h2> |
|
|
|
|
<img src="' . api_get_path(REL_CODE_PATH).'img/mascot.png" alt="Mr. Chamilo" title="Mr. Chamilo" /> |
|
|
|
|
<h2>' . get_lang('IntroductionText').'</h2> |
|
|
|
|
</p>'; |
|
|
|
|
|
|
|
|
|
$toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro(); |
|
|
|
|
@ -1000,9 +1000,9 @@ class AddCourse |
|
|
|
|
$html = '<table width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
|
|
|
<tr> |
|
|
|
|
<td width="220" valign="top" align="left"> |
|
|
|
|
<img src="' . api_get_path(WEB_CODE_PATH) . 'default_course_document/images/mr_chamilo/doubts.png"> |
|
|
|
|
<img src="' . api_get_path(WEB_CODE_PATH).'default_course_document/images/mr_chamilo/doubts.png"> |
|
|
|
|
</td> |
|
|
|
|
<td valign="top" align="left">' . get_lang('Antique') . '</td></tr> |
|
|
|
|
<td valign="top" align="left">' . get_lang('Antique').'</td></tr> |
|
|
|
|
</table>'; |
|
|
|
|
$exercise->type = 1; |
|
|
|
|
$exercise->setRandom(0); |
|
|
|
|
@ -1254,7 +1254,7 @@ class AddCourse |
|
|
|
|
'https://' |
|
|
|
|
) === false |
|
|
|
|
) { |
|
|
|
|
$department_url = 'http://' . $department_url; |
|
|
|
|
$department_url = 'http://'.$department_url; |
|
|
|
|
} |
|
|
|
|
//just in case |
|
|
|
|
if ($department_url == 'http://') { |
|
|
|
|
@ -1300,12 +1300,12 @@ class AddCourse |
|
|
|
|
$code |
|
|
|
|
); |
|
|
|
|
if (!empty($user_id)) { |
|
|
|
|
$sql = "INSERT INTO " . $TABLECOURSUSER . " SET |
|
|
|
|
c_id = '" . $course_id . "', |
|
|
|
|
user_id = '" . intval($user_id) . "', |
|
|
|
|
$sql = "INSERT INTO ".$TABLECOURSUSER." SET |
|
|
|
|
c_id = '" . $course_id."', |
|
|
|
|
user_id = '" . intval($user_id)."', |
|
|
|
|
status = '1', |
|
|
|
|
is_tutor = '0', |
|
|
|
|
sort = '" . ($i_course_sort) . "', |
|
|
|
|
sort = '" . ($i_course_sort)."', |
|
|
|
|
relation_type = 0, |
|
|
|
|
user_course_cat = '0'"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
@ -1324,12 +1324,12 @@ class AddCourse |
|
|
|
|
if (empty($key)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$sql = "INSERT INTO " . $TABLECOURSUSER . " SET |
|
|
|
|
c_id = '" . Database::escape_string($course_id) . "', |
|
|
|
|
user_id = '" . Database::escape_string($key) . "', |
|
|
|
|
$sql = "INSERT INTO ".$TABLECOURSUSER." SET |
|
|
|
|
c_id = '" . Database::escape_string($course_id)."', |
|
|
|
|
user_id = '" . Database::escape_string($key)."', |
|
|
|
|
status = '1', |
|
|
|
|
is_tutor = '0', |
|
|
|
|
sort = '" . ($sort + 1) . "', |
|
|
|
|
sort = '" . ($sort + 1)."', |
|
|
|
|
relation_type = 0, |
|
|
|
|
user_course_cat = '0'"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
@ -1373,18 +1373,18 @@ class AddCourse |
|
|
|
|
$iname = api_get_setting('Institution'); |
|
|
|
|
$subject = get_lang( |
|
|
|
|
'NewCourseCreatedIn' |
|
|
|
|
) . ' ' . $siteName . ' - ' . $iname; |
|
|
|
|
).' '.$siteName.' - '.$iname; |
|
|
|
|
$message = get_lang( |
|
|
|
|
'Dear' |
|
|
|
|
) . ' ' . $recipient_name . ",\n\n" . get_lang( |
|
|
|
|
).' '.$recipient_name.",\n\n".get_lang( |
|
|
|
|
'MessageOfNewCourseToAdmin' |
|
|
|
|
) . ' ' . $siteName . ' - ' . $iname . "\n"; |
|
|
|
|
$message .= get_lang('CourseName') . ' ' . $title . "\n"; |
|
|
|
|
).' '.$siteName.' - '.$iname."\n"; |
|
|
|
|
$message .= get_lang('CourseName').' '.$title."\n"; |
|
|
|
|
$message .= get_lang( |
|
|
|
|
'Category' |
|
|
|
|
) . ' ' . $category_code . "\n"; |
|
|
|
|
$message .= get_lang('Tutor') . ' ' . $tutor_name . "\n"; |
|
|
|
|
$message .= get_lang('Language') . ' ' . $course_language; |
|
|
|
|
).' '.$category_code."\n"; |
|
|
|
|
$message .= get_lang('Tutor').' '.$tutor_name."\n"; |
|
|
|
|
$message .= get_lang('Language').' '.$course_language; |
|
|
|
|
|
|
|
|
|
$userInfo = api_get_user_info($user_id); |
|
|
|
|
|
|
|
|
|
|