123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655 |
- <?php
- require_once api_get_path(LIBRARY_PATH).'database.lib.php';
- require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
- function create_course($wanted_code, $title, $tutor_name, $category_code, $course_language, $course_admin_id, $db_prefix, $firstExpirationDelay) {
- $keys = define_course_keys($wanted_code, "", $db_prefix);
- if(sizeof($keys)) {
- $visual_code = $keys["currentCourseCode"];
- $code = $keys["currentCourseId"];
- $db_name = $keys["currentCourseDbName"];
- $directory = $keys["currentCourseRepository"];
- $expiration_date = time() + $firstExpirationDelay;
- prepare_course_repository($directory, $code);
- update_Db_course($db_name, $course_language);
- fill_course_repository($directory);
- fill_Db_course($db_name, $directory, $course_language);
- register_course($code, $visual_code, $directory, $db_name, $tutor_name, $category_code, $title, $course_language, $course_admin_id, $expiration_date);
- return $code;
- }
- else
- return false;
- }
- function generate_course_code($course_title, $encoding = null)
- {
- if (empty($encoding)) {
- $encoding = api_get_system_encoding();
- }
- return substr(preg_replace('/[^A-Z0-9]/', '', strtoupper(api_transliterate($course_title, 'X', $encoding))), 0, 20);
- }
- function define_course_keys($wantedCode, $prefix4all = "", $prefix4baseName = "", $prefix4path = "", $addUniquePrefix = false, $useCodeInDepedentKeys = true)
- {
- global $prefixAntiNumber, $_configuration;
- $course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
- $wantedCode = generate_course_code($wantedCode);
- $keysCourseCode = $wantedCode;
- if(!$useCodeInDepedentKeys)
- {
- $wantedCode = '';
- }
- if($addUniquePrefix)
- {
- $uniquePrefix = substr(md5(uniqid(rand())), 0, 10);
- }
- else
- {
- $uniquePrefix = '';
- }
- $keys = array ();
- $finalSuffix = array ('CourseId' => '', 'CourseDb' => '', 'CourseDir' => '');
- $limitNumbTry = 100;
- $keysAreUnique = false;
- $tryNewFSCId = $tryNewFSCDb = $tryNewFSCDir = 0;
- while (!$keysAreUnique)
- {
- $keysCourseId = $prefix4all.$uniquePrefix.$wantedCode.$finalSuffix['CourseId'];
- $keysCourseDbName = $prefix4baseName.$uniquePrefix.strtoupper($keysCourseId).$finalSuffix['CourseDb'];
- $keysCourseRepository = $prefix4path.$uniquePrefix.$wantedCode.$finalSuffix['CourseDir'];
- $keysAreUnique = true;
-
- $query = "SELECT 1 FROM ".$course_table . " WHERE code='".$keysCourseId . "' LIMIT 0,1";
- $result = Database::query($query);
- if($keysCourseId == DEFAULT_COURSE || Database::num_rows($result))
- {
- $keysAreUnique = false;
- $tryNewFSCId ++;
- $finalSuffix['CourseId'] = substr(md5(uniqid(rand())), 0, 4);
- }
- if($_configuration['single_database'])
- {
- $query = "SHOW TABLES FROM `".$_configuration['main_database']."` LIKE '".$_configuration['table_prefix']."$keysCourseDbName".$_configuration['db_glue']."%'";
- $result = Database::query($query);
- }
- else
- {
- $query = "SHOW DATABASES LIKE '$keysCourseDbName'";
- $result = Database::query($query);
- }
- if(Database::num_rows($result))
- {
- $keysAreUnique = false;
- $tryNewFSCDb ++;
- $finalSuffix['CourseDb'] = substr('_'.md5(uniqid(rand())), 0, 4);
- }
-
- if(file_exists($_configuration['root_sys'].$_configuration['course_folder'].$keysCourseRepository))
- {
- $keysAreUnique = false;
- $tryNewFSCDir ++;
- $finalSuffix['CourseDir'] = substr(md5(uniqid(rand())), 0, 4);
- }
- if(($tryNewFSCId + $tryNewFSCDb + $tryNewFSCDir) > $limitNumbTry)
- {
- return $keys;
- }
- }
-
- if(!stristr("abcdefghijklmnopqrstuvwxyz", $keysCourseDbName[0]))
- {
- $keysCourseDbName = $prefixAntiNumber.$keysCourseDbName;
- }
- $keys["currentCourseCode"] = $keysCourseCode;
- $keys["currentCourseId"] = $keysCourseId;
- $keys["currentCourseDbName"] = $keysCourseDbName;
- $keys["currentCourseRepository"] = $keysCourseRepository;
- return $keys;
- }
- function prepare_course_repository($courseRepository, $courseId)
- {
- $perm = api_get_permissions_for_new_directories();
- $perm_file = api_get_permissions_for_new_files();
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository, $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/document", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/document/images", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/document/images/gallery/", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/document/shared_folder/", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/document/audio", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/document/flash", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/document/video", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/document/video/flv", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/dropbox", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/group", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/page", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/scorm", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/temp", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/forum", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/forum/images", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/test", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/blog", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/learning_path", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/learning_path/images", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/calendar", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/calendar/images", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/work", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/announcements", $perm);
- mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/announcements/images", $perm);
-
- $fp = fopen(api_get_path(SYS_COURSE_PATH).$courseRepository . "/dropbox/.htaccess", "w");
- fwrite($fp, "AuthName AllowLocalAccess
- AuthType Basic
- order deny,allow
- deny from all
- php_flag zlib.output_compression off");
- fclose($fp);
-
- $fd = fopen(api_get_path(SYS_COURSE_PATH).$courseRepository . "/index.php", "w");
-
- $string = str_replace("\r", "", "<?" . "php
- \$cidReq = \"$courseId\";
- \$dbname = \"$courseId\";
- include(\"../../main/course_home/course_home.php\");
- ?>");
- fwrite($fd,$string);
- @chmod(api_get_path(SYS_COURSE_PATH).$courseRepository . '/index.php',$perm_file);
- $fd = fopen(api_get_path(SYS_COURSE_PATH).$courseRepository . '/group/index.html', 'w');
- $string = "<html></html>";
- fwrite($fd, "$string");
- return 0;
- };
- function update_Db_course($courseDbName, $language = null)
- {
- global $_configuration, $language_interface;
- if (empty($language)) {
- $language = $language_interface;
- }
-
- $charset_clause = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci';
- if (!$_configuration['single_database'])
- {
- Database::query("CREATE DATABASE IF NOT EXISTS `" . $courseDbName . "`" . $charset_clause);
- }
- $courseDbName = $_configuration['table_prefix'].$courseDbName.$_configuration['db_glue'];
- $tbl_course_homepage = $courseDbName . 'tool';
- $TABLEINTROS = $courseDbName . 'tool_intro';
-
- $TABLEGROUPS = $courseDbName . 'group_info';
- $TABLEGROUPCATEGORIES = $courseDbName . 'group_category';
- $TABLEGROUPUSER = $courseDbName . 'group_rel_user';
- $TABLEGROUPTUTOR = $courseDbName . 'group_rel_tutor';
- $TABLEITEMPROPERTY = $courseDbName . 'item_property';
- $TABLETOOLUSERINFOCONTENT = $courseDbName . 'userinfo_content';
- $TABLETOOLUSERINFODEF = $courseDbName . 'userinfo_def';
- $TABLETOOLCOURSEDESC = $courseDbName . 'course_description';
- $TABLETOOLAGENDA = $courseDbName . 'calendar_event';
- $TABLETOOLAGENDAREPEAT = $courseDbName . 'calendar_event_repeat';
- $TABLETOOLAGENDAREPEATNOT = $courseDbName . 'calendar_event_repeat_not';
- $TABLETOOLAGENDAATTACHMENT = $courseDbName . 'calendar_event_attachment';
-
- $TABLETOOLANNOUNCEMENTS = $courseDbName . 'announcement';
- $TABLETOOLANNOUNCEMENTSATTACHMENT = $courseDbName . 'announcement_attachment';
-
- $TABLEADDEDRESOURCES = $courseDbName . 'resource';
-
- $TABLETOOLWORKS = $courseDbName . 'student_publication';
- $TABLETOOLWORKSASS = $courseDbName . 'student_publication_assignment';
-
- $TABLETOOLDOCUMENT = $courseDbName . 'document';
-
- $TABLETOOLFORUMCATEGORY = $courseDbName . 'forum_category';
- $TABLETOOLFORUM = $courseDbName . 'forum_forum';
- $TABLETOOLFORUMTHREAD = $courseDbName . 'forum_thread';
- $TABLETOOLFORUMPOST = $courseDbName . 'forum_post';
- $TABLETOOLFORUMMAILCUE = $courseDbName . 'forum_mailcue';
- $TABLETOOLFORUMATTACHMENT = $courseDbName . 'forum_attachment';
- $TABLETOOLFORUMNOTIFICATION = $courseDbName . 'forum_notification';
- $TABLETOOLFORUMQUALIFY = $courseDbName . 'forum_thread_qualify';
- $TABLETOOLFORUMQUALIFYLOG = $courseDbName . 'forum_thread_qualify_log';
-
- $TABLETOOLLINK = $courseDbName . 'link';
- $TABLETOOLLINKCATEGORIES = $courseDbName . 'link_category';
- $TABLETOOLONLINECONNECTED = $courseDbName . 'online_connected';
- $TABLETOOLONLINELINK = $courseDbName . 'online_link';
-
- $TABLETOOLCHATCONNECTED = $courseDbName . 'chat_connected';
-
- $TABLEQUIZ = $courseDbName . 'quiz';
- $TABLEQUIZQUESTION = $courseDbName . 'quiz_rel_question';
- $TABLEQUIZQUESTIONLIST = $courseDbName . 'quiz_question';
- $TABLEQUIZANSWERSLIST = $courseDbName . 'quiz_answer';
-
- $TABLETOOLDROPBOXPOST = $courseDbName . 'dropbox_post';
- $TABLETOOLDROPBOXFILE = $courseDbName . 'dropbox_file';
- $TABLETOOLDROPBOXPERSON = $courseDbName . 'dropbox_person';
- $TABLETOOLDROPBOXCATEGORY = $courseDbName . 'dropbox_category';
- $TABLETOOLDROPBOXFEEDBACK = $courseDbName . 'dropbox_feedback';
-
- $TABLELP = $courseDbName . 'lp';
- $TABLELPITEM = $courseDbName . 'lp_item';
- $TABLELPVIEW = $courseDbName . 'lp_view';
- $TABLELPITEMVIEW = $courseDbName . 'lp_item_view';
- $TABLELPIVINTERACTION = $courseDbName . 'lp_iv_interaction';
- $TABLELPIVOBJECTIVE = $courseDbName . 'lp_iv_objective';
-
- $tbl_blogs = $courseDbName . 'blog';
- $tbl_blogs_comments = $courseDbName . 'blog_comment';
- $tbl_blogs_posts = $courseDbName . 'blog_post';
- $tbl_blogs_rating = $courseDbName . 'blog_rating';
- $tbl_blogs_rel_user = $courseDbName . 'blog_rel_user';
- $tbl_blogs_tasks = $courseDbName . 'blog_task';
- $tbl_blogs_tasks_rel_user = $courseDbName . 'blog_task_rel_user';
- $tbl_blogs_attachment = $courseDbName . 'blog_attachment';
-
- $tbl_permission_group = $courseDbName . 'permission_group';
- $tbl_permission_user = $courseDbName . 'permission_user';
- $tbl_permission_task = $courseDbName . 'permission_task';
-
- $tbl_role = $courseDbName . 'role';
- $tbl_role_group = $courseDbName . 'role_group';
- $tbl_role_permissions = $courseDbName . 'role_permissions';
- $tbl_role_user = $courseDbName . 'role_user';
-
- $TABLESURVEY = $courseDbName . 'survey';
- $TABLESURVEYQUESTION = $courseDbName . 'survey_question';
- $TABLESURVEYQUESTIONOPTION = $courseDbName . 'survey_question_option';
- $TABLESURVEYINVITATION = $courseDbName . 'survey_invitation';
- $TABLESURVEYANSWER = $courseDbName . 'survey_answer';
- $TABLESURVEYGROUP = $courseDbName . 'survey_group';
-
- $TABLETOOLWIKI = $courseDbName . 'wiki';
- $TABLEWIKICONF = $courseDbName . 'wiki_conf';
- $TABLEWIKIDISCUSS = $courseDbName . 'wiki_discuss';
- $TABLEWIKIMAILCUE = $courseDbName . 'wiki_mailcue';
-
- $TABLEAUDIORECORDER = $courseDbName.'audiorecorder';
-
- $TABLESETTING = $courseDbName . 'course_setting';
-
- $TBL_GLOSSARY = $courseDbName . 'glossary';
-
- $TBL_NOTEBOOK = $courseDbName . 'notebook';
-
- $TBL_ATTENDANCE = $courseDbName . 'attendance';
- $TBL_ATTENDANCE_SHEET = $courseDbName . 'attendance_sheet';
- $TBL_ATTENDANCE_CALENDAR = $courseDbName . 'attendance_calendar';
- $TBL_ATTENDANCE_RESULT = $courseDbName . 'attendance_result';
-
- $TBL_THEMATIC = $courseDbName . 'thematic';
- $TBL_THEMATIC_PLAN = $courseDbName . 'thematic_plan';
- $TBL_THEMATIC_ADVANCE = $courseDbName . 'thematic_advance';
-
- $sql = "
- CREATE TABLE `".$TABLETOOLANNOUNCEMENTS . "` (
- id mediumint unsigned NOT NULL auto_increment,
- title text,
- content mediumtext,
- end_date date default NULL,
- display_order mediumint NOT NULL default 0,
- email_sent tinyint default 0,
- session_id smallint default 0,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLANNOUNCEMENTS . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLETOOLANNOUNCEMENTSATTACHMENT."` (
- id int NOT NULL auto_increment,
- path varchar(255) NOT NULL,
- comment text,
- size int NOT NULL default 0,
- announcement_id int NOT NULL,
- filename varchar(255) NOT NULL,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLEADDEDRESOURCES . "` (
- id int unsigned NOT NULL auto_increment,
- source_type varchar(50) default NULL,
- source_id int unsigned default NULL,
- resource_type varchar(50) default NULL,
- resource_id int unsigned default NULL,
- UNIQUE KEY id (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "
- CREATE TABLE `".$TABLETOOLUSERINFOCONTENT . "` (
- id int unsigned NOT NULL auto_increment,
- user_id int unsigned NOT NULL,
- definition_id int unsigned NOT NULL,
- editor_ip varchar(39) default NULL,
- edition_time datetime default NULL,
- content text NOT NULL,
- PRIMARY KEY (id),
- KEY user_id (user_id)
- )" . $charset_clause;
- Database::query($sql);
-
-
- $sql = "
- CREATE TABLE `".$TABLETOOLUSERINFODEF . "` (
- id int unsigned NOT NULL auto_increment,
- title varchar(80) NOT NULL default '',
- comment text,
- line_count tinyint unsigned NOT NULL default 5,
- rank tinyint unsigned NOT NULL default 0,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
-
-
- $sql = "
- CREATE TABLE `".$TABLETOOLFORUMCATEGORY . "` (
- cat_id int NOT NULL auto_increment,
- cat_title varchar(255) NOT NULL default '',
- cat_comment text,
- cat_order int NOT NULL default 0,
- locked int NOT NULL default 0,
- session_id smallint unsigned NOT NULL default 0,
- PRIMARY KEY (cat_id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLFORUMCATEGORY . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLFORUM . "` (
- forum_id int NOT NULL auto_increment,
- forum_title varchar(255) NOT NULL default '',
- forum_comment text,
- forum_threads int default 0,
- forum_posts int default 0,
- forum_last_post int default 0,
- forum_category int default NULL,
- allow_anonymous int default NULL,
- allow_edit int default NULL,
- approval_direct_post varchar(20) default NULL,
- allow_attachments int default NULL,
- allow_new_threads int default NULL,
- default_view varchar(20) default NULL,
- forum_of_group varchar(20) default NULL,
- forum_group_public_private varchar(20) default 'public',
- forum_order int default NULL,
- locked int NOT NULL default 0,
- session_id int NOT NULL default 0,
- forum_image varchar(255) NOT NULL default '',
- start_time datetime NOT NULL default '0000-00-00 00:00:00',
- end_time datetime NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY (forum_id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLFORUMTHREAD . "` (
- thread_id int NOT NULL auto_increment,
- thread_title varchar(255) default NULL,
- forum_id int default NULL,
- thread_replies int default 0,
- thread_poster_id int default NULL,
- thread_poster_name varchar(100) default '',
- thread_views int default 0,
- thread_last_post int default NULL,
- thread_date datetime default '0000-00-00 00:00:00',
- thread_sticky tinyint unsigned default 0,
- locked int NOT NULL default 0,
- session_id int unsigned default NULL,
- thread_title_qualify varchar(255) default '',
- thread_qualify_max float(6,2) UNSIGNED NOT NULL default 0,
- thread_close_date datetime default '0000-00-00 00:00:00',
- thread_weight float(6,2) UNSIGNED NOT NULL default 0,
- PRIMARY KEY (thread_id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLFORUMTHREAD . "` ADD INDEX idx_forum_thread_forum_id (forum_id)";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLFORUMPOST . "` (
- post_id int NOT NULL auto_increment,
- post_title varchar(250) default NULL,
- post_text text,
- thread_id int default 0,
- forum_id int default 0,
- poster_id int default 0,
- poster_name varchar(100) default '',
- post_date datetime default '0000-00-00 00:00:00',
- post_notification tinyint default 0,
- post_parent_id int default 0,
- visible tinyint default 1,
- PRIMARY KEY (post_id),
- KEY poster_id (poster_id),
- KEY forum_id (forum_id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLFORUMPOST . "` ADD INDEX idx_forum_post_thread_id (thread_id)";
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLFORUMPOST . "` ADD INDEX idx_forum_post_visible (visible)";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLFORUMMAILCUE . "` (
- thread_id int default NULL,
- user_id int default NULL,
- post_id int default NULL
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLETOOLFORUMATTACHMENT."` (
- id int NOT NULL auto_increment,
- path varchar(255) NOT NULL,
- comment text,
- size int NOT NULL default 0,
- post_id int NOT NULL,
- filename varchar(255) NOT NULL,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLETOOLFORUMNOTIFICATION."` (
- user_id int,
- forum_id int,
- thread_id int,
- post_id int,
- KEY user_id (user_id),
- KEY forum_id (forum_id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLETOOLFORUMQUALIFY."` (
- id int unsigned PRIMARY KEY AUTO_INCREMENT,
- user_id int unsigned NOT NULL,
- thread_id int NOT NULL,
- qualify float(6,2) NOT NULL default 0,
- qualify_user_id int default NULL,
- qualify_time datetime default '0000-00-00 00:00:00',
- session_id int default NULL
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLFORUMQUALIFY . "` ADD INDEX (user_id, thread_id)";
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLETOOLFORUMQUALIFYLOG."` (
- id int unsigned PRIMARY KEY AUTO_INCREMENT,
- user_id int unsigned NOT NULL,
- thread_id int NOT NULL,
- qualify float(6,2) NOT NULL default 0,
- qualify_user_id int default NULL,
- qualify_time datetime default '0000-00-00 00:00:00',
- session_id int default NULL
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLFORUMQUALIFYLOG. "` ADD INDEX (user_id, thread_id)";
- Database::query($sql);
-
-
- $sql = "
- CREATE TABLE `".$TABLEQUIZ . "` (
- id mediumint unsigned NOT NULL auto_increment,
- title varchar(255) NOT NULL,
- description text default NULL,
- sound varchar(255) default NULL,
- type tinyint unsigned NOT NULL default 1,
- random smallint(6) NOT NULL default 0,
- random_answers tinyint unsigned NOT NULL default 0,
- active tinyint NOT NULL default 0,
- results_disabled TINYINT UNSIGNED NOT NULL DEFAULT 0,
- access_condition TEXT DEFAULT NULL,
- max_attempt int NOT NULL default 0,
- start_time datetime NOT NULL default '0000-00-00 00:00:00',
- end_time datetime NOT NULL default '0000-00-00 00:00:00',
- feedback_type int NOT NULL default 0,
- expired_time int NOT NULL default '0',
- session_id smallint default 0,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLEQUIZ . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLEQUIZQUESTIONLIST . "` (
- id mediumint unsigned NOT NULL auto_increment,
- question varchar(511) NOT NULL,
- description text default NULL,
- ponderation float(6,2) NOT NULL default 0,
- position mediumint unsigned NOT NULL default 1,
- type tinyint unsigned NOT NULL default 2,
- picture varchar(50) default NULL,
- level int unsigned NOT NULL default 0,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLEQUIZQUESTIONLIST . "` ADD INDEX (position)";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLEQUIZANSWERSLIST . "` (
- id mediumint unsigned NOT NULL,
- question_id mediumint unsigned NOT NULL,
- answer text NOT NULL,
- correct mediumint unsigned default NULL,
- comment text default NULL,
- ponderation float(6,2) NOT NULL default 0,
- position mediumint unsigned NOT NULL default 1,
- hotspot_coordinates text,
- hotspot_type enum('square','circle','poly','delineation') default NULL,
- destination text NOT NULL,
- id_auto int NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (id, question_id),
- UNIQUE KEY id_auto (id_auto)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLEQUIZQUESTION . "` (
- question_id mediumint unsigned NOT NULL,
- exercice_id mediumint unsigned NOT NULL,
- question_order mediumint unsigned NOT NULL default 1,
- PRIMARY KEY (question_id,exercice_id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLCOURSEDESC . "` (
- id TINYINT UNSIGNED NOT NULL auto_increment,
- title VARCHAR(255),
- content TEXT,
- session_id smallint default 0,
- description_type tinyint unsigned NOT NULL default 0,
- progress INT NOT NULL default 0,
- UNIQUE (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLCOURSEDESC . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `" . $tbl_course_homepage . "` (
- id int unsigned NOT NULL auto_increment,
- name varchar(255) NOT NULL,
- link varchar(255) NOT NULL,
- image varchar(255) default NULL,
- visibility tinyint unsigned default 0,
- admin varchar(255) default NULL,
- address varchar(255) default NULL,
- added_tool tinyint unsigned default 1,
- target enum('_self','_blank') NOT NULL default '_self',
- category enum('authoring','interaction','admin') NOT NULL default 'authoring',
- session_id smallint default 0,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$tbl_course_homepage . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLAGENDA . "` (
- id int unsigned NOT NULL auto_increment,
- title varchar(255) NOT NULL,
- content text,
- start_date datetime NOT NULL default '0000-00-00 00:00:00',
- end_date datetime NOT NULL default '0000-00-00 00:00:00',
- parent_event_id INT NULL,
- session_id int unsigned NOT NULL default 0,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLAGENDA . "` ADD INDEX ( session_id ) ;";
- Database::query($sql);
- $sql = "
- CREATE TABLE `".$TABLETOOLAGENDAREPEAT. "` (
- cal_id INT DEFAULT 0 NOT NULL,
- cal_type VARCHAR(20),
- cal_end INT,
- cal_frequency INT DEFAULT 1,
- cal_days CHAR(7),
- PRIMARY KEY (cal_id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "
- CREATE TABLE `".$TABLETOOLAGENDAREPEATNOT."` (
- cal_id INT NOT NULL,
- cal_date INT NOT NULL,
- PRIMARY KEY ( cal_id, cal_date )
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLETOOLAGENDAATTACHMENT."` (
- id int NOT NULL auto_increment,
- path varchar(255) NOT NULL,
- comment text,
- size int NOT NULL default 0,
- agenda_id int NOT NULL,
- filename varchar(255) NOT NULL,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLDOCUMENT . "` (
- id int unsigned NOT NULL auto_increment,
- path varchar(255) NOT NULL default '',
- comment text,
- title varchar(255) default NULL,
- filetype set('file','folder') NOT NULL default 'file',
- size int NOT NULL default 0,
- readonly TINYINT UNSIGNED NOT NULL,
- session_id int UNSIGNED NOT NULL default 0,
- PRIMARY KEY (`id`)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLWORKS . "` (
- id int unsigned NOT NULL auto_increment,
- url varchar(255) default NULL,
- title varchar(255) default NULL,
- description text default NULL,
- author varchar(255) default NULL,
- active tinyint default NULL,
- accepted tinyint default 0,
- post_group_id int DEFAULT 0 NOT NULL,
- sent_date datetime NOT NULL default '0000-00-00 00:00:00',
- filetype set('file','folder') NOT NULL default 'file',
- has_properties int UNSIGNED NOT NULL DEFAULT 0,
- view_properties tinyint NULL,
- qualification float(6,2) UNSIGNED NOT NULL DEFAULT 0,
- date_of_qualification datetime NOT NULL default '0000-00-00 00:00:00',
- parent_id INT UNSIGNED NOT NULL DEFAULT 0,
- qualificator_id INT UNSIGNED NOT NULL DEFAULT 0,
- weight float(6,2) UNSIGNED NOT NULL default 0,
- session_id INT UNSIGNED NOT NULL default 0,
- user_id INTEGER NOT NULL,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "
- CREATE TABLE `".$TABLETOOLWORKSASS."` (
- id int NOT NULL auto_increment,
- expires_on datetime NOT NULL default '0000-00-00 00:00:00',
- ends_on datetime NOT NULL default '0000-00-00 00:00:00',
- add_to_calendar tinyint NOT NULL,
- enable_qualification tinyint NOT NULL,
- publication_id int NOT NULL,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLWORKS . "` ADD INDEX ( session_id )" ;
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLLINK . "` (
- id int unsigned NOT NULL auto_increment,
- url TEXT NOT NULL,
- title varchar(150) default NULL,
- description text,
- category_id smallint unsigned default NULL,
- display_order smallint unsigned NOT NULL default 0,
- on_homepage enum('0','1') NOT NULL default '0',
- target char(10) default '_self',
- session_id smallint default 0,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLLINK . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
- $sql = "
- CREATE TABLE `".$TABLETOOLLINKCATEGORIES . "` (
- id smallint unsigned NOT NULL auto_increment,
- category_title varchar(255) NOT NULL,
- description text,
- display_order mediumint unsigned NOT NULL default 0,
- session_id smallint default 0,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLLINKCATEGORIES . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
- $sql = "CREATE TABLE `".$TABLETOOLWIKI . "` (
- id int NOT NULL auto_increment,
- page_id int NOT NULL default 0,
- reflink varchar(255) NOT NULL default 'index',
- title varchar(255) NOT NULL,
- content mediumtext NOT NULL,
- user_id int NOT NULL default 0,
- group_id int DEFAULT NULL,
- dtime datetime NOT NULL default '0000-00-00 00:00:00',
- addlock int NOT NULL default 1,
- editlock int NOT NULL default 0,
- visibility int NOT NULL default 1,
- addlock_disc int NOT NULL default 1,
- visibility_disc int NOT NULL default 1,
- ratinglock_disc int NOT NULL default 1,
- assignment int NOT NULL default 0,
- comment text NOT NULL,
- progress text NOT NULL,
- score int NULL default 0,
- version int default NULL,
- is_editing int NOT NULL default 0,
- time_edit datetime NOT NULL default '0000-00-00 00:00:00',
- hits int default 0,
- linksto text NOT NULL,
- tag text NOT NULL,
- user_ip varchar(39) NOT NULL,
- session_id smallint default 0,
- PRIMARY KEY (id),
- KEY reflink (reflink),
- KEY group_id (group_id),
- KEY page_id (page_id),
- KEY session_id (session_id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLEWIKICONF . "` (
- page_id int NOT NULL default 0,
- task text NOT NULL,
- feedback1 text NOT NULL,
- feedback2 text NOT NULL,
- feedback3 text NOT NULL,
- fprogress1 varchar(3) NOT NULL,
- fprogress2 varchar(3) NOT NULL,
- fprogress3 varchar(3) NOT NULL,
- max_size int default NULL,
- max_text int default NULL,
- max_version int default NULL,
- startdate_assig datetime NOT NULL default '0000-00-00 00:00:00',
- enddate_assig datetime NOT NULL default '0000-00-00 00:00:00',
- delayedsubmit int NOT NULL default 0,
- KEY page_id (page_id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLEWIKIDISCUSS . "` (
- id int NOT NULL auto_increment,
- publication_id int NOT NULL default 0,
- userc_id int NOT NULL default 0,
- comment text NOT NULL,
- p_score varchar(255) default NULL,
- dtime datetime NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TABLEWIKIMAILCUE . "` (
- id int NOT NULL,
- user_id int NOT NULL,
- type text NOT NULL,
- group_id int DEFAULT NULL,
- session_id smallint default 0,
- KEY (id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TABLETOOLONLINECONNECTED . "` (
- user_id int unsigned NOT NULL,
- last_connection datetime NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY (user_id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "
- CREATE TABLE `".$TABLETOOLONLINELINK . "` (
- id smallint unsigned NOT NULL auto_increment,
- name char(50) NOT NULL default '',
- url char(100) NOT NULL,
- PRIMARY KEY (id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "
- CREATE TABLE `".$TABLETOOLCHATCONNECTED . "` (
- user_id int unsigned NOT NULL default '0',
- last_connection datetime NOT NULL default '0000-00-00 00:00:00',
- session_id INT NOT NULL default 0,
- to_group_id INT NOT NULL default 0
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLCHATCONNECTED . "` ADD INDEX `char_connected_index`(user_id, session_id, to_group_id) ";
- Database::query($sql);
-
- Database::query("CREATE TABLE `".$TABLEGROUPS . "` (
- id int unsigned NOT NULL auto_increment,
- name varchar(100) default NULL,
- category_id int unsigned NOT NULL default 0,
- description text,
- max_student smallint unsigned NOT NULL default 8,
- doc_state tinyint unsigned NOT NULL default 1,
- calendar_state tinyint unsigned NOT NULL default 0,
- work_state tinyint unsigned NOT NULL default 0,
- announcements_state tinyint unsigned NOT NULL default 0,
- forum_state tinyint unsigned NOT NULL default 0,
- wiki_state tinyint unsigned NOT NULL default 1,
- chat_state tinyint unsigned NOT NULL default 1,
- secret_directory varchar(255) default NULL,
- self_registration_allowed tinyint unsigned NOT NULL default '0',
- self_unregistration_allowed tinyint unsigned NOT NULL default '0',
- session_id smallint unsigned NOT NULL default 0,
- PRIMARY KEY (id)
- )" . $charset_clause);
- Database::query("ALTER TABLE `".$TABLEGROUPS . "` ADD INDEX ( session_id )");
- Database::query("CREATE TABLE `".$TABLEGROUPCATEGORIES . "` (
- id int unsigned NOT NULL auto_increment,
- title varchar(255) NOT NULL default '',
- description text NOT NULL,
- doc_state tinyint unsigned NOT NULL default 1,
- calendar_state tinyint unsigned NOT NULL default 1,
- work_state tinyint unsigned NOT NULL default 1,
- announcements_state tinyint unsigned NOT NULL default 1,
- forum_state tinyint unsigned NOT NULL default 1,
- wiki_state tinyint unsigned NOT NULL default 1,
- chat_state tinyint unsigned NOT NULL default 1,
- max_student smallint unsigned NOT NULL default 8,
- self_reg_allowed tinyint unsigned NOT NULL default 0,
- self_unreg_allowed tinyint unsigned NOT NULL default 0,
- groups_per_user smallint unsigned NOT NULL default 0,
- display_order smallint unsigned NOT NULL default 0,
- PRIMARY KEY (id)
- )" . $charset_clause);
- Database::query("CREATE TABLE `".$TABLEGROUPUSER . "` (
- id int unsigned NOT NULL auto_increment,
- user_id int unsigned NOT NULL,
- group_id int unsigned NOT NULL default 0,
- status int NOT NULL default 0,
- role char(50) NOT NULL,
- PRIMARY KEY (id)
- )" . $charset_clause);
- Database::query("CREATE TABLE `".$TABLEGROUPTUTOR . "` (
- id int NOT NULL auto_increment,
- user_id int NOT NULL,
- group_id int NOT NULL default 0,
- PRIMARY KEY (id)
- )" . $charset_clause);
- Database::query("CREATE TABLE `".$TABLEITEMPROPERTY . "` (
- id int NOT NULL auto_increment,
- tool varchar(100) NOT NULL default '',
- insert_user_id int unsigned NOT NULL default '0',
- insert_date datetime NOT NULL default '0000-00-00 00:00:00',
- lastedit_date datetime NOT NULL default '0000-00-00 00:00:00',
- ref int NOT NULL default '0',
- lastedit_type varchar(100) NOT NULL default '',
- lastedit_user_id int unsigned NOT NULL default '0',
- to_group_id int unsigned default NULL,
- to_user_id int unsigned default NULL,
- visibility tinyint NOT NULL default '1',
- start_visible datetime NOT NULL default '0000-00-00 00:00:00',
- end_visible datetime NOT NULL default '0000-00-00 00:00:00',
- id_session INT NOT NULL DEFAULT 0,
- PRIMARY KEY (id)
- )" . $charset_clause);
- Database::query("ALTER TABLE `$TABLEITEMPROPERTY` ADD INDEX idx_item_property_toolref (tool,ref)");
-
- Database::query("
- CREATE TABLE `".$TABLEINTROS . "` (
- id varchar(50) NOT NULL,
- intro_text text NOT NULL,
- session_id INT NOT NULL DEFAULT 0,
- PRIMARY KEY (id, session_id)
- )" . $charset_clause);
-
- Database::query("
- CREATE TABLE `".$TABLETOOLDROPBOXFILE . "` (
- id int unsigned NOT NULL auto_increment,
- uploader_id int unsigned NOT NULL default 0,
- filename varchar(250) NOT NULL default '',
- filesize int unsigned NOT NULL,
- title varchar(250) default '',
- description varchar(250) default '',
- author varchar(250) default '',
- upload_date datetime NOT NULL default '0000-00-00 00:00:00',
- last_upload_date datetime NOT NULL default '0000-00-00 00:00:00',
- cat_id int NOT NULL default 0,
- session_id SMALLINT UNSIGNED NOT NULL,
- PRIMARY KEY (id),
- UNIQUE KEY UN_filename (filename)
- )" . $charset_clause);
- Database::query("ALTER TABLE `$TABLETOOLDROPBOXFILE` ADD INDEX ( `session_id` )");
- Database::query("
- CREATE TABLE `".$TABLETOOLDROPBOXPOST . "` (
- file_id int unsigned NOT NULL,
- dest_user_id int unsigned NOT NULL default 0,
- feedback_date datetime NOT NULL default '0000-00-00 00:00:00',
- feedback text default '',
- cat_id int NOT NULL default 0,
- session_id SMALLINT UNSIGNED NOT NULL,
- PRIMARY KEY (file_id,dest_user_id)
- )" . $charset_clause);
- Database::query("ALTER TABLE `$TABLETOOLDROPBOXPOST` ADD INDEX ( `session_id` )");
- Database::query("
- CREATE TABLE `".$TABLETOOLDROPBOXPERSON . "` (
- file_id int unsigned NOT NULL,
- user_id int unsigned NOT NULL default 0,
- PRIMARY KEY (file_id,user_id)
- )" . $charset_clause);
- $sql = "CREATE TABLE `".$TABLETOOLDROPBOXCATEGORY."` (
- cat_id int NOT NULL auto_increment,
- cat_name text NOT NULL,
- received tinyint unsigned NOT NULL default 0,
- sent tinyint unsigned NOT NULL default 0,
- user_id int NOT NULL default 0,
- session_id smallint NOT NULL default 0,
- PRIMARY KEY (cat_id)
- )" . $charset_clause;
- Database::query($sql);
- $sql = "ALTER TABLE `".$TABLETOOLDROPBOXCATEGORY . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
- $sql = "CREATE TABLE `".$TABLETOOLDROPBOXFEEDBACK."` (
- feedback_id int NOT NULL auto_increment,
- file_id int NOT NULL default 0,
- author_user_id int NOT NULL default 0,
- feedback text NOT NULL,
- feedback_date datetime NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY (feedback_id),
- KEY file_id (file_id),
- KEY author_user_id (author_user_id)
- )" . $charset_clause;
- Database::query($sql);
-
- $sql = "CREATE TABLE IF NOT EXISTS `$TABLELP` (" .
- "id int unsigned primary key auto_increment," .
- "lp_type smallint unsigned not null," .
- "name varchar(255) not null," .
- "ref tinytext null," .
- "description text null,".
- "path text not null," .
- "force_commit tinyint unsigned not null default 0, " .
- "default_view_mod char(32) not null default 'embedded'," .
- "default_encoding char(32) not null default 'UTF-8', " .
- "display_order int unsigned not null default 0," .
- "content_maker tinytext not null default ''," .
- "content_local varchar(32) not null default 'local'," .
- "content_license text not null default ''," .
- "prevent_reinit tinyint unsigned not null default 1," .
- "js_lib tinytext not null default ''," .
- "debug tinyint unsigned not null default 0," .
- "theme varchar(255) not null default '', " .
- "preview_image varchar(255) not null default '', " .
- "author varchar(255) not null default '', " .
- "session_id int unsigned not null default 0, " .
- "prerequisite int unsigned not null default 0 " .
- ")" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "CREATE TABLE IF NOT EXISTS `$TABLELPVIEW` (" .
- "id int unsigned primary key auto_increment," .
- "lp_id int unsigned not null," .
- "user_id int unsigned not null," .
- "view_count smallint unsigned not null default 0," .
- "last_item int unsigned not null default 0," .
- "progress int unsigned default 0," .
- "session_id int not null default 0 )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "ALTER TABLE `$TABLELPVIEW` ADD INDEX (lp_id) ";
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "ALTER TABLE `$TABLELPVIEW` ADD INDEX (user_id) ";
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "ALTER TABLE `$TABLELPVIEW` ADD INDEX (session_id) ";
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "CREATE TABLE IF NOT EXISTS `$TABLELPITEM` (" .
- "id int unsigned primary key auto_increment," .
- "lp_id int unsigned not null," .
- "item_type char(32) not null default 'dokeos_document'," .
- "ref tinytext not null default ''," .
- "title varchar(511) not null," .
- "description varchar(511) not null default ''," .
- "path text not null," .
- "min_score float unsigned not null default 0," .
- "max_score float unsigned not null default 100," .
- "mastery_score float unsigned null," .
- "parent_item_id int unsigned not null default 0," .
- "previous_item_id int unsigned not null default 0," .
- "next_item_id int unsigned not null default 0," .
- "display_order int unsigned not null default 0," .
- "prerequisite text null default null," .
- "parameters text null," .
- "launch_data text not null default ''," .
- "max_time_allowed char(13) NULL default ''," .
- "terms TEXT NULL," .
- "search_did INT NULL,".
- "audio VARCHAR(250))" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "ALTER TABLE `$TABLELPITEM` ADD INDEX (lp_id)";
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "CREATE TABLE IF NOT EXISTS `$TABLELPITEMVIEW` (" .
- "id bigint unsigned primary key auto_increment," .
- "lp_item_id int unsigned not null," .
- "lp_view_id int unsigned not null," .
- "view_count int unsigned not null default 0," .
- "start_time int unsigned not null," .
- "total_time int unsigned not null default 0," .
- "score float unsigned not null default 0," .
- "status char(32) not null default 'not attempted'," .
- "suspend_data text null default ''," .
- "lesson_location text null default ''," .
- "core_exit varchar(32) not null default 'none'," .
- "max_score varchar(8) default ''" .
- ")" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "ALTER TABLE `$TABLELPITEMVIEW` ADD INDEX (lp_item_id) ";
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "ALTER TABLE `$TABLELPITEMVIEW` ADD INDEX (lp_view_id) ";
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "CREATE TABLE IF NOT EXISTS `$TABLELPIVINTERACTION`(" .
- "id bigint unsigned primary key auto_increment," .
- "order_id smallint unsigned not null default 0,".
- "lp_iv_id bigint unsigned not null," .
- "interaction_id varchar(255) not null default ''," .
- "interaction_type varchar(255) not null default ''," .
- "weighting double not null default 0," .
- "completion_time varchar(16) not null default ''," .
- "correct_responses text not null default ''," .
- "student_response text not null default ''," .
- "result varchar(255) not null default ''," .
- "latency varchar(16) not null default ''" .
- ")" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "ALTER TABLE `$TABLELPIVINTERACTION` ADD INDEX (lp_iv_id) ";
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "CREATE TABLE IF NOT EXISTS `$TABLELPIVOBJECTIVE`(" .
- "id bigint unsigned primary key auto_increment," .
- "lp_iv_id bigint unsigned not null," .
- "order_id smallint unsigned not null default 0,".
- "objective_id varchar(255) not null default ''," .
- "score_raw float unsigned not null default 0," .
- "score_max float unsigned not null default 0," .
- "score_min float unsigned not null default 0," .
- "status char(32) not null default 'not attempted'" .
- ")" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
- $sql = "ALTER TABLE `$TABLELPIVOBJECTIVE` ADD INDEX (lp_iv_id) ";
- if(!Database::query($sql))
- {
- error_log($sql,0);
- }
-
- $sql = "
- CREATE TABLE `" . $tbl_blogs . "` (
- blog_id smallint NOT NULL AUTO_INCREMENT ,
- blog_name varchar( 250 ) NOT NULL default '',
- blog_subtitle varchar( 250 ) default NULL ,
- date_creation datetime NOT NULL default '0000-00-00 00:00:00',
- visibility tinyint unsigned NOT NULL default 0,
- session_id smallint default 0,
- PRIMARY KEY ( blog_id )
- )" . $charset_clause . " COMMENT = 'Table with blogs in this course';";
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "ALTER TABLE `".$tbl_blogs . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
- $sql = "
- CREATE TABLE `" . $tbl_blogs_comments . "` (
- comment_id int NOT NULL AUTO_INCREMENT ,
- title varchar( 250 ) NOT NULL default '',
- comment longtext NOT NULL ,
- author_id int NOT NULL default 0,
- date_creation datetime NOT NULL default '0000-00-00 00:00:00',
- blog_id mediumint NOT NULL default 0,
- post_id int NOT NULL default 0,
- task_id int default NULL ,
- parent_comment_id int NOT NULL default 0,
- PRIMARY KEY ( comment_id )
- )" . $charset_clause . " COMMENT = 'Table with comments on posts in a blog';";
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_blogs_posts . "` (
- post_id int NOT NULL AUTO_INCREMENT ,
- title varchar( 250 ) NOT NULL default '',
- full_text longtext NOT NULL ,
- date_creation datetime NOT NULL default '0000-00-00 00:00:00',
- blog_id mediumint NOT NULL default 0,
- author_id int NOT NULL default 0,
- PRIMARY KEY ( post_id )
- )" . $charset_clause . " COMMENT = 'Table with posts / blog.';";
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_blogs_rating . "` (
- rating_id int NOT NULL AUTO_INCREMENT ,
- blog_id int NOT NULL default 0,
- rating_type enum( 'post', 'comment' ) NOT NULL default 'post',
- item_id int NOT NULL default 0,
- user_id int NOT NULL default 0,
- rating mediumint NOT NULL default 0,
- PRIMARY KEY ( rating_id )
- )" . $charset_clause . " COMMENT = 'Table with ratings for post/comments in a certain blog';";
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_blogs_rel_user . "` (
- blog_id int NOT NULL default 0,
- user_id int NOT NULL default 0,
- PRIMARY KEY ( blog_id , user_id )
- )" . $charset_clause . " COMMENT = 'Table representing users subscribed to a blog';";
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_blogs_tasks . "` (
- task_id mediumint NOT NULL AUTO_INCREMENT ,
- blog_id mediumint NOT NULL default 0,
- title varchar( 250 ) NOT NULL default '',
- description text NOT NULL ,
- color varchar( 10 ) NOT NULL default '',
- system_task tinyint unsigned NOT NULL default 0,
- PRIMARY KEY ( task_id )
- )" . $charset_clause . " COMMENT = 'Table with tasks for a blog';";
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_blogs_tasks_rel_user . "` (
- blog_id mediumint NOT NULL default 0,
- user_id int NOT NULL default 0,
- task_id mediumint NOT NULL default 0,
- target_date date NOT NULL default '0000-00-00',
- PRIMARY KEY ( blog_id , user_id , task_id )
- )" . $charset_clause . " COMMENT = 'Table with tasks assigned to a user in a blog';";
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql ="CREATE TABLE `" .$tbl_blogs_attachment."` (
- id int unsigned NOT NULL auto_increment,
- path varchar(255) NOT NULL COMMENT 'the real filename',
- comment text,
- size int NOT NULL default '0',
- post_id int NOT NULL,
- filename varchar(255) NOT NULL COMMENT 'the user s file name',
- blog_id int NOT NULL,
- comment_id int NOT NULL default '0',
- PRIMARY KEY (id)
- )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_permission_group . "` (
- id int NOT NULL AUTO_INCREMENT ,
- group_id int NOT NULL default 0,
- tool varchar( 250 ) NOT NULL default '',
- action varchar( 250 ) NOT NULL default '',
- PRIMARY KEY (id)
- )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_permission_user . "` (
- id int NOT NULL AUTO_INCREMENT ,
- user_id int NOT NULL default 0,
- tool varchar( 250 ) NOT NULL default '',
- action varchar( 250 ) NOT NULL default '',
- PRIMARY KEY ( id )
- )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_permission_task . "` (
- id int NOT NULL AUTO_INCREMENT ,
- task_id int NOT NULL default 0,
- tool varchar( 250 ) NOT NULL default '',
- action varchar( 250 ) NOT NULL default '',
- PRIMARY KEY ( id )
- )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_role . "` (
- role_id int NOT NULL AUTO_INCREMENT ,
- role_name varchar( 250 ) NOT NULL default '',
- role_comment text,
- default_role tinyint default 0,
- PRIMARY KEY ( role_id )
- )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_role_group . "` (
- role_id int NOT NULL default 0,
- scope varchar( 20 ) NOT NULL default 'course',
- group_id int NOT NULL default 0
- )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_role_permissions . "` (
- role_id int NOT NULL default 0,
- tool varchar( 250 ) NOT NULL default '',
- action varchar( 50 ) NOT NULL default '',
- default_perm tinyint NOT NULL default 0
- )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
- $sql = "
- CREATE TABLE `" . $tbl_role_user . "` (
- role_id int NOT NULL default 0,
- scope varchar( 20 ) NOT NULL default 'course',
- user_id int NOT NULL default 0
- )" . $charset_clause;
- if(!Database::query($sql))
- {
- error_log($sql, 0);
- }
-
-
- Database::query("
- CREATE TABLE `".$TABLESETTING . "` (
- id int unsigned NOT NULL auto_increment,
- variable varchar(255) NOT NULL default '',
- subkey varchar(255) default NULL,
- type varchar(255) default NULL,
- category varchar(255) default NULL,
- value varchar(255) NOT NULL default '',
- title varchar(255) NOT NULL default '',
- comment varchar(255) default NULL,
- subkeytext varchar(255) default NULL,
- PRIMARY KEY (id)
- )" . $charset_clause);
-
- $sql = "CREATE TABLE `".$TABLESURVEY."` (
- survey_id int unsigned NOT NULL auto_increment,
- code varchar(20) default NULL,
- title text default NULL,
- subtitle text default NULL,
- author varchar(20) default NULL,
- lang varchar(20) default NULL,
- avail_from date default NULL,
- avail_till date default NULL,
- is_shared char(1) default '1',
- template varchar(20) default NULL,
- intro text,
- surveythanks text,
- creation_date datetime NOT NULL default '0000-00-00 00:00:00',
- invited int NOT NULL,
- answered int NOT NULL,
- invite_mail text NOT NULL,
- reminder_mail text NOT NULL,
- mail_subject VARCHAR( 255 ) NOT NULL,
- anonymous enum('0','1') NOT NULL default '0',
- access_condition TEXT DEFAULT NULL,
- shuffle bool NOT NULL default '0',
- one_question_per_page bool NOT NULL default '0',
- survey_version varchar(255) NOT NULL default '',
- parent_id int unsigned NOT NULL,
- survey_type int NOT NULL default 0,
- show_form_profile int NOT NULL default 0,
- form_fields TEXT NOT NULL,
- session_id SMALLINT unsigned NOT NULL default 0,
- PRIMARY KEY (survey_id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TABLESURVEY."` ADD INDEX ( session_id )";
- Database::query($sql);
- $sql = "CREATE TABLE `".$TABLESURVEYINVITATION."` (
- survey_invitation_id int unsigned NOT NULL auto_increment,
- survey_code varchar(20) NOT NULL,
- user varchar(250) NOT NULL,
- invitation_code varchar(250) NOT NULL,
- invitation_date datetime NOT NULL,
- reminder_date datetime NOT NULL,
- answered int NOT NULL default 0,
- session_id SMALLINT(5) UNSIGNED NOT NULL default 0,
- PRIMARY KEY (survey_invitation_id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "CREATE TABLE `".$TABLESURVEYQUESTION."` (
- question_id int unsigned NOT NULL auto_increment,
- survey_id int unsigned NOT NULL,
- survey_question text NOT NULL,
- survey_question_comment text NOT NULL,
- type varchar(250) NOT NULL,
- display varchar(10) NOT NULL,
- sort int NOT NULL,
- shared_question_id int,
- max_value int,
- survey_group_pri int unsigned NOT NULL default '0',
- survey_group_sec1 int unsigned NOT NULL default '0',
- survey_group_sec2 int unsigned NOT NULL default '0',
- PRIMARY KEY (question_id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql ="CREATE TABLE `".$TABLESURVEYQUESTIONOPTION."` (
- question_option_id int unsigned NOT NULL auto_increment,
- question_id int unsigned NOT NULL,
- survey_id int unsigned NOT NULL,
- option_text text NOT NULL,
- sort int NOT NULL,
- value int NOT NULL default '0',
- PRIMARY KEY (question_option_id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "CREATE TABLE `".$TABLESURVEYANSWER."` (
- answer_id int unsigned NOT NULL auto_increment,
- survey_id int unsigned NOT NULL,
- question_id int unsigned NOT NULL,
- option_id TEXT NOT NULL,
- value int unsigned NOT NULL,
- user varchar(250) NOT NULL,
- PRIMARY KEY (answer_id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "CREATE TABLE `".$TABLESURVEYGROUP."` (
- id int unsigned NOT NULL auto_increment,
- name varchar(20) NOT NULL,
- description varchar(255) NOT NULL,
- survey_id int unsigned NOT NULL,
- PRIMARY KEY (id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
-
- $sql = "CREATE TABLE `".$TBL_GLOSSARY."` (
- glossary_id int unsigned NOT NULL auto_increment,
- name varchar(255) NOT NULL,
- description text not null,
- display_order int,
- session_id smallint default 0,
- PRIMARY KEY (glossary_id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TBL_GLOSSARY . "` ADD INDEX ( session_id ) ";
- Database::query($sql);
-
- $sql = "CREATE TABLE `".$TBL_NOTEBOOK."` (
- notebook_id int unsigned NOT NULL auto_increment,
- user_id int unsigned NOT NULL,
- course varchar(40) not null,
- session_id int NOT NULL default 0,
- title varchar(255) NOT NULL,
- description text NOT NULL,
- creation_date datetime NOT NULL default '0000-00-00 00:00:00',
- update_date datetime NOT NULL default '0000-00-00 00:00:00',
- status int,
- PRIMARY KEY (notebook_id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
-
-
- $sql = "
- CREATE TABLE `".$TBL_ATTENDANCE."` (
- id int NOT NULL auto_increment PRIMARY KEY,
- name text NOT NULL,
- description TEXT NULL,
- active tinyint NOT NULL default 1,
- attendance_qualify_title varchar(255) NULL,
- attendance_qualify_max int NOT NULL default 0,
- attendance_weight float(6,2) NOT NULL default '0.0',
- session_id int NOT NULL default 0
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TBL_ATTENDANCE . "` ADD INDEX (session_id)";
- Database::query($sql);
- $sql = "ALTER TABLE `".$TBL_ATTENDANCE . "` ADD INDEX (active)";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TBL_ATTENDANCE_SHEET."` (
- user_id int NOT NULL,
- attendance_calendar_id int NOT NULL,
- presence tinyint NOT NULL DEFAULT 0,
- PRIMARY KEY(user_id, attendance_calendar_id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TBL_ATTENDANCE_SHEET . "` ADD INDEX (presence) ";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TBL_ATTENDANCE_CALENDAR."` (
- id int NOT NULL auto_increment,
- attendance_id int NOT NULL ,
- date_time datetime NOT NULL default '0000-00-00 00:00:00',
- done_attendance tinyint NOT NULL default 0,
- PRIMARY KEY(id)
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TBL_ATTENDANCE_CALENDAR."` ADD INDEX (attendance_id)";
- Database::query($sql);
- $sql = "ALTER TABLE `".$TBL_ATTENDANCE_CALENDAR."` ADD INDEX (done_attendance)";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TBL_ATTENDANCE_RESULT."` (
- id int NOT NULL auto_increment PRIMARY KEY,
- user_id int NOT NULL,
- attendance_id int NOT NULL,
- score int NOT NULL DEFAULT 0
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TBL_ATTENDANCE_RESULT."` ADD INDEX (attendance_id)";
- Database::query($sql);
- $sql = "ALTER TABLE `".$TBL_ATTENDANCE_RESULT."` ADD INDEX (user_id)";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TBL_THEMATIC."` (
- id int NOT NULL auto_increment PRIMARY KEY,
- title varchar(255) NOT NULL,
- content text NULL,
- display_order int unsigned NOT NULL DEFAULT 0,
- active tinyint NOT NULL DEFAULT 0,
- session_id int NOT NULL DEFAULT 0
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TBL_THEMATIC."` ADD INDEX (active, session_id)";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TBL_THEMATIC_PLAN."` (
- id int NOT NULL auto_increment PRIMARY KEY,
- thematic_id int NOT NULL,
- title varchar(255) NOT NULL,
- description text NULL,
- description_type int NOT NULL
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TBL_THEMATIC_PLAN."` ADD INDEX (thematic_id, description_type)";
- Database::query($sql);
-
- $sql = "
- CREATE TABLE `".$TBL_THEMATIC_ADVANCE."` (
- id int NOT NULL auto_increment PRIMARY KEY,
- thematic_id int NOT NULL,
- attendance_id int NOT NULL DEFAULT 0,
- content text NULL,
- start_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
- duration int NOT NULL DEFAULT 0,
- done_advance tinyint NOT NULL DEFAULT 0
- )" . $charset_clause;
- $result = Database::query($sql) or die(Database::error());
- $sql = "ALTER TABLE `".$TBL_THEMATIC_ADVANCE."` ADD INDEX (thematic_id)";
- Database::query($sql);
- return 0;
- }
- function browse_folders($path, $files, $media)
- {
- if($media=='images')
- {
- $code_path = api_get_path(SYS_CODE_PATH)."default_course_document/images/";
- }
- if($media=='audio')
- {
- $code_path = api_get_path(SYS_CODE_PATH)."default_course_document/audio/";
- }
- if($media=='flash')
- {
- $code_path = api_get_path(SYS_CODE_PATH)."default_course_document/flash/";
- }
- if($media=='video')
- {
- $code_path = api_get_path(SYS_CODE_PATH)."default_course_document/video/";
- }
- if(is_dir($path))
- {
- $handle = opendir($path);
- while (false !== ($file = readdir($handle)))
- {
- if(is_dir($path.$file) && strpos($file,'.')!==0)
- {
- $files[]["dir"] = str_replace($code_path,"",$path.$file."/");
- $files = browse_folders($path.$file."/",$files,$media);
- }
- elseif(is_file($path.$file) && strpos($file,'.')!==0)
- {
- $files[]["file"] = str_replace($code_path,"",$path.$file);
- }
- }
- }
- return $files;
- }
- function sort_pictures($files,$type)
- {
- $pictures=array();
- foreach($files as $key => $value){
- if($value[$type]!=""){
- $pictures[][$type]=$value[$type];
- }
- }
- return $pictures;
- }
- function fill_course_repository($courseRepository)
- {
- $sys_course_path = api_get_path(SYS_COURSE_PATH);
- $web_code_path = api_get_path(WEB_CODE_PATH);
- $perm = api_get_permissions_for_new_directories();
- $perm_file = api_get_permissions_for_new_files();
-
- $default_document_array=array();
- if(api_get_setting('example_material_course_creation')<>'false')
- {
- $img_code_path = api_get_path(SYS_CODE_PATH)."default_course_document/images/";
- $audio_code_path = api_get_path(SYS_CODE_PATH)."default_course_document/audio/";
- $flash_code_path = api_get_path(SYS_CODE_PATH)."default_course_document/flash/";
- $video_code_path = api_get_path(SYS_CODE_PATH)."default_course_document/video/";
- $course_documents_folder_images=$sys_course_path.$courseRepository.'/document/images/gallery/';
- $course_documents_folder_audio=$sys_course_path.$courseRepository.'/document/audio/';
- $course_documents_folder_flash=$sys_course_path.$courseRepository.'/document/flash/';
- $course_documents_folder_video=$sys_course_path.$courseRepository.'/document/video/';
-
- $files=array();
- $files=browse_folders($img_code_path,$files,'images');
- $pictures_array = sort_pictures($files,"dir");
- $pictures_array = array_merge($pictures_array,sort_pictures($files,"file"));
- if(!is_dir($course_documents_folder_images))
- {
- mkdir($course_documents_folder_images,$perm);
- }
- $handle = opendir($img_code_path);
- foreach($pictures_array as $key => $value)
- {
- if($value["dir"]!="")
- {
- mkdir($course_documents_folder_images.$value["dir"],$perm);
- }
- if($value["file"]!="")
- {
- copy($img_code_path.$value["file"],$course_documents_folder_images.$value["file"]);
- chmod($course_documents_folder_images.$value["file"],$perm_file);
- }
- }
-
- $path_thumb=mkdir($course_documents_folder_images.'trainer/.thumbs',$perm);
- $handle = opendir($img_code_path.'trainer/.thumbs/');
- while (false !== ($file = readdir($handle)))
- {
- if (is_file($img_code_path.'trainer/.thumbs/'.$file))
- {
- copy($img_code_path.'trainer/.thumbs/'.$file,$course_documents_folder_images.'trainer/.thumbs/'.$file);
- chmod($course_documents_folder_images.'trainer/.thumbs/'.$file,$perm_file);
- }
- }
- $default_document_array['images']=$pictures_array;
-
- $files=array();
- $files=browse_folders($audio_code_path,$files,'audio');
- $audio_array = sort_pictures($files,"dir");
- $audio_array = array_merge($audio_array,sort_pictures($files,"file"));
- if(!is_dir($course_documents_folder_audio))
- {
- mkdir($course_documents_folder_audio,$perm);
- }
- $handle = opendir($audio_code_path);
- foreach($audio_array as $key => $value){
- if($value["dir"]!=""){
- mkdir($course_documents_folder_audio.$value["dir"],$perm);
- }
- if($value["file"]!=""){
- copy($audio_code_path.$value["file"],$course_documents_folder_audio.$value["file"]);
- chmod($course_documents_folder_audio.$value["file"],$perm_file);
- }
- }
- $default_document_array['audio']=$audio_array;
-
- $files=array();
- $files=browse_folders($flash_code_path,$files,'flash');
- $flash_array = sort_pictures($files,"dir");
- $flash_array = array_merge($flash_array,sort_pictures($files,"file"));
- if(!is_dir($course_documents_folder_flash))
- {
- mkdir($course_documents_folder_flash,$perm);
- }
- $handle = opendir($flash_code_path);
- foreach($flash_array as $key => $value){
- if($value["dir"]!=""){
- mkdir($course_documents_folder_flash.$value["dir"],$perm);
- }
- if($value["file"]!=""){
- copy($flash_code_path.$value["file"],$course_documents_folder_flash.$value["file"]);
- chmod($course_documents_folder_flash.$value["file"],$perm_file);
- }
- }
- $default_document_array['flash']=$flash_array;
-
- $files=array();
- $files=browse_folders($video_code_path,$files,'video');
- $video_array = sort_pictures($files,"dir");
- $video_array = array_merge($video_array,sort_pictures($files,"file"));
- if(!is_dir($course_documents_folder_video))
- {
- mkdir($course_documents_folder_video,$perm);
- }
- $handle = opendir($video_code_path);
- foreach($video_array as $key => $value){
- if($value["dir"]!=""){
- @mkdir($course_documents_folder_video.$value["dir"],$perm);
- }
- if($value["file"]!=""){
- copy($video_code_path.$value["file"],$course_documents_folder_video.$value["file"]);
- chmod($course_documents_folder_video.$value["file"],$perm_file);
- }
- }
- $default_document_array['video']=$video_array;
- }
- return $default_document_array;
- }
- function lang2db($string)
- {
- $string = str_replace("\\'", "'", $string);
- $string = Database::escape_string($string);
- return $string;
- }
- function fill_Db_course($courseDbName, $courseRepository, $language,$default_document_array = array())
- {
- global $_configuration, $clarolineRepositoryWeb, $_user;
- $courseDbName = $_configuration['table_prefix'].$courseDbName.$_configuration['db_glue'];
- $tbl_course_homepage = $courseDbName . "tool";
- $TABLEINTROS = $courseDbName . "tool_intro";
- $TABLEGROUPS = $courseDbName . "group_info";
- $TABLEGROUPCATEGORIES = $courseDbName . "group_category";
- $TABLEGROUPUSER = $courseDbName . "group_rel_user";
- $TABLEITEMPROPERTY = $courseDbName . "item_property";
- $TABLETOOLCOURSEDESC = $courseDbName . "course_description";
- $TABLETOOLAGENDA = $courseDbName . "calendar_event";
- $TABLETOOLANNOUNCEMENTS = $courseDbName . "announcement";
- $TABLEADDEDRESOURCES = $courseDbName . "resource";
- $TABLETOOLWORKS = $courseDbName . "student_publication";
- $TABLETOOLWORKSUSER = $courseDbName . "stud_pub_rel_user";
- $TABLETOOLDOCUMENT = $courseDbName . "document";
- $TABLETOOLWIKI = $courseDbName . "wiki";
- $TABLETOOLLINK = $courseDbName . "link";
- $TABLEQUIZ = $courseDbName . "quiz";
- $TABLEQUIZQUESTION = $courseDbName . "quiz_rel_question";
- $TABLEQUIZQUESTIONLIST = $courseDbName . "quiz_question";
- $TABLEQUIZANSWERSLIST = $courseDbName . "quiz_answer";
- $TABLESETTING = $courseDbName . "course_setting";
- $TABLEFORUMCATEGORIES = $courseDbName . "forum_category";
- $TABLEFORUMS = $courseDbName . "forum_forum";
- $TABLEFORUMTHREADS = $courseDbName . "forum_thread";
- $TABLEFORUMPOSTS = $courseDbName . "forum_post";
- $nom = $_user['lastName'];
- $prenom = $_user['firstName'];
- include (api_get_path(SYS_CODE_PATH) . "lang/english/create_course.inc.php");
- $file_to_include = "lang/".$language . "/create_course.inc.php";
- if (file_exists($file_to_include)) {
- include (api_get_path(SYS_CODE_PATH) . $file_to_include);
- }
- Database::select_db("$courseDbName");
-
- $visible4all = 1;
- $visible4AdminOfCourse = 0;
- $visible4AdminOfClaroline = 2;
-
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_COURSE_DESCRIPTION . "','course_description/','info.gif','".string2binary(api_get_setting('course_create_active_tools', 'course_description')) . "','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_CALENDAR_EVENT . "','calendar/agenda.php','agenda.gif','".string2binary(api_get_setting('course_create_active_tools', 'agenda')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_DOCUMENT . "','document/document.php','folder_document.gif','".string2binary(api_get_setting('course_create_active_tools', 'documents')) . "','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_LEARNPATH . "','newscorm/lp_controller.php','scorm.gif','".string2binary(api_get_setting('course_create_active_tools', 'learning_path')) . "','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_LINK . "','link/link.php','links.gif','".string2binary(api_get_setting('course_create_active_tools', 'links')) . "','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_QUIZ . "','exercice/exercice.php','quiz.gif','".string2binary(api_get_setting('course_create_active_tools', 'quiz')) . "','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_ANNOUNCEMENT . "','announcements/announcements.php','valves.gif','".string2binary(api_get_setting('course_create_active_tools', 'announcements')) . "','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_FORUM . "','forum/index.php','forum.gif','".string2binary(api_get_setting('course_create_active_tools', 'forums')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_DROPBOX . "','dropbox/index.php','dropbox.gif','".string2binary(api_get_setting('course_create_active_tools', 'dropbox')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_USER . "','user/user.php','members.gif','".string2binary(api_get_setting('course_create_active_tools', 'users')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GROUP . "','group/group.php','group.gif','".string2binary(api_get_setting('course_create_active_tools', 'groups')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_CHAT . "','chat/chat.php','chat.gif','".string2binary(api_get_setting('course_create_active_tools', 'chat')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_STUDENTPUBLICATION . "','work/work.php','works.gif','".string2binary(api_get_setting('course_create_active_tools', 'student_publications')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_SURVEY."','survey/survey_list.php','survey.gif','".string2binary(api_get_setting('course_create_active_tools', 'survey')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_WIKI ."','wiki/index.php','wiki.gif','".string2binary(api_get_setting('course_create_active_tools', 'wiki')) . "','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'gradebook')). "','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".string2binary(api_get_setting('course_create_active_tools', 'glossary')). "','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_NOTEBOOK."','notebook/index.php','notebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'notebook'))."','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_ATTENDANCE."','attendance/index.php','attendance.gif','".string2binary(api_get_setting('course_create_active_tools', 'attendances'))."','0','squaregrey.gif','NO','_self','authoring','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_COURSE_PROGRESS."','course_progress/index.php','course_progress.gif','".string2binary(api_get_setting('course_create_active_tools', 'course_progress'))."','0','squaregrey.gif','NO','_self','authoring','0')");
- if(api_get_setting('service_visio','active')=='true')
- {
- $mycheck = api_get_setting('service_visio','visio_host');
- if(!empty($mycheck))
- {
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_VISIO_CONFERENCE . "','conference/index.php?type=conference','visio_meeting.gif','1','0','squaregrey.gif','NO','_self','interaction','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_VISIO_CLASSROOM . "','conference/index.php?type=classroom','visio.gif','1','0','squaregrey.gif','NO','_self','authoring','0')");
- }
- }
- if (api_get_setting('search_enabled')=='true') {
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_SEARCH. "','search/','info.gif','".string2binary(api_get_setting('course_create_active_tools', 'enable_search')) . "','0','search.gif','NO','_self','authoring','0')");
- }
-
- $sql = "INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL,'" . TOOL_BLOGS . "','blog/blog_admin.php','blog_admin.gif','" . string2binary(api_get_setting('course_create_active_tools', 'blogs')) . "','1','squaregrey.gif','NO','_self','admin','0')";
- Database::query($sql);
-
-
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_TRACKING . "','tracking/courseLog.php','statistics.gif','$visible4AdminOfCourse','1','', 'NO','_self','admin','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_COURSE_SETTING . "','course_info/infocours.php','reference.gif','$visible4AdminOfCourse','1','', 'NO','_self','admin','0')");
- Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL,'".TOOL_COURSE_MAINTENANCE."','course_info/maintenance.php','backup.gif','$visible4AdminOfCourse','1','','NO','_self', 'admin','0')");
-
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_manager_on_new_doc',0,'work')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_on_new_doc_dropbox',0,'dropbox')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_edit_agenda',0,'agenda')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_edit_announcement',0,'announcement')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_manager_on_new_quiz',0,'quiz')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_image_forum',1,'forum')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('course_theme','','theme')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_learning_path_theme','1','theme')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_open_chat_window',1,'chat')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_to_teacher_on_new_user_in_course',0,'registration')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_view_user_list',1,'user')");
- Database::query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('display_info_advance_inside_homecourse',1,'thematic_advance')");
- Database::query("INSERT INTO `".$TABLESETTING . "` (variable,value,category) VALUES ('email_alert_students_on_new_homework',0,'work')");
-
-
- Database::query("INSERT INTO `".$TABLEGROUPCATEGORIES . "` ( id , title , description , max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order ) VALUES ('2', '".lang2db(get_lang('DefaultGroupCategory')) . "', '', '8', '0', '0', '0', '0');");
-
- global $language_interface;
-
- $language_interface_tmp=$language_interface;
- $language_interface=$language;
-
-
-
-
-
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('/images','".get_lang('Images')."','folder','0')");
- $example_doc_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('/images/gallery','".get_lang('DefaultCourseImages')."','folder','0')");
- $example_doc_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('/shared_folder','".get_lang('SharedDocumentsDirectory')."','folder','0')");
- $example_doc_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('/audio','".get_lang('Audio')."','folder','0')");
- $example_doc_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('/flash','".get_lang('Flash')."','folder','0')");
- $example_doc_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('/video','".get_lang('Video')."','folder','0')");
- $example_doc_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('/chat_files','chat_files','folder','0')");
- $example_doc_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
-
- $sys_course_path = api_get_path(SYS_COURSE_PATH);
- foreach($default_document_array as $media_type=>$array_media)
- {
- if($media_type=='images')
- {
- $path_documents='/images/gallery/';
- $course_documents_folder=$sys_course_path.$courseRepository.'/document/images/gallery/';
- }
- if($media_type=='audio')
- {
- $path_documents='/audio/';
- $course_documents_folder=$sys_course_path.$courseRepository.'/document/audio/';
- }
- if($media_type=='flash')
- {
- $path_documents='/flash/';
- $course_documents_folder=$sys_course_path.$courseRepository.'/document/flash/';
- }
- if($media_type=='video')
- {
- $path_documents='/video/';
- $course_documents_folder=$sys_course_path.$courseRepository.'/document/video/';
- }
- foreach($array_media as $key => $value)
- {
- if($value["dir"]!="")
- {
- $folder_path=substr($value["dir"],0,strlen($value["dir"])-1);
- $temp=explode("/",$folder_path);
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('$path_documents".$folder_path."','".$temp[count($temp)-1]."','folder','0')");
- $image_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$image_id,'DocumentAdded',1,0,NULL,0)");
- }
- if($value["file"]!="")
- {
- $temp=explode("/",$value["file"]);
- $file_size=filesize($course_documents_folder.$value["file"]);
- Database::query("INSERT INTO `".$TABLETOOLDOCUMENT . "`(path,title,filetype,size) VALUES ('$path_documents".$value["file"]."','".$temp[count($temp)-1]."','file','$file_size')");
- $image_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$image_id,'DocumentAdded',1,0,NULL,1)");
- }
- }
- }
- if(api_get_setting('example_material_course_creation')<>'false')
- {
-
- Database::query("INSERT INTO `".$TABLETOOLAGENDA . "` VALUES ( NULL, '".lang2db(get_lang('AgendaCreationTitle')) . "', '".lang2db(get_lang('AgendaCreationContenu')) . "', now(), now(), NULL, 0)");
-
- $insert_id = Database :: insert_id();
- $sql = "INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('" . TOOL_CALENDAR_EVENT . "',1,NOW(),NOW(),$insert_id,'AgendaAdded',1,0,NULL,1)";
- Database::query($sql);
-
- $add_google_link_sql = " INSERT INTO `".$TABLETOOLLINK . "` (url, title, description, category_id, display_order, on_homepage, target)
- VALUES ('http://www.google.com','Google','".lang2db(get_lang('Google')) . "','0','0','0','_self')";
- Database::query($add_google_link_sql);
-
- $insert_id = Database :: insert_id();
- $sql = "INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('" . TOOL_LINK . "',1,NOW(),NOW(),$insert_id,'LinkAdded',1,0,NULL,1)";
- Database::query($sql);
- $add_wikipedia_link_sql = " INSERT INTO `".$TABLETOOLLINK . "` (url, title, description, category_id, display_order, on_homepage, target)
- VALUES ('http://www.wikipedia.org','Wikipedia','".lang2db(get_lang('Wikipedia')) . "','0','1','0','_self')";
- Database::query($add_wikipedia_link_sql);
-
- $insert_id = Database :: insert_id();
- $sql = "INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('" . TOOL_LINK . "',1,NOW(),NOW(),$insert_id,'LinkAdded',1,0,NULL,1)";
- Database::query($sql);
-
- $sql = "INSERT INTO `".$TABLETOOLANNOUNCEMENTS . "` (title,content,end_date,display_order,email_sent) VALUES ('".lang2db(get_lang('AnnouncementExampleTitle')) . "', '".lang2db(get_lang('AnnouncementEx')) . "', NOW(), '1','0')";
- Database::query($sql);
-
- $insert_id = Database :: insert_id();
- $sql = "INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('" . TOOL_ANNOUNCEMENT . "',1,NOW(),NOW(),$insert_id,'AnnouncementAdded',1,0,NULL,1)";
- Database::query($sql);
-
- $intro_text='<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="middle" align="left"><img src="'.api_get_path(REL_CODE_PATH).'img/mascot.png" alt="Mr. Chamilo" title="Mr. Chamilo" /></td><td valign="middle" align="left">'.lang2db(get_lang('IntroductionText')).'</td></tr></table>';
- Database::query("INSERT INTO `".$TABLEINTROS . "` VALUES ('" . TOOL_COURSE_HOMEPAGE . "','".$intro_text. "', 0)");
- Database::query("INSERT INTO `".$TABLEINTROS . "` VALUES ('" . TOOL_STUDENTPUBLICATION . "','".lang2db(get_lang('IntroductionTwo')) . "', 0)");
-
- $intro_wiki='<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="top" align="left"></td><td valign="top" align="left">'.lang2db(get_lang('IntroductionWiki')).'</td></tr></table>';
- Database::query("INSERT INTO `".$TABLEINTROS . "` VALUES ('" . TOOL_WIKI . "','".$intro_wiki. "', 0)");
-
- Database::query("INSERT INTO `".$TABLEQUIZANSWERSLIST . "` VALUES ( '1', '1', '".lang2db(get_lang('Ridiculise')) . "', '0', '".lang2db(get_lang('NoPsychology')) . "', '-5', '1','','','','')");
- Database::query("INSERT INTO `".$TABLEQUIZANSWERSLIST . "` VALUES ( '2', '1', '".lang2db(get_lang('AdmitError')) . "', '0', '".lang2db(get_lang('NoSeduction')) . "', '-5', '2','','','','')");
- Database::query("INSERT INTO `".$TABLEQUIZANSWERSLIST . "` VALUES ( '3', '1', '".lang2db(get_lang('Force')) . "', '1', '".lang2db(get_lang('Indeed')) . "', '5', '3','','','','')");
- Database::query("INSERT INTO `".$TABLEQUIZANSWERSLIST . "` VALUES ( '4', '1', '".lang2db(get_lang('Contradiction')) . "', '1', '".lang2db(get_lang('NotFalse')) . "', '5', '4','','','','')");
- $html=Database::escape_string('<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="top" align="left"><img src="'.api_get_path(WEB_CODE_PATH).'default_course_document/images/mr_dokeos/thinking.jpg"></td><td valign="top" align="left">'.get_lang('Antique').'</td></tr></table>');
- Database::query('INSERT INTO `'.$TABLEQUIZ . '` (title, description, type, random, random_answers, active, results_disabled ) VALUES ("'.lang2db(get_lang('ExerciceEx')) . '", "'.$html.'", "1", "0", "0", "1", "0")');
- Database::query("INSERT INTO `".$TABLEQUIZQUESTIONLIST . "` (id, question, description, ponderation, position, type, picture, level) VALUES ( '1', '".lang2db(get_lang('SocraticIrony')) . "', '".lang2db(get_lang('ManyAnswers')) . "', '10', '1', '2','',1)");
- Database::query("INSERT INTO `".$TABLEQUIZQUESTION . "` (question_id, exercice_id, question_order) VALUES (1,1,1)");
-
- Database::query("INSERT INTO `$TABLEFORUMCATEGORIES` VALUES (1,'".lang2db(get_lang('ExampleForumCategory'))."', '', 1, 0, 0)");
- $insert_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('forum_category',1,NOW(),NOW(),$insert_id,'ForumCategoryAdded',1,0,NULL,1)");
- Database::query("INSERT INTO `$TABLEFORUMS` (forum_title, forum_comment, forum_threads,forum_posts,forum_last_post,forum_category, allow_anonymous, allow_edit,allow_attachments, allow_new_threads,default_view,forum_of_group,forum_group_public_private, forum_order,locked,session_id ) VALUES ('".lang2db(get_lang('ExampleForum'))."', '', 0, 0, 0, 1, 0, 1, '0', 1, 'flat','0', 'public', 1, 0,0)");
- $insert_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('" . TOOL_FORUM . "',1,NOW(),NOW(),$insert_id,'ForumAdded',1,0,NULL,1)");
- Database::query("INSERT INTO `$TABLEFORUMTHREADS` (thread_id, thread_title, forum_id, thread_replies, thread_poster_id, thread_poster_name, thread_views, thread_last_post, thread_date, locked, thread_qualify_max) VALUES (1, '".lang2db(get_lang('ExampleThread'))."', 1, 0, 1, '', 0, 1, NOW(), 0, 10)");
- $insert_id = Database :: insert_id();
- Database::query("INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('forum_thread',1,NOW(),NOW(),$insert_id,'ForumThreadAdded',1,0,NULL,1)");
- Database::query("INSERT INTO `$TABLEFORUMPOSTS` VALUES (1, '".lang2db(get_lang('ExampleThread'))."', '".lang2db(get_lang('ExampleThreadContent'))."', 1, 1, 1, '', NOW(), 0, 0, 1)");
- }
- $language_interface=$language_interface_tmp;
- return 0;
- };
- function string2binary($variable)
- {
- if($variable == "true")
- {
- return true;
- }
- if($variable == "false")
- {
- return false;
- }
- }
- function register_course($courseSysCode, $courseScreenCode, $courseRepository, $courseDbName, $titular, $category, $title, $course_language, $uidCreator, $expiration_date = "", $teachers=array(), $visibility = null)
- {
- global $defaultVisibilityForANewCourse, $error_msg;
- $TABLECOURSE = Database :: get_main_table(TABLE_MAIN_COURSE);
- $TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
- $TABLEANNOUNCEMENTS = Database :: get_course_table(TABLE_ANNOUNCEMENT,$courseDbName);
- $okForRegisterCourse = true;
-
- if (empty($courseSysCode)) {
- $error_msg[] = "courseSysCode is missing";
- $okForRegisterCourse = false;
- }
- if (empty($courseScreenCode)) {
- $error_msg[] = "courseScreenCode is missing";
- $okForRegisterCourse = false;
- }
- if (empty($courseDbName)) {
- $error_msg[] = "courseDbName is missing";
- $okForRegisterCourse = false;
- }
- if (empty($courseRepository)) {
- $error_msg[] = "courseRepository is missing";
- $okForRegisterCourse = false;
- }
- if (empty($titular)) {
- $error_msg[] = "titular is missing";
- $okForRegisterCourse = false;
- }
- if (empty($title)) {
- $error_msg[] = "title is missing";
- $okForRegisterCourse = false;
- }
- if (empty($course_language)) {
- $error_msg[] = "language is missing";
- $okForRegisterCourse = false;
- }
- if (empty($expiration_date)) {
- $expiration_date = "NULL";
- } else {
- $expiration_date = "FROM_UNIXTIME(".$expiration_date . ")";
- }
- if($visibility === null) {
- $visibility = $defaultVisibilityForANewCourse;
- } else {
- if($visibility < 0 || $visibility > 3) {
- $error_msg[] = "visibility is invalid";
- $okForRegisterCourse = false;
- }
- }
- if ($okForRegisterCourse) {
- $titular=addslashes($titular);
-
- $sql = "INSERT INTO ".$TABLECOURSE . " SET
- code = '".Database :: escape_string($courseSysCode) . "',
- db_name = '".Database :: escape_string($courseDbName) . "',
- directory = '".Database :: escape_string($courseRepository) . "',
- course_language = '".Database :: escape_string($course_language) . "',
- title = '".Database :: escape_string($title) . "',
- description = '".lang2db(get_lang('CourseDescription')) . "',
- category_code = '".Database :: escape_string($category) . "',
- visibility = '".$visibility . "',
- show_score = '',
- disk_quota = '".api_get_setting('default_document_quotum') . "',
- creation_date = now(),
- expiration_date = ".$expiration_date . ",
- last_edit = now(),
- last_visit = NULL,
- tutor_name = '".Database :: escape_string($titular) . "',
- visual_code = '".Database :: escape_string($courseScreenCode) . "'";
- Database::query($sql);
- $sort = api_max_sort_value('0', api_get_user_id());
- require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
- $i_course_sort = CourseManager :: userCourseSort($uidCreator,$courseSysCode);
- $sql = "INSERT INTO ".$TABLECOURSUSER . " SET
- course_code = '".addslashes($courseSysCode) . "',
- user_id = '".Database::escape_string($uidCreator) . "',
- status = '1',
- role = '".lang2db(get_lang('Professor')) . "',
- tutor_id='0',
- sort='". ($i_course_sort) . "',
- user_course_cat='0'";
- Database::query($sql);
- if (count($teachers)>0) {
- foreach ($teachers as $key) {
- $sql = "INSERT INTO ".$TABLECOURSUSER . " SET
- course_code = '".Database::escape_string($courseSysCode) . "',
- user_id = '".Database::escape_string($key) . "',
- status = '1',
- role = '',
- tutor_id='0',
- sort='". ($sort +1) . "',
- user_course_cat='0'";
- Database::query($sql);
- }
- }
-
- global $_configuration;
- require_once (api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
- if ($_configuration['multiple_access_urls']) {
- $url_id=1;
- if (api_get_current_access_url_id()!=-1) {
- $url_id=api_get_current_access_url_id();
- }
- UrlManager::add_course_to_url($courseSysCode,$url_id);
- } else {
- UrlManager::add_course_to_url($courseSysCode,1);
- }
-
- $time = time();
- $user_id = api_get_user_id();
- event_system(LOG_COURSE_CREATE, LOG_COURSE_CODE, $courseSysCode, $time, $user_id, $courseSysCode);
- $send_mail_to_admin = api_get_setting('send_email_to_admin_when_create_course');
-
- if ($send_mail_to_admin=='true'){
- $siteName=api_get_setting('siteName');
- $recipient_email = api_get_setting('emailAdministrator');
- $recipient_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'));
- $urlsite = api_get_path(WEB_PATH);
- $iname = api_get_setting('Institution');
- $subject=get_lang('NewCourseCreatedIn').' '.$siteName.' - '.$iname;
- $message = get_lang('Dear').' '.$recipient_name.",\n\n".get_lang('MessageOfNewCourseToAdmin').' '.$siteName.' - '.$iname."\n";
- $message .= get_lang('CourseName').' '.$title."\n";
- $message .= get_lang('Category').' '.$category."\n";
- $message .= get_lang('Tutor').' '.$titular."\n";
- $message .= get_lang('Language').' '.$course_language;
- @api_mail($recipient_name, $recipient_email, $subject, $message,$siteName,$recipient_email);
- }
- }
- return 0;
- }
- function checkArchive($pathToArchive) {
- return TRUE;
- }
- function readPropertiesInArchive($archive, $isCompressed = TRUE) {
- include api_get_path(LIBRARY_PATH) . "pclzip/pclzip.lib.php";
- debug::printVar(dirname($archive), "Zip : ");
- $uid = api_get_user_id();
-
- $zipFile = new pclZip($archive);
- $tmpDirName = dirname($archive) . "/tmp".$uid.uniqid($uid);
- if (mkdir($tmpDirName, api_get_permissions_for_new_directories(), true)) {
- $unzippingSate = $zipFile->extract($tmpDirName);
- } else {
- die("mkdir failed");
- }
- $pathToArchiveIni = dirname($tmpDirName) . "/archive.ini";
-
- $courseProperties = parse_ini_file($pathToArchiveIni);
- rmdir($tmpDirName);
- return $courseProperties;
- }
|