123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854 |
- <?php
- use ChamiloSession as Session;
- $use_anonymous = true;
- require_once '../inc/global.inc.php';
- if (!empty($_course['language'])){
- $resource_linker_file = api_get_path(SYS_CODE_PATH).'lang/'.$_course['language'].'/resourcelinker.inc.php';
- if (file_exists($resource_linker_file)) {
- require_once $resource_linker_file;
- }
- }
- require_once '../exercice/hotpotatoes.lib.php';
- function unset_session_resources() {
- $_SESSION['addedresource'] = '';
- $_SESSION['addedresourceid'] = '';
- Session::erase(addedresource);
- Session::erase(addedresourceid);
- }
- function show_folder_up() {
- global $folder;
- global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
- $level = get_levels($folder);
- if ($level == 1) {
- echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>";
- }
- if ($level && $level != 0 && $level != 1) {
- $folder_up=$folder;
- $folder_temp=explode('/',$folder);
- $last=count($folder_temp)-1;
- unset($folder_temp[$last]);
- $folder_up=implode('/',$folder_temp);
- echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&folder=$folder_up&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>";
- }
- }
- function show_documents($folder) {
- global $_course;
- global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
-
-
- if (api_is_allowed_to_edit()) {
- $visibility = "ip.visibility<>'2'";
- } else {
- $visibility = "ip.visibility='1'";
- }
- $course_id = api_get_course_int_id();
- $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
- $document_table = Database::get_course_table(TABLE_DOCUMENT);
- $sql = "SELECT * from $document_table docs , $item_property_table ip
- WHERE
- docs.c_id = $course_id AND
- ip.c_id = $course_id AND
- docs.id=ip.ref AND
- ip.tool = '".TOOL_DOCUMENT."' AND
- $visibility AND
- (ip.to_group_id = 0 OR ip.to_group_id IS NULL)AND
- ip.to_user_id IS NULL
- ORDER BY docs.path ASC";
- $result = Database::query($sql);
- while ($row = Database::fetch_array($result)) {
- if (!$folder) {
- if (get_levels($row['path'])-1 == 1) {
-
- if (file_or_folder($row['path'])) {
- echo '<img src="../img/file.gif" align="middle" />';
- } else {
- $image = choose_image($row['path']);
- echo "<img src=\"../img/$image\" align=\"middle\" />";
- }
-
- if (file_or_folder($row['path'])) {
- echo "<a href='".api_get_self()."?content=Document";
- echo "&folder=".substr($row['path'], 1)."&source_id=$source_id&source_forum=".$_GET['source_forum']."&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".substr($row['path'], 1).'</a><br />';
- } else {
- echo substr($row['path'], 1).' ';
- echo showorhide_addresourcelink('Document',$row['id']);
- echo '<br />';
- }
- }
- } else {
-
-
- $level = get_levels($folder) + 1;
-
- $file_level=get_levels($row['path'])-1;
-
-
- if ($file_level == $level) {
- $good_paths[] = $row['path'];
- $good_ids[] = $row['id'];
- }
-
-
-
-
-
-
-
- }
- }
-
- if ($good_paths) {
-
- foreach ($good_paths as $path) {
- if (strstr($path, $folder)) {
- $good_key = key($good_paths);
-
- if (file_or_folder($path)) {
- echo '<img src="../img/file.gif" align="middle" />';
- } else {
- $image = choose_image($path);
- echo "<img src=\"../img/$image\" align=\"middle\" />";
- }
-
- if (file_or_folder($path)) {
- $path = substr($path, 1);
- $uri = str_replace($folder, $path, $_SERVER['REQUEST_URI']);
- $newuri = str_replace('add=', 'addnot=', $uri);
-
- $folder_name = str_replace($folder.'/', '', $path);
- echo "<a href='$newuri'>".$folder_name.'</a><br />';
- } else {
- echo str_replace("/$folder/", '', $path).' ';
- echo showorhide_addresourcelink('Document', $good_ids[$good_key]);
- echo '<br />';
- }
- }
- next($good_paths);
- }
- }
- }
- function file_or_folder($filefolder) {
- global $_course;
- $courseDir = $_course['path'].'/document';
- $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir;
- return (is_dir($baseWorkDir.$filefolder) ? 1 : 0);
- }
- function store_resources($source_type, $source_id)
- {
- $resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES);
- $course_id = api_get_course_int_id();
- $addedresource = $_SESSION['addedresource'];
- $addedresourceid = $_SESSION['addedresourceid'];
- if ($_SESSION['addedresource']) {
- foreach ($addedresource as $resource_type) {
- $sql="INSERT INTO $resource_table (c_id, source_type, source_id, resource_type, resource_id) VALUES
- ($course_id, '$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')";
- Database::query($sql);
- $i=key($addedresource);
- next($addedresource);
- }
- $_SESSION['addedresource']='';
- $_SESSION['addedresourceid']='';
- }
- }
- function display_addedresource_link($type, $id, $style = '')
- {
- $course_id = api_get_course_int_id();
-
- if ($style != '') {
- $styling = ' class="'.$style.'"';
- }
- switch ($type) {
- case 'Agenda':
- $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
- $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
- break;
- case 'Ad_Valvas':
- $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
- $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
- break;
- case 'Link':
- $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
- $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url'])."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n";
- break;
- case 'Exercise':
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercice/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n";
- break;
- case 'Forum':
- $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
- $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id");
- $myrow = Database::fetch_array($result);
- echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewforum.php?forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow['forum_name']."</a><br />\n";
- break;
- case 'Thread':
-
-
- break;
- case 'Post':
- $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
- $sql = "SELECT * FROM $tbl_post p WHERE c_id = $course_id AND post_id = $id";
- $result = Database::query($sql);
- $post = Database::fetch_object($result);
- echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post->topic_id.'&forum='.$post->forum_id.'"'.$styling.'>'.$post->post_title."</a><br />\n";
- break;
- case 'Document':
- $dbTable = Database::get_course_table(TABLE_DOCUMENT);
- $result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $pathname = explode('/',$myrow['path']);
- $last = count($pathname) - 1;
- $filename = $pathname[$last];
- $image = choose_image($filename);
- $ext = explode('.', $filename);
- $ext = strtolower($ext[sizeof($ext)-1]);
- $myrow['path'] = rawurlencode($myrow['path']);
- $array_ext=array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png');
- if (api_browser_support('svg')){
- $array_ext[]='svg';
- }
- if (api_browser_support('ogg')){
- $array_ext[]='ogg';
- }
- $in_frames = in_array($ext, $array_ext);
- echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n";
- break;
- case 'Externallink':
- echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n";
- break;
- }
- }
- function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0) {
- global $learnpath_id, $items;
- global $enableDocumentParsing, $_course, $_user, $_cid;
- $course_id = api_get_course_int_id();
- $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
- $hyperlink_target_parameter = '';
- $length = ((($builder == 'builder') && ($icon == 'nolink')) ? 65 : 32);
- if ($builder != 'builder') $origin = 'learnpath';
- $linktype = $type;
- if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link';
-
- switch ($type) {
- case TOOL_CALENDAR_EVENT:
- case 'Agenda':
- $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
- $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['title'] = $row['title']; }
- $desc = $row['description'];
- $agenda_id = $row['item_id'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($myrow['title'] == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($myrow['title'], $length)); }
- if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length-3*$level))."</a>";
- $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>";
- }
- }
- } else {
- echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length-3*$level))."</a>";
- }
- break;
- case TOOL_ANNOUNCEMENT:
- case 'Ad_Valvas':
- $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
- $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($row['title'] != '') {
- $myrow['content'] = $row['title'];
- }
- $desc = $row['description'];
- $ann_id = $row['item_id'];
- echo str_repeat(" >", $level);
-
- list($title, $text) = explode('<br>', $myrow['content']);
- if ($title == '') { $title = $myrow['content']; }
- $title = $myrow['title'];
- $text = $myrow['content'];
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($title == '') {
- $type = 'Announcement';
- echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
- return(true);
- }
- if ($icon == 'nolink') { return(shorten($title,$length)); }
- if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title, ($length-3*$level))."</a>";
- $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>";
- }
- }
- } else {
- echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title, ($length-3*$level))."</a>";
- }
- break;
- case TOOL_LINK:
- case 'Link':
- $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
- $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['title'] = $row['title']; }
- $desc=$row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($myrow['title'] == '') {
- echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
- return(true);
- }
- if ($icon == 'nolink') { return(shorten($myrow['title'], $length)); }
- if ($icon == 'icon') {
- if ($linktype == 'Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; }
- else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; }
- }
- $thelink = $myrow['url'];
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length-3*$level))."</a>";
- $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>";
- }
- }
- } else {
- echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length-3*$level))."</a>";
- }
- break;
- case TOOL_QUIZ:
- case 'Exercise':
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- if ($builder == 'builder') { $origin = 'builder'; }
-
- $sql = "select * from $tbl_lp_item where id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['title'] = $row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($myrow['title'] == '') {
- echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
- return(true);
- }
- if ($icon == 'nolink') { return(shorten($myrow['title'], $length)); }
- if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow['title'], ($length-3*$level))."</a>";
- $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>";
- }
- }
- } else {
- echo "<a href=\"../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow['id']."\" class='$completed' target='_blank'>".shorten($myrow['title'], ($length-3*$level))."</a>";
- }
- break;
- case 'hotpotatoes':
- case 'HotPotatoes':
- $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
- $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
- $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $path = $myrow['path'];
- $name = GetQuizName($path, $documentPath);
- if ($builder == 'builder') { $origin='builder'; }
-
- $sql = "select * from $tbl_lp_item where id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $name=$row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($name,$length)); }
- if ($icon == 'icon') { echo "<img src='../img/jqz.jpg' align=\"absmiddle\" alt='hot potatoes'>"; }
- $cid = $_course['official_code'];
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>";
- $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>";
- }
- }
- } else {
- echo " <a href=\"../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
- }
- break;
- case TOOL_FORUM:
- case 'Forum':
- $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
- $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id");
- $myrow = Database::fetch_array($result);
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow["forum_name"] = $row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($myrow['forum_name'], $length)); }
- if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
- $forumparameters = "forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
- $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>";
- }
- }
- } else {
- echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
- }
- break;
- case TOOL_THREAD:
- case 'Thread':
- $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD);
- $sql = "SELECT * FROM $tbl_topics where c_id = $course_id AND topic_id=$id";
- $result = Database::query($sql);
- $myrow = Database::fetch_array($result);
- $sql = "select * from $tbl_lp_item where id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['topic_title'] = $row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($myrow["topic_title"] == '') { $type = "Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($myrow['topic_title'], $length)); }
- if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"], ($length-3*$level))."</a>";
- $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>";
- }
- }
- } else {
- echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>";
- }
- break;
- case TOOL_POST:
- case 'Post':
-
- $tbl_posts = Database::get_course_table(TABLE_FORUM_POST);
- $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
- $result = Database::query("SELECT * FROM $tbl_posts where c_id = $course_id AND post_id=$id");
- $myrow = Database::fetch_array($result);
-
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row=Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['post_title'] = $row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- $posternom = $myrow['nom']; $posterprenom = $myrow['prenom'];
- $posttime = $myrow['post_time']; $posttext = $myrow['post_text'];
- $posttitle = $myrow['post_title'];
- $posttext = str_replace('"', "'", $posttext);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($myrow["post_title"] == '') {
- $type = 'Forum';
- echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
- }
- if ($icon == 'nolink') { return(shorten($myrow["post_title"],$length)); }
- if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".intval($_GET['source_forum'])."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".intval($_GET['source_forum'])."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>";
- }
- }
- } else {
- echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["post_title"],($length-3*$level))."</a>";
- }
- break;
- case TOOL_DOCUMENT:
- case 'Document':
- $dbTable = Database::get_course_table(TABLE_DOCUMENT);
- $my_sql = "SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id";
-
- $result = Database::query($my_sql);
- $myrow = Database::fetch_array($result);
- $pathname = explode('/', $myrow['path']);
- $last = count($pathname) - 1;
- $filename=$pathname[$last];
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- echo str_repeat(" >", $level);
- if ($icon != 'nolink') {
- if ($completed=='completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- $image = choose_image($filename);
- $sql = "select * from $tbl_lp_item where id=$id_in_path";
-
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $filename = $row['title']; }
- $desc=$row['description'];
- if (($myrow['path'] == '') && ($filename == '')) {
- echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
- return(true);
- }
- if ($icon == 'nolink') { return(shorten($filename, $length)); }
- if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; }
- if ($builder != 'builder')
- {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>";
- }
- } $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
- } else {
- $enableDocumentParsing=yes;
- if (!$enableDocumentParsing) {
-
- $file = urlencode($myrow['path']);
- echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
- } else {
- echo "<a href=\"../document/download.php?doc_url=".$myrow['path']."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
- }
- }
- break;
- case 'assignments':
- case 'Assignments':
- $name = get_lang('Assignments');
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($row['title'] != '') { $name=$row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($name=='') {
- echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
- }
- if ($icon == 'nolink') { return(shorten($name, $length)); }
- if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>";
- } else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>";
- }
- }
- } else {
- echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>";
- }
- break;
- case TOOL_DROPBOX:
- case 'Dropbox':
- $name = get_lang('Dropbox');
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($row['title'] != '') { $name = $row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($name, $length)); }
- if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; }
- else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; }
- }
- } else {
- echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>";
- }
- break;
- case 'introduction_text':
- case 'Introduction_text':
- $name = get_lang('IntroductionText');
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $name = $row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($name, $length)); }
- if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>";
- $items[] = api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; }
- else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; }
- }
- } else {
- $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
- echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>";
- }
- break;
- case TOOL_COURSE_DESCRIPTION:
- case 'Course_description':
- $name = get_lang('CourseDescription');
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $name = $row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($name,$length)); }
- if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; }
- else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; }
- }
- } else {
- $s=api_get_path(WEB_CODE_PATH)."course_description";
- echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>";
- }
- break;
- case TOOL_GROUP:
- case 'Groups':
- $name = get_lang('Groups');
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($row['title'] != '') { $name=$row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($name, $length)); }
- if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; }
- else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; }
- }
- } else {
- echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>";
- }
- break;
- case TOOL_USER:
- case 'Users':
- $name = get_lang('Users');
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($row['title'] != '') { $name = $row['title']; }
- $desc = $row['description'];
- echo str_repeat(" >", $level);
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "<td>"; }
- if ($icon != 'nolink') {
- if ($completed == 'completed') {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
- } else {
- echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
-
- }
- }
- if (($builder != 'builder') && ($icon != 'wrap')) { echo "</td><td>"; }
- if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
- if ($icon == 'nolink') { return(shorten($name,$length)); }
- if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; }
- if ($builder != 'builder') {
- echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
- if ($desc != '') {
- if ($icon != 'wrap') {
- echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc, ($length-3*$level))."</div></td></tr>"; }
- else {
- echo "<div class='description'> ".shorten($desc, ($length-3*$level))."</div>"; }
- }
- } else {
- echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name, ($length-3*$level))."</a>";
- }
- break;
- }
- }
- function get_addedresource_link_in_learnpath($type, $id, $id_in_path)
- {
- global $_course, $learnpath_id;
- global $enableDocumentParsing, $_user, $_cid;
- $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
- $course_id = api_get_course_int_id();
- $hyperlink_target_parameter = '';
- $builder = 'player';
- $origin = 'learnpath';
- $linktype = $type;
- if (($type == 'Link _self') || ($type == 'Link _blank')) { $type = 'Link'; }
- $link = '';
- switch ($type) {
- case 'Agenda':
- $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
- $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['title'] = $row['title']; }
- $desc = $row['description'];
- $agenda_id = $row['item_id'];
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
- } else {
- $link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id";
- }
- break;
- case 'Ad_Valvas':
- $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
- $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path";
- } else {
- $link .= "../announcements/announcements.php?origin=$origin&ann_id=$id";
- }
- break;
- case 'Link':
- $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
- $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- $thelink = $myrow['url'];
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
- } else {
- $link .= $thelink;
- }
- break;
- case 'Exercise':
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- if ($builder == 'builder') { $origin = 'builder'; }
-
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['title'] = $row['title']; }
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
- } else {
- $link .= "../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"];
- }
- break;
- case 'HotPotatoes':
- $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
- $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
- $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $path = $myrow['path'];
- $name = GetQuizName($path, $documentPath);
- if ($builder == 'builder') {
- $origin = 'builder';
- }
- $cid = $_course['official_code'];
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
- } else {
- $link .= "../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id'];
- }
- break;
- case 'Forum':
-
- $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
- $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id");
- $myrow = Database::fetch_array($result);
- if ($builder == 'builder') { $origin = 'builder'; }
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['forum_name'] = $row['title']; }
- if ($myrow['forum_name'] == '') { $type = 'Forum'; }
- $forumparameters = "forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
- } else {
- $link .= "../phpbb/viewforum.php?$forumparameters";
- }
- break;
- case 'Thread':
-
- $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD);
- $tbl_posts = Database::get_course_table(TABLE_FORUM_POST);
- $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
- $sql = "SELECT * FROM $tbl_topics where c_id = $course_id AND topic_id=$id";
- $result = Database::query($sql);
- $myrow = Database::fetch_array($result);
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql); $row = Database::fetch_array($result);
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
- } else {
- $link .= "../forum/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
- }
- break;
- case 'Post':
-
- $tbl_posts = Database::get_course_table(TABLE_FORUM_POST);
- $result = Database::query("SELECT * FROM $tbl_posts where c_id = $course_id AND post_id=$id");
- $myrow = Database::fetch_array($result);
-
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($row['title'] != '') { $myrow['post_title'] = $row['title']; }
- $desc = $row['description'];
-
- $posternom = $myrow['nom']; $posterprenom = $myrow['prenom'];
- $posttime = $myrow['post_time']; $posttext = $myrow['post_text'];
- $posttitle = $myrow['post_title'];
- $posttext = str_replace('"', "'", $posttext);
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path";
- } else {
- $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
- }
- break;
- case 'Document':
- $dbTable = Database::get_course_table(TABLE_DOCUMENT);
- $result = Database::query("SELECT * FROM $dbTable WHERE id=$id");
- $myrow = Database::fetch_array($result);
- $pathname = explode('/', $myrow['path']);
- $last = count($pathname) - 1;
- $filename = $pathname[$last];
- $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
- } else {
- $enableDocumentParsing = yes;
- if (!$enableDocumentParsing) {
-
- $file = urlencode($myrow['path']);
- $link .= "../document/showinframes.php?file=$file";
- } else {
- $link .= "../document/download.php?doc_url=".$myrow['path'];
- }
- }
- break;
- case 'Assignments':
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
- } else {
- $link .= "../work/work.php";
- }
- break;
- case 'Dropbox':
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
- } else {
- $link .= "../dropbox/index.php";
- }
- break;
- case 'Introduction_text':
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
- } else {
- $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
- $link .= $s;
- }
- break;
- case 'Course_description':
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
- } else {
- $s = api_get_path(WEB_CODE_PATH).'course_description';
- $link .= $s;
- }
- break;
- case 'Groups':
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
- } else {
- $link .= "../group/group.php?origin=$origin";
- }
- break;
- case 'Users':
- if ($builder != 'builder') {
- $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
- } else {
- $link .= "../user/user.php?origin=$origin";
- }
- break;
- }
- return $link;
- }
- function remove_resource($resource_key) {
- $addedresource = $_SESSION['addedresource'];
- $addedresourceid = $_SESSION['addedresourceid'];
- unset($addedresource[$resource_key]);
- unset($addedresourceid[$resource_key]);
- $_SESSION['addedresource'] = $addedresource;
- $_SESSION['addedresourceid'] = $addedresourceid ;
- }
- function show_addresource_button($additionalparameters = '') {
- global $charset;
- echo '<label for="addresources"><img src="../img/attachment.gif" /></label><input class="link_alike" type="submit" name="addresources" id="addresources" value="'.api_htmlentities(get_lang('Attachment'), ENT_QUOTES, $charset).'" '.$additionalparameters.' />';
- }
- function delete_added_resource($type, $id)
- {
- $course_id = api_get_course_int_id();
- $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
- $sql = "DELETE FROM $TABLERESOURCE
- WHERE c_id = $course_id AND source_type='$type' and source_id='$id'";
- Database::query($sql);
- }
- function delete_all_resources_type($type)
- {
- $course_id = api_get_course_int_id();
- $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
- $sql = "DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type'";
- Database::query($sql);
- }
- function check_added_resources($type, $id) {
- $course_id = api_get_course_int_id();
- $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
- $sql = "SELECT * FROM $TABLERESOURCE
- WHERE c_id = $course_id AND source_type='$type' and source_id='$id'";
- $result = Database::query($sql);
- $number_added = Database::num_rows($result);
- if ($number_added != 0)
- return true;
- else
- return false;
- }
- function edit_added_resources($type, $id)
- {
- $course_id = api_get_course_int_id();
- $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
- $sql = "SELECT * FROM $TABLERESOURCE
- WHERE c_id = $course_id AND source_type='$type' and source_id=$id";
- $result=Database::query($sql);
- while ($row=Database::fetch_array($result))
- {
- $addedresource[]=$row["resource_type"];
- $addedresourceid[]=$row["resource_id"];
- }
- $_SESSION['addedresource'] = $addedresource;
- $_SESSION['addedresourceid'] = $addedresourceid;
- }
- function update_added_resources($type, $id)
- {
- $course_id = api_get_course_int_id();
- $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
-
- $sql = "DELETE FROM $TABLERESOURCE
- WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'";
-
- Database::query($sql);
-
- store_resources($type, $id);
-
- unset_session_resources();
- }
- function display_added_resources($type, $id, $style = '') {
- $course_id = api_get_course_int_id();
-
- $arr_icons = array(
- 'Agenda' => '../img/agenda.gif',
- 'Ad Valvas' => '../img/valves.gif',
- 'Link' => '../img/links.gif',
- 'Exercise' => '../img/quiz.gif',
- );
- global $origin;
- $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
- $sql = "SELECT * FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' and source_id='$id'";
- $result = Database::query($sql);
- while ($row=Database::fetch_array($result)) {
- if ($origin != 'learnpath') {
- display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ;
- } else {
- display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>";
- }
- }
- }
- function display_resources($showdeleteimg) {
- global $action;
- global $resourceaction;
- global $id;
- global $locationkey;
- global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
- if ($resourceaction == 'removeresource') {
- remove_resource($locationkey);
- }
- $addedresource = $_SESSION['addedresource'];
- $addedresourceid = $_SESSION['addedresourceid'];
- if (is_array($addedresource)) {
- echo '<table>';
- foreach ($addedresource as $resource) {
- echo '<tr><td>';
- display_addedresource_link($resource, $addedresourceid[key($addedresource)]);
- echo '</td><td width="30">';
-
-
- $test = parse_url($_SERVER['REQUEST_URI']);
- $output = array();
- parse_str($test[query], $output);
- if ($showdeleteimg == 1) {
- echo "<a href=".api_get_self()."?showresources=true&source_forum=".$_GET['source_forum']."&resourceaction=removeresource&locationkey=".key($addedresource)."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />";
- }
- echo '</td></tr>';
- next($addedresource);
- }
- echo '</table>';
- }
- else {
- echo '';
- }
- }
- function showorhide_addresourcelink($type, $id) {
- global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target;
- $addedresource = $_SESSION['addedresource'];
- $addedresourceid = $_SESSION['addedresourceid'];
- if (is_array($_SESSION['addedresource'])) {
- foreach ($addedresource as $toolcompare) {
- if ($toolcompare==$type && $addedresourceid[key($addedresource)] == $id) {
- $show = 0;
- }
- next($addedresource);
- }
- if ($from_learnpath) { $lang_add_it_or_resource = get_lang('AddIt'); } else { $lang_add_it_or_resource = get_lang('AddResource'); }
- if ($show !== 0) {
- if ($type == 'Document') {
- echo "<a href=".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no>".$lang_add_it_or_resource."</a>";
- } else {
- echo "<a href='".api_get_self()."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>";
- }
- }
- }
- else {
- if ($_SESSION['addedresource'] !== $type || $_SESSION['addedresourceid'] !== $id) {
- if ($from_learnpath) { $lang_add_it_or_resource = get_lang('AddIt'); } else { $lang_add_it_or_resource = get_lang('AddResource'); }
- echo "<a href='".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>";
- }
- }
- }
- function rl_get_html_resource_link($course_code, $type, $id, $style='', $new_window = true) {
- $_course = api_get_course_info($course_code);
- $course_id = api_get_course_int_id();
-
- if ($style != '') $styling = ' class="'.$style.'"';
- if ($new_window) { $target = ' target = "_blank" '; } else { $target = ' target = "_self" '; }
- $output = '';
- switch ($type) {
- case TOOL_CALENDAR_EVENT:
- $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
- $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $output = '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.' '.$target.'>'.$myrow['title']."</a><br />\n";
- break;
- case TOOL_ANNOUNCEMENT:
- $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
- $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $output = '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.' '.$target.'>'.$myrow['title']."</a><br />\n";
- break;
- case TOOL_LINK:
-
- $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
- $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $output = '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url'])."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n";
- break;
- case TOOL_QUIZ:
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $output = '<img src="../img/quiz.gif" align="middle" /> <a href="../exercice/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.' '.$target.'>'.$myrow['title']."</a><br />\n";
- break;
- case TOOL_FORUM:
- $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
- $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id");
- $myrow = Database::fetch_array($result);
- $output = '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewforum.php?forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.' '.$target.'>'.$myrow['forum_name']."</a><br />\n";
- break;
- case TOOL_THREAD:
-
-
- $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
-
- $sql_title = "SELECT * FROM $tbl_post WHERE c_id = $course_id AND post_id=".$id;
- $result_title = Database::query($sql_title);
- $myrow_title = Database::fetch_array($result_title);
- $output = '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$myrow_title['thread_id'].'&forum='.$myrow_title['forum_id'].'" '.$styling.' '.$target.'>'.$myrow_title['post_title']."</a><br />\n";
- break;
- case TOOL_POST:
- $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
-
- $sql = "SELECT * FROM $tbl_post p WHERE c_id = $course_id AND p.post_id = $id";
- $result = Database::query($sql);
- $post = Database::fetch_array($result);
- $output = '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post['thread_id'].'&forum='.$post['forum_id'].'"'.$styling.' '.$target.'>'.$post['post_title']."</a><br />\n";
- break;
- case TOOL_DOCUMENT:
- $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
- $result = Database::query("SELECT * FROM $tbl_doc WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $pathname = explode('/', $myrow['path']);
- $last = count($pathname) - 1;
- $filename = $pathname[$last];
- $image = choose_image($filename);
- $ext = explode('.', $filename);
- $ext = strtolower($ext[sizeof($ext) - 1]);
- $myrow['path'] = rawurlencode($myrow['path']);
- $in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
- $output = '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.' '.$target.'>'.$filename."</a><br />\n";
- break;
- }
- return $output;
- }
- function rl_get_resource_link_for_learnpath($course_id, $learnpath_id, $id_in_path, $lpViewId)
- {
- $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
- $course_info = api_get_course_info_by_id($course_id);
- $course_id = $course_info['real_id'];
- $course_code = $course_info['code'];
- $session_id = api_get_session_id();
- $learnpath_id = intval($learnpath_id);
- $id_in_path = intval($id_in_path);
- $lpViewId = intval($lpViewId);
- $sql = "SELECT * FROM $tbl_lp_item
- WHERE
- c_id = $course_id AND
- lp_id = $learnpath_id AND
- id = $id_in_path
- ";
- $res_item = Database::query($sql);
- if (Database::num_rows($res_item) < 1) {
- return -1;
- }
- $row_item = Database::fetch_array($res_item);
- $type = strtolower($row_item['item_type']);
- $id = (strcmp($row_item['path'], '') == 0) ? '0' : $row_item['path'];
- $origin = 'learnpath';
- $main_dir_path = api_get_path(WEB_CODE_PATH);
- $main_course_path = api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/';
- $link = '';
- switch ($type) {
- case 'dokeos_chapter':
- $link .= $main_dir_path.'newscorm/blank.php';
- case TOOL_CALENDAR_EVENT:
- $link .= $main_dir_path.'calendar/agenda.php?origin='.$origin.'&agenda_id='.$id;
- break;
- case TOOL_ANNOUNCEMENT:
- $link .= $main_dir_path.'announcements/announcements.php?origin='.$origin.'&ann_id='.$id;
- break;
- case TOOL_LINK:
- $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
- $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $thelink = $myrow["url"];
- $link .= $thelink;
- break;
- case TOOL_QUIZ:
- if (!empty($id)) {
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $sql = "SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id";
- $result= Database::query($sql);
- $myrow=Database::fetch_array($result);
- if ($row_item['title'] != '') {
- $myrow['title'] = $row_item['title'];
- }
- $link .= $main_dir_path.'exercice/overview.php?cidReq='.$course_code.'&session_id='.$session_id.'&lp_init=1&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$id_in_path.'&exerciseId='.$id;
- }
- break;
- case 'hotpotatoes':
- $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
- $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $path = $myrow['path'];
- $link .= $main_dir_path.'exercice/showinframes.php?file='.$path.'' .
- '&origin='.$origin.'&cid='.$course_code.'&uid='.api_get_user_id().'' .
- '&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$id_in_path.'&lp_view_id='.$lpViewId;
- break;
- case TOOL_FORUM:
- $link .= $main_dir_path.'forum/viewforum.php?forum='.$id.'&lp=true&origin=learnpath';
- break;
- case TOOL_THREAD:
- $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD);
- if (!empty($id)) {
- $sql = "SELECT * FROM $tbl_topics WHERE c_id = $course_id AND thread_id=$id";
- $result = Database::query($sql);
- $myrow = Database::fetch_array($result);
- $link .= $main_dir_path.'forum/viewthread.php?origin=learnpath&thread='.$id.'' .
- '&forum='.$myrow['forum_id'].'&lp=true';
- }
- break;
- case TOOL_POST:
- $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
- $result = Database::query("SELECT * FROM $tbl_post WHERE c_id = $course_id AND post_id=$id");
- $myrow = Database::fetch_array($result);
- $title = $myrow['post_title'];
-
- $posternom = $myrow['poster_name'];
- $posttime = $myrow['post_date'];
- $posttext = $myrow['post_text'];
- $posttitle = $title;
- $posttext = str_replace('"', "'", $posttext);
- $link .= $main_dir_path.'forum/viewthread.php?post='.$id.'' .
- '&thread='.$myrow['thread_id'].'&forum='.$myrow['forum_id'].'' .
- '&lp=true';
- break;
- case TOOL_DOCUMENT:
- $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
- $sql = "SELECT * FROM $tbl_doc WHERE c_id = $course_id AND id = $id";
- $result = Database::query($sql);
- $myrow = Database::fetch_array($result);
- $docurl = str_replace('%2F', '/', urlencode($myrow['path']));
- $link .= $main_course_path.'document'.$docurl.'?cidReq='.$course_code.'&id_session='.$session_id;
- $openmethod = 2;
- $officedoc = false;
- Session::write('openmethod',$openmethod);
- Session::write('officedoc',$officedoc);
- break;
- case 'assignments':
- $link .= $main_dir_path.'work/work.php?origin='.$origin;
- break;
- case TOOL_DROPBOX:
- $link .= $main_dir_path.'dropbox/index.php?origin=learnpath';
- break;
- case 'introduction_text':
- $link .= '';
- break;
- case TOOL_COURSE_DESCRIPTION:
- $link .= $main_dir_path.'course_description?origin=learnpath';
- break;
- case TOOL_GROUP:
- $link .= $main_dir_path.'group/group.php?origin='.$origin;
- break;
- case TOOL_USER:
- $link .= $main_dir_path.'user/user.php?origin='.$origin;
- break;
- case 'student_publication' :
- $link .= $main_dir_path.'work/work.php?origin=learnpath';
- break;
- }
- return $link;
- }
- function rl_get_resource_name($course_code, $learnpath_id, $id_in_path)
- {
- $_course = api_get_course_info($course_code);
- $course_id = $_course['real_id'];
- $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
- $learnpath_id = intval($learnpath_id);
- $id_in_path = intval($id_in_path);
- $sql_item = "SELECT item_type, title, ref FROM $tbl_lp_item
- WHERE c_id = $course_id AND lp_id = $learnpath_id AND id = $id_in_path";
- $res_item = Database::query($sql_item);
- if (Database::num_rows($res_item) < 1) {
- return '';
- }
- $row_item = Database::fetch_array($res_item);
- $type = strtolower($row_item['item_type']);
- $id = $row_item['ref'];
- $output = '';
- switch ($type) {
- case TOOL_CALENDAR_EVENT:
- $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
- $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $output = $myrow['title'];
- break;
- case TOOL_ANNOUNCEMENT:
- $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
- $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $output = $myrow['title'];
- break;
- case TOOL_LINK:
-
- $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
- $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $output = $myrow['title'];
- break;
- case TOOL_QUIZ:
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $output = $myrow['title'];
- break;
- case TOOL_FORUM:
- $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
- $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id");
- $myrow = Database::fetch_array($result);
- $output = $myrow['forum_name'];
- break;
- case TOOL_THREAD:
- $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
-
- $sql_title = "SELECT * FROM $tbl_post WHERE c_id = $course_id AND post_id=".$id;
- $result_title = Database::query($sql_title);
- $myrow_title = Database::fetch_array($result_title);
- $output = $myrow_title['post_title'];
- break;
- case TOOL_POST:
- $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
-
- $sql = "SELECT * FROM $tbl_post p WHERE c_id = $course_id AND p.post_id = $id";
- $result = Database::query($sql);
- $post = Database::fetch_array($result);
- $output = $post['post_title'];
- break;
- case 'dokeos_chapter':
- $title = $row_item['title'];
- if (!empty($title)) {
- $output = $title;
- } else {
- $output = '-';
- }
- break;
- case TOOL_DOCUMENT:
- $title = $row_item['title'];
- if (!empty($title)) {
- $output = $title;
- } else {
- $output = '-';
- }
- break;
- case 'hotpotatoes':
- $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
- $result = Database::query("SELECT * FROM $tbl_doc WHERE c_id = $course_id AND id=$id");
- $myrow = Database::fetch_array($result);
- $pathname = explode('/', $myrow['path']);
- $last = count($pathname) - 1;
- $filename = $pathname[$last];
- $image = choose_image($filename);
- $ext = explode('.', $filename);
- $ext = strtolower($ext[sizeof($ext) - 1]);
- $myrow['path'] = rawurlencode($myrow['path']);
- $in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
- $output = $filename;
- break;
-
- }
- return stripslashes($output);
- }
|