".get_lang('LevelUp').""; } if ($level and $level != 0 and $level != 1) { $folder_up=$folder; $folder_temp=explode('/',$folder); $last=count($folder_temp)-1; unset($folder_temp[$last]); $folder_up=implode('/',$folder_temp); echo "".get_lang('LevelUp').""; } } /** * Shows the documents of the document tool * @param $folder */ function show_documents($folder) { global $_course; global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; // documents are a special case: the teacher can add an invisible document (it will be viewable by the user) // other tools do not have this feature. This only counts if (is_allowed_to_edit()) { $visibility="ip.visibility<>'2'"; } else { $visibility="ip.visibility='1'"; } $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.id=ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND $visibility AND ip.to_group_id = 0 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) { // showing the right icon if (file_or_folder($row['path'])) { echo ''; } else { $image = choose_image($row['path']); echo ""; } // folders should be clickable if (file_or_folder($row['path'])) { echo "".substr($row['path'],1).'
'; } else { echo substr($row['path'],1).' '; echo showorhide_addresourcelink('Document',$row['id']); echo '
'; } } } else { // we calculate the level we are in by using the $folder in the url // we put +1 because it does not start with an / and in the database it does $level=get_levels($folder)+1; // we calculate each level of the database entry $file_level=get_levels($row['path'])-1; // if the level of the database entry is equal to the level we ar in, we put it into an array // as this is a potential good entry if ($file_level==$level) { $good_paths[]=$row['path']; $good_ids[]=$row['id']; } //$haystack=$row['path']; //$conform_folder=strstr($haystack, $folder); //if (str_replace($folder.'/','',$conform_folder)!==$folder) // { // $good_folders[]=$row['path']; //echo str_replace($folder.'/','',$conform_folder); // echo '
'; // }// if (str_replace($folder.'/','',$conform_folder)!==$folder) } // else (if (!$folder)) } //while ($row=Database::fetch_array($result)) // this is code for the case that we are in a subfolder if ($good_paths) { // we have all the potential good database entries, the good ones are those that start with $folder foreach ($good_paths as $path) { if (strstr($path,$folder)) { $good_key=key($good_paths); // showing the right icon if (file_or_folder($path)) { echo ''; } else { $image = choose_image($path); echo ""; } // folders should be clickable if (file_or_folder($path)) { $path=substr($path,1); // remove the first / in folder_up $uri=str_replace($folder,$path,$_SERVER['REQUEST_URI']); $newuri=str_replace('add=','addnot=',$uri); //using the correct name of the folder $folder_name=str_replace($folder.'/','',$path); echo "".$folder_name.'
'; } else { echo str_replace("/$folder/", '',$path).' '; echo showorhide_addresourcelink('Document',$good_ids[$good_key]); echo '
'; } } next($good_paths); } } } /** * Checks wether something is a file or a folder * 0 means file, 1 means folder * @param $filefolder * @todo: use true and false instead of 1 and 0. */ function file_or_folder($filefolder) { global $_course; global $baseServDir; $courseDir = $_course['path'].'/document'; $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir; return (is_dir($baseWorkDir.$filefolder) ? 1 : 0); } /** * Inserts a resource into the database * * @param $source_type * @param $source_id */ function store_resources($source_type, $source_id) { global $_course; $resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES); $addedresource = $_SESSION['addedresource']; $addedresourceid = $_SESSION['addedresourceid']; if ($_SESSION['addedresource']) { foreach ($addedresource as $resource_type) { $sql="INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')"; Database::query($sql); $i=key($addedresource); next($addedresource); } $_SESSION['addedresource']=''; $_SESSION['addedresourceid']=''; } } /** * DEPRECATED - use rl_get_resource_link() instead - DEPRECATED * Displays the link that opens a new browser window that views the added resource. * * @author Patrick Cool , Ghent University * @param $type the type of the tool * @param $id the id of the resource * @param $style this is used to style the link (for instance when a resource is hidden => the added resources should also be styled like they are hidden) * @todo use the constants for the type definitions. */ function display_addedresource_link($type, $id, $style='') { global $_course; // styling the link of the added resource if ($style <> '') { $styling = ' class="'.$style.'"'; } switch ($type) { case 'Agenda': $TABLEAGENDA = $_course['dbNameGlu'].'calendar_event'; $result = Database::query("SELECT * FROM `$TABLEAGENDA` WHERE id=$id"); $myrow = Database::fetch_array($result); echo ' '.$myrow['title']."
\n"; break; case 'Ad_Valvas': $tbl_announcement = $_course['dbNameGlu'].'announcement'; $result = Database::query("SELECT * FROM `$tbl_announcement` WHERE id=$id"); $myrow = Database::fetch_array($result); echo ' '.$myrow['title']."
\n"; break; case 'Link': $TABLETOOLLINK = $_course['dbNameGlu'].'link'; $result = Database::query("SELECT * FROM `$TABLETOOLLINK` WHERE id=$id"); $myrow = Database::fetch_array($result); echo ' '.$myrow['title']."
\n"; break; case 'Exercise': $TBL_EXERCICES = $_course['dbNameGlu'].'quiz'; $result = Database::query("SELECT * FROM `$TBL_EXERCICES` WHERE id=$id"); $myrow = Database::fetch_array($result); echo ' '.$myrow['title']."
\n"; break; case 'Forum': $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums'; $result = Database::query("SELECT * FROM `$TBL_FORUMS` WHERE forum_id=$id"); $myrow = Database::fetch_array($result); echo ' '.$myrow['forum_name']."
\n"; break; case 'Thread': //=topics $tbl_posts = $_course['dbNameGlu'].'bb_posts'; $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums'; $result = Database::query("SELECT * FROM `$tbl_posts` posts, `$TBL_FORUMS` forum WHERE forum.forum_id=posts.forum_id and post_id=$id"); $myrow = Database::fetch_array($result); // grabbing the title of the post $sql_title = "SELECT * FROM `$tbl_posts_text` WHERE post_id=".$myrow["post_id"]; $result_title = Database::query($sql_title); $myrow_title = Database::fetch_array($result_title); echo ' '.$myrow_title['post_title']."
\n"; break; case 'Post': $tbl_post = Database::get_course_table(TABLE_FORUM_POST); $sql = "SELECT * FROM $tbl_post p WHERE post_id = $id"; $result = Database::query($sql); $post = Database::fetch_object($result); echo ' '.$post->post_title."
\n"; break; case 'Document': $dbTable = $_course['dbNameGlu'].'document'; $result = Database::query("SELECT * FROM `$dbTable` WHERE id=$id"); $myrow = Database::fetch_array($result); $pathname = explode('/',$myrow['path']); // making a correct name for the link $last = count($pathname) - 1; // making a correct name for the link $filename = $pathname[$last]; // making a correct name for the link $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')); echo ' '.$filename."
\n"; break; case 'Externallink': echo ' '.$id."
\n"; break; } } /** * This function is to display the added resources (lessons) in the learning path player and builder * this function is a modification of display_addedresource_link($type, $id) function * the two ids are a bit confusing, I admit, but I did not want to change Patrick's work, I was * building upon it. - Denes * * Parameters: * @param completed - if ="completed" then green presentation with checkbox * @param id_in_path - if onclick then this lesson will be considered completed, that is the unique index in the items table * @param id - that is the correspondent id in the mirror tool (like Agenda item 2) * @param type - that is the correspondent type in the mirror tool (like this is a Link item) * @param builder - if ="builder" then onclick shows in new window * @param icon - if ="icon" then the small icon will appear * if ="wrap" then wrapped settings are used (and no icon is displayed) * if ="nolink" then only the name is returned with no href and no icon (note:only in this case, the result is not displayed, but returned) * @todo this function is too long, rewrite */ function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0) { global $_course, $learnpath_id, $tbl_learnpath_item, $items; global $curDirPath, $_configuration, $enableDocumentParsing, $_course, $_user, $_cid; $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $hyperlink_target_parameter = ''; //or e.g. 'target="_blank"' $length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32); if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view $linktype = $type; if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link'; //YW switched litteral tool names to use of constants declared in main_api.lib.php switch ($type) { case TOOL_CALENDAR_EVENT: case "Agenda": $TABLEAGENDA = $_course['dbNameGlu']."calendar_event"; $result = Database::query("SELECT * FROM `$TABLEAGENDA` WHERE id=$id"); $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["title"]=$row['title']; } $desc=$row['description']; $agenda_id=$row['item_id']; echo str_repeat(" >",$level); if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($myrow["title"]=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } if ($icon == 'icon') { echo "agenda"; } if ($builder != 'builder') { echo "".shorten($myrow["title"],($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($myrow["title"],($length-3*$level)).""; } break; case TOOL_ANNOUNCEMENT: case "Ad_Valvas": $tbl_announcement = $_course['dbNameGlu']."announcement"; $result = Database::query("SELECT * FROM `$tbl_announcement` WHERE id=$id"); $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["content"]=$row['title']; } $desc=$row['description']; $ann_id=$row['item_id']; echo str_repeat(" >",$level); // the title and the text are in the content field and we only want to display the title list($title, $text)=split('
',$myrow['content']); if ($title=='') { $title=$myrow['content']; } $title=$myrow['title']; $text=$myrow['content']; if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($title=='') { $type="Announcement"; echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($title,$length)); } if ($icon == 'icon') { echo "ad valvas"; } if ($builder != 'builder') { echo "".shorten($title,($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($title,($length-3*$level)).""; } break; case TOOL_LINK: case "Link" : $TABLETOOLLINK = $_course['dbNameGlu']."link"; $result= Database::query("SELECT * FROM `$TABLETOOLLINK` WHERE id=$id"); $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["title"]=$row['title']; } $desc=$row['description']; echo str_repeat(" >",$level); if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($myrow["title"]=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } if ($icon == 'icon') { if ($linktype=='Link _self') { echo "links"; } else { echo "blank links"; } } $thelink=$myrow["url"]; if ($builder != 'builder') { echo "".shorten($myrow["title"],($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($myrow["title"],($length-3*$level)).""; } break; case TOOL_QUIZ: case "Exercise": $TBL_EXERCICES = $_course['dbNameGlu'].'quiz'; $result= Database::query("SELECT * FROM `$TBL_EXERCICES` WHERE id=$id"); $myrow=Database::fetch_array($result); if ($builder=='builder') { $origin='builder'; } //this is needed for the exercise_submit.php can delete the session info about tests $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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($myrow["title"]=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } if ($icon == 'icon') { echo "quizz"; } if ($builder != 'builder') { echo "".shorten($myrow["title"],($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($myrow["title"],($length-3*$level)).""; } break; case 'hotpotatoes': case "HotPotatoes": $TBL_DOCUMENT = $_course['dbNameGlu'].'document'; $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; $result = Database::query("SELECT * FROM `".$TBL_DOCUMENT."` WHERE id=$id"); $myrow= Database::fetch_array($result); $path=$myrow["path"]; $name=GetQuizName($path,$documentPath); if ($builder=='builder') { $origin='builder'; } //this is needed for the exercise_submit.php can delete the session info about tests $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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($name=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($name,$length)); } if ($icon == 'icon') { echo "hot potatoes"; } $cid = $_course['official_code']; if ($builder != 'builder') { echo "".shorten($name,($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo " ".shorten($name,($length-3*$level)).""; } break; case TOOL_FORUM: case "Forum": $TBL_FORUMS = Database::get_course_table(TABLE_FORUM,$_course['database']); $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); $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["forum_name"]=$row['title']; } $desc=$row['description']; echo str_repeat(" >",$level); if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($myrow["forum_name"]=='') { $type="Forum"; echo "".get_lang('StepDeleted1')." $type ".get_lang('step_deleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); } if ($icon == 'icon') { echo "forum"; } $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; if ($builder != 'builder') { echo "".shorten($myrow["forum_name"],($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($myrow["forum_name"],($length-3*$level)).""; } break; case TOOL_THREAD: case "Thread": //forum post $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD,$_course['database']); $sql="SELECT * FROM $tbl_topics where 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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); } if ($icon == 'icon') { echo "forum"; } if ($builder != 'builder') { echo "".shorten($myrow["topic_title"],($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($myrow["topic_title"],($length-3*$level)).""; } break; case TOOL_POST: case "Post": $tbl_posts = $_course['dbNameGlu'].'bb_posts'; $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; $result= Database::query("SELECT * FROM `$tbl_posts` where post_id=$id"); $myrow=Database::fetch_array($result); // grabbing the title of the post $sql_titel="SELECT * FROM `$tbl_posts_text` WHERE post_id=".$myrow["post_id"]; $result_titel=Database::query($sql_titel); $myrow_titel=Database::fetch_array($result_titel); $sql="select * from $tbl_lp_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; } $desc=$row['description']; echo str_repeat(" >",$level); $posternom=$myrow['nom']; $posterprenom=$myrow['prenom']; $posttime=$myrow['post_time']; $posttext=$myrow_titel['post_text']; $posttitle=$myrow_titel['post_title']; $posttext = str_replace('"',"'",$posttext); if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($myrow_titel["post_title"]=='') { $type="Forum"; echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); } if ($icon == 'icon') { echo "forum"; } if ($builder != 'builder') { echo "".shorten($myrow_titel["post_title"],($length-3*$level)).""; $items[]=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"; if ($desc != '') { if ($icon != 'wrap') { echo "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($myrow_titel["post_title"],($length-3*$level)).""; } break; case TOOL_DOCUMENT: case "Document": $dbTable = $_course['dbNameGlu']."document"; $mysql = "SELECT * FROM `$dbTable` WHERE id=$id"; //error_log('New LP - Querying document table: '.$mysql,0); $result = Database::query($mysql); $myrow=Database::fetch_array($result); $pathname=explode("/",$myrow["path"]); // making a correct name for the link $last=count($pathname)-1; // making a correct name for the link $filename=$pathname[$last]; // making a correct name for the link if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } echo str_repeat(" >",$level); if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } $image=choose_image($filename); $sql="select * from $tbl_lp_item where id=$id_in_path"; //error_log('New LP - Querying lp_item table: '.$sql,0); $result=Database::query($sql); $row=Database::fetch_array($result); if ($row['title'] != '') { $filename=$row['title']; } $desc=$row['description']; if (($myrow["path"]=='') and ($filename=='')) { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($filename,$length)); } if ($icon == 'icon') { echo "$image"; } if ($builder != 'builder') { echo "".shorten($filename,($length-3*$level)).""; if ($desc != '') { if ($icon != 'wrap') { echo "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } $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) { //this is the solution for the non-parsing version in the builder $file=urlencode($myrow["path"]); echo "".shorten($filename,($length-3*$level)).""; } else { echo "".shorten($filename,($length-3*$level)).""; } } break; case 'assignments': case "Assignments": $name=get_lang('Assignments'); $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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($name=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($name,$length)); } if ($icon == 'icon') { echo ""; } if ($builder != 'builder') { echo "".shorten($name,($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($name,($length-3*$level)).""; } break; case TOOL_DROPBOX: case "Dropbox": $name=get_lang('Dropbox'); $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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($name=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($name,$length)); } if ($icon == 'icon') { echo ""; } if ($builder != 'builder') { echo "".shorten($name,($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($name,($length-3*$level)).""; } break; case 'introduction_text': case "Introduction_text": $name=get_lang('IntroductionText'); $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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($name=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($name,$length)); } if ($icon == 'icon') { echo "introduction"; } if ($builder != 'builder') { echo "".shorten($name,($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { $s=api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; echo "".shorten($name,($length-3*$level)).""; } break; case TOOL_COURSE_DESCRIPTION: case "Course_description": $name=get_lang('CourseDescription'); $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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($name=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($name,$length)); } if ($icon == 'icon') { echo "info"; } if ($builder != 'builder') { echo "".shorten($name,($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { $s=api_get_path(WEB_CODE_PATH)."course_description"; echo "".shorten($name,($length-3*$level)).""; } break; case TOOL_GROUP: case "Groups": $name=get_lang('Groups'); $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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($name=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($name,$length)); } if ($icon == 'icon') { echo "group"; } if ($builder != 'builder') { echo "".shorten($name,($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($name,($length-3*$level)).""; } break; case TOOL_USER: case "Users": $name=get_lang('Users'); $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') and ($icon != 'wrap')) { echo ""; } if ($icon != 'nolink') { if ($completed=='completed') { echo "on"; } else { echo "on"; //echo " "; } } if (($builder != 'builder') and ($icon != 'wrap')) { echo ""; } if ($name=='') { echo "".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2').""; return(true); } if ($icon == 'nolink') { return(shorten($name,$length)); } if ($icon == 'icon') { echo "members"; } if ($builder != 'builder') { echo "".shorten($name,($length-3*$level)).""; $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 "
  ".shorten($desc,($length-3*$level))."
"; } else { echo "
     ".shorten($desc,($length-3*$level))."
"; } } } else { echo "".shorten($name,($length-3*$level)).""; } break; }//end huge switch-statement } /** * This function is to create and return a link to the added resources (lessons). * It returns the same thing as display_addedresource_link_in_learnpath() but doesn't display * anything. * * Parameters: * @param type - that is the correspondent type in the mirror tool (like this is a Link item) * @param id - that is the correspondent id in the mirror tool (like Agenda item 2) * @param id_in_path - the unique index in the items table */ function get_addedresource_link_in_learnpath($type, $id, $id_in_path) { global $_course, $learnpath_id, $tbl_learnpath_item, $items; global $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid; $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $hyperlink_target_parameter = ""; //or e.g. target='_blank' $builder = 'player'; $origin='learnpath'; $linktype=$type; if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; } $link = ''; switch ($type) { case "Agenda": $TABLEAGENDA = $_course['dbNameGlu']."calendar_event"; $result = Database::query("SELECT * FROM `$TABLEAGENDA` WHERE id=$id"); $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["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 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 = $_course['dbNameGlu']."link"; $result= Database::query("SELECT * FROM `$TABLETOOLLINK` WHERE id=$id"); $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); $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 = $_course['dbNameGlu'].'quiz'; $result= Database::query("SELECT * FROM `$TBL_EXERCICES` WHERE id=$id"); $myrow=Database::fetch_array($result); if ($builder=='builder') { $origin='builder'; } //this is needed for the exercise_submit.php can delete the session info about tests $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']; } 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/exercice_submit.php?origin=$origin&exerciseId=".$myrow["id"]; } break; case "HotPotatoes": $TBL_DOCUMENT = $_course['dbNameGlu'].'document'; $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; $result = Database::query("SELECT * FROM `".$TBL_DOCUMENT."` WHERE 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 = $_course['dbNameGlu']."bb_forums"; // TODO: This is the old table name, it should be corrected. $result= Database::query("SELECT * FROM `$TBL_FORUMS` WHERE forum_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["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": //forum post $tbl_topics = $_course['dbNameGlu'].'bb_topics'; $tbl_posts = $_course['dbNameGlu'].'bb_posts'; $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; $sql="SELECT * FROM `$tbl_topics` where 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 ($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 = $_course['dbNameGlu'].'bb_posts'; $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; $result= Database::query("SELECT * FROM `$tbl_posts` where post_id=$id"); $myrow=Database::fetch_array($result); // grabbing the title of the post $sql_titel="SELECT * FROM `$tbl_posts_text` WHERE post_id=".$myrow["post_id"]; $result_titel=Database::query($sql_titel); $myrow_titel=Database::fetch_array($result_titel); $sql="select * from $tbl_lp_item where id=$id_in_path"; $result=Database::query($sql); $row=Database::fetch_array($result); if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; } $desc=$row['description']; $link .= str_repeat(" >",$level); $posternom=$myrow['nom']; $posterprenom=$myrow['prenom']; $posttime=$myrow['post_time']; $posttext=$myrow_titel['post_text']; $posttitle=$myrow_titel['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 = $_course['dbNameGlu']."document"; $result=Database::query("SELECT * FROM `$dbTable` WHERE id=$id"); $myrow=Database::fetch_array($result); $pathname=explode("/",$myrow["path"]); // making a correct name for the link $last=count($pathname)-1; // making a correct name for the link $filename=$pathname[$last]; // making a correct name for the link $sql="select * from $tbl_lp_item where 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) { //this is the solution for the non-parsing version in the builder $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; }//end huge switch-statement return $link; } /** * This function is to remove an resource item from the array */ 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 ; } /** * This function is to show the button "click to add resource" on the tool page * @author Patrick Cool , Ghent University */ function show_addresource_button($additionalparameters = '') { global $charset; echo ''; } /** * this function is to delete ONE specific resource that were added to a specific item * Deprecated *//* function delete_one_added_resource($source_type, $source_id, $resource_type, $resource_id) { //echo "delete_one_added_resource"; global $_course; $TABLERESOURCE = $_course['dbNameGlu']."resource"; $sql="DELETE FROM `$TABLERESOURCE` WHERE source_type='$source_type' and source_id='$source_id' and resource_type='$resource_type' and resource_id='$resource_id'"; Database::query($sql); }*/ /** * this function is to delete the resources that were added to a specific item */ function delete_added_resource($type, $id) { global $_course; $TABLERESOURCE = $_course['dbNameGlu']."resource"; $sql="DELETE FROM `$TABLERESOURCE` WHERE source_type='$type' and source_id='$id'"; Database::query($sql); } /** * this function is te delete all resources of a specific type (only used in announcements -- delete all) * Author : Frederik Vermeire */ function delete_all_resources_type($type) { global $_course; $TABLERESOURCE = $_course['dbNameGlu']."resource"; $sql="DELETE FROM `$TABLERESOURCE` WHERE source_type='$type'"; Database::query($sql); } /** * this function checks wether there are added resources or not */ function check_added_resources($type, $id) { global $_course, $origin; $TABLERESOURCE = $_course['dbNameGlu']."resource"; $sql="SELECT * FROM `$TABLERESOURCE` WHERE 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; } /** * this function is to load the resources that were added to a specific item * into the session variables */ function edit_added_resources($type, $id) { global $_course; $TABLERESOURCE = $_course['dbNameGlu']."resource"; $sql="SELECT * FROM `$TABLERESOURCE` WHERE 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; } /** * this function is store the modified resources * first we delete all the added resources in the database, * then we add all the resources from the session object. */ function update_added_resources($type, $id) { global $_course; $TABLERESOURCE = $_course['dbNameGlu']."resource"; // delete all the added resources for this item in the database; $sql="DELETE FROM `$TABLERESOURCE` WHERE source_type='$type' AND source_id='$id'"; //echo $sql; Database::query($sql); // store the resources from the session into the database store_resources($type, $id); //delete_added_resource_($type, $id); unset_session_resources(); } /** * this function is to display the resources that were added to a specific item */ function display_added_resources($type, $id, $style='') { // the array containing the icons $arr_icons=array('Agenda'=>'../img/agenda.gif', 'Ad Valvas'=>'../img/valves.gif', 'Link'=>'../img/links.gif', 'Exercise'=>'../img/quiz.gif' ); global $_course, $origin; $TABLERESOURCE = $_course['dbNameGlu']."resource"; $sql="SELECT * FROM `$TABLERESOURCE` WHERE 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 "
"; } } } /** * This function is to show the added resources when adding an item * $showdeleteimg determine if the delete image should appear or not. * deleting an added resource is only possible through the resource linker file itself */ 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 ''; foreach ($addedresource as $resource) { echo ''; next($addedresource); } echo '
'; display_addedresource_link($resource,$addedresourceid[key($addedresource)]); echo ''; // if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource // should also contain this id. $test=parse_url($_SERVER['REQUEST_URI']); $output = array(); parse_str($test[query],$output); if ($showdeleteimg==1) { echo "resource ".get_lang(
"; } echo '
'; } else // it is a string { echo ''; } } // end of the display_resources function /** * This function checks wether the link add resource should be displayed next the item in the linker page * So we have to check if the specific id of that tool is already in the array of the added resources * if it is already in, the link should not be showed since it would make it possible to add * the same resource a second time (=duplication of added resources) */ 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 and $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 "".$lang_add_it_or_resource.""; } else { echo "".$lang_add_it_or_resource.""; } } } else // if it is not an array, it is a string { if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id) { if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } echo "".$lang_add_it_or_resource.""; } } } /** * Gets the link to the given added resource. * * @author Patrick Cool , Ghent University * @author Yannick Warnier , Dokeos - rebranding * @param string Course code * @param string The tool type (using constants declared in main_api.lib.php) * @param integer The resource ID * @param string Resource style (e.g. when a resource is hidden => the added resources should also be styled like they are hidden) * @param boolean Open in a new window (true) or in the current frame/window (false)? * @todo use the constants for the type definitions. */ function rl_get_html_resource_link($course_code, $type, $id, $style='', $new_window=true) { //$_course = Database::get_course_info($course_code); $_course = Database::get_course_info($course_code); // styling the link of the added resource 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,$_course['database']); $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); $myrow = Database::fetch_array($result); $output = ' '.$myrow['title']."
\n"; break; case TOOL_ANNOUNCEMENT: $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT,$_course['database']); $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); $myrow = Database::fetch_array($result); $output = ' '.$myrow['title']."
\n"; break; case TOOL_LINK: //doesn't take $target into account $TABLETOOLLINK = Database::get_course_table(TABLE_LINK,$_course['database']); $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); $myrow = Database::fetch_array($result); $output = ' '.$myrow['title']."
\n"; break; case TOOL_QUIZ: $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST,$_course['database']); $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); $myrow = Database::fetch_array($result); $output = ' '.$myrow['title']."
\n"; break; case TOOL_FORUM: $TBL_FORUMS = Database::get_course_table(TABLE_FORUM,$_course['database']); $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); $myrow = Database::fetch_array($result); $output = ' '.$myrow['forum_name']."
\n"; break; case TOOL_THREAD: //=topics //$tbl_forum = Database::get_course_table(TABLE_FORUM,$_course['database']); //$tbl_thread = Database::get_course_table(TABLE_FORUM_THREAD,$_course['database']); $tbl_post = Database::get_course_table(TABLE_FORUM_POST,$_course['database']); // grabbing the title of the post $sql_title = "SELECT * FROM $tbl_post WHERE post_id=".$id; $result_title = Database::query($sql_title); $myrow_title = Database::fetch_array($result_title); $output = ' '.$myrow_title['post_title']."
\n"; break; case TOOL_POST: $tbl_post = Database::get_course_table(TABLE_FORUM_POST,$_course['database']); //$tbl_post_text = Database::get_course_table(FORUM_POST_TEXT_TABLE); $sql = "SELECT * FROM $tbl_post p WHERE p.post_id = $id"; $result = Database::query($sql); $post = Database::fetch_array($result); $output = ' '.$post['post_title']."
\n"; break; case TOOL_DOCUMENT: $tbl_doc = Database::get_course_table(TABLE_DOCUMENT,$_course['database']); $result = Database::query("SELECT * FROM $tbl_doc WHERE id=$id"); $myrow = Database::fetch_array($result); $pathname = explode('/',$myrow['path']); // making a correct name for the link $last = count($pathname) - 1; // making a correct name for the link $filename = $pathname[$last]; // making a correct name for the link $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."
\n"; break; /* case 'Externallink': $output = ' '.$id."
\n"; break; */ } return $output; } /** * Returns an HTML-formatted link to a resource, to incorporate directly into * the new learning path tool. * * The function is a big switch on tool type. * In each case, we query the corresponding table for information and build the link * with that information. * @author Yannick Warnier - rebranding based on previous work (display_addedresource_link_in_learnpath()) * @param string Course code * @param integer The learning path ID (in lp table) * @param integer The database ID for that item in the lp_item table * @param * @param string Type (as one of the TOOL_ constants declared in main_api.lib.php) * @param integer ID of the database item to get (from that tool's table) * @param id - that is the correspondent id in the mirror tool (like Agenda item 2) * @param id_in_path - the unique index in the items table */ function rl_get_resource_link_for_learnpath($course_code, $learnpath_id, $id_in_path) { //error_log('In rl_get_resource_link_for_learnpath()',0); $_course = Database::get_course_info($course_code); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $sql_item = "SELECT * FROM $tbl_lp_item " . "WHERE lp_id = $learnpath_id AND id = $id_in_path"; $res_item = Database::query($sql_item); if(Database::num_rows($res_item)<1) return -1; //exit $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['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,$_course['database']); $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE 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,$_course['database']); $sql = "SELECT * FROM $TBL_EXERCICES WHERE 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/exercice_submit.php?lp_init=1&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$id_in_path.'&exerciseId='.$id; } break; case "hotpotatoes": //lowercase because of strtolower above $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE 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; break; case TOOL_FORUM: $link .= $main_dir_path.'forum/viewforum.php?forum='.$id.'&lp=true&origin=learnpath'; break; case TOOL_THREAD: //forum post $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD,$_course['database']); if(!empty($id)) { $sql="SELECT * FROM $tbl_topics where 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,$_course['database']); $result= Database::query("SELECT * FROM $tbl_post where post_id=$id"); $myrow=Database::fetch_array($result); $title=$myrow['post_title']; //$desc=$row_item['description']; $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,$_course['database']); $sql = "SELECT * FROM $tbl_doc WHERE id=$id"; $result=Database::query($sql); $myrow=Database::fetch_array($result); $docurl=str_replace('%2F','/',urlencode($myrow['path'])); $link .= $main_course_path.'document'.$docurl.'?'.api_get_cidreq(); $openmethod=2; $officedoc=false; api_session_register('openmethod'); api_session_register('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": //DEPRECATED $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; }//end switch return $link; } /** * Gets the name of a resource (generally used in learnpath when no name is provided) * * @author Yannick Warnier , Dokeos - rebranding * @param string Course code * @param string The tool type (using constants declared in main_api.lib.php) * @param integer The resource ID */ function rl_get_resource_name($course_code, $learnpath_id, $id_in_path) { $_course = Database::get_course_info($course_code); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $sql_item = "SELECT * FROM $tbl_lp_item " . "WHERE lp_id = $learnpath_id AND id = $id_in_path"; $res_item = Database::query($sql_item); if(Database::num_rows($res_item)<1) { return ''; //exit } $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,$_course['database']); $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); $myrow = Database::fetch_array($result); $output = $myrow['title']; break; case TOOL_ANNOUNCEMENT: $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT,$_course['database']); $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); $myrow = Database::fetch_array($result); $output = $myrow['title']; break; case TOOL_LINK: //doesn't take $target into account $TABLETOOLLINK = Database::get_course_table(TABLE_LINK,$_course['database']); $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); $myrow = Database::fetch_array($result); $output = $myrow['title']; break; case TOOL_QUIZ: $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST,$_course['database']); $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); $myrow = Database::fetch_array($result); $output = $myrow['title']; break; case TOOL_FORUM: $TBL_FORUMS = Database::get_course_table(TABLE_FORUM,$_course['database']); $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); $myrow = Database::fetch_array($result); $output = $myrow['forum_name']; break; case TOOL_THREAD: //=topics $tbl_post = Database::get_course_table(TABLE_FORUM_POST,$_course['database']); // grabbing the title of the post $sql_title = "SELECT * FROM $tbl_post WHERE 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,$_course['database']); //$tbl_post_text = Database::get_course_table(FORUM_POST_TEXT_TABLE); $sql = "SELECT * FROM $tbl_post p WHERE 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,$_course['database']); $result = Database::query("SELECT * FROM $tbl_doc WHERE id=$id"); $myrow = Database::fetch_array($result); $pathname = explode('/',$myrow['path']); // making a correct name for the link $last = count($pathname) - 1; // making a correct name for the link $filename = $pathname[$last]; // making a correct name for the link $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; /* case 'externallink': $output = ' '.$id."
\n"; break; */ } return stripslashes($output); } ?>