http://atutor.ca/atutor/mantis/view.php?id=4602
authorcindy li <cli@ocad.ca>
Tue, 7 Dec 2010 17:12:08 +0000 (17:12 -0000)
committercindy li <cli@ocad.ca>
Tue, 7 Dec 2010 17:12:08 +0000 (17:12 -0000)
Display the turned-on student tools under the Student Tools entry in the sitemap.

docs/mods/_standard/sitemap/sitemap.php
docs/mods/_standard/student_tools/classes/StudentToolsUtil.class.php [new file with mode: 0644]
docs/mods/_standard/student_tools/index.php

index f1296b4..7f2cb64 100644 (file)
@@ -16,8 +16,17 @@ $page = 'sitemap';
 define('AT_INCLUDE_PATH', '../../../include/');
 require(AT_INCLUDE_PATH.'vitals.inc.php');
 require(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
+require(AT_INCLUDE_PATH.'../mods/_standard/student_tools/classes/StudentToolsUtil.class.php');
 
 require(AT_INCLUDE_PATH.'header.inc.php');
+
+function print_one_menu_item($text) {
+       echo '<br />';
+       echo '<img src="images/'.$rtl.'tree/tree_vertline.gif" alt="" class="img-size-tree" />';
+       echo '<img src="images/'.$rtl.'tree/tree_end.gif" alt="" class="img-size-tree" />';
+       echo '<img src="images/'.$rtl.'tree/tree_horizontal.gif" alt="" class="img-size-tree" />';
+       echo '&nbsp;'.$text;
+}
 ?>
 <div id="container" style="padding:2em; width:90%;">
 <?php
@@ -32,6 +41,7 @@ foreach ($_current_modules as $module) {
 
        if (substr($module, -14) == 'forum/list.php') {
                $forums = get_forums($_SESSION['course_id']);
+               
                if (is_array($forums)) {
                        foreach ($forums as $state=>$rows) {
                                $count = 0;
@@ -50,11 +60,21 @@ foreach ($_current_modules as $module) {
                                }
                        } 
                } else {
-                       echo '<br />';
-                       echo '<img src="images/'.$rtl.'tree/tree_vertline.gif" alt="" class="img-size-tree" />';
-                       echo '<img src="images/'.$rtl.'tree/tree_vertline.gif" alt="" class="img-size-tree" />';
-                       echo '<img src="images/'.$rtl.'tree/tree_end.gif" alt="" class="img-size-tree" />';
-                       echo _AT('no_forums');
+                       print_one_menu_item(_AT('no_forums'));
+               }
+       }
+       
+       // display the turned-on student tools
+       if (substr($module, -23) == 'student_tools/index.php') {
+               $student_tools = StudentToolsUtil::getStudentTools($_SESSION['course_id']);
+               
+               if (count($student_tools) == 0) {
+                       print_one_menu_item(_AT("no_student_tools"));
+               } else {
+                       foreach (get_home_navigation($student_tools) as $link) {
+                               $text = '<a href="'.$link['url'].'">'. $link['title'].'</a>';
+                               print_one_menu_item($text);
+                       }
                }
        }
 }
diff --git a/docs/mods/_standard/student_tools/classes/StudentToolsUtil.class.php b/docs/mods/_standard/student_tools/classes/StudentToolsUtil.class.php
new file mode 100644 (file)
index 0000000..064cafa
--- /dev/null
@@ -0,0 +1,47 @@
+<?php\r
+/************************************************************************/\r
+/* ATutor                                                               */\r
+/************************************************************************/\r
+/* Copyright (c) 2002 - 2009                                            */\r
+/* Inclusive Design Institute                                           */\r
+/*                                                                      */\r
+/* This program is free software. You can redistribute it and/or        */\r
+/* modify it under the terms of the GNU General Public License          */\r
+/* as published by the Free Software Foundation.                        */\r
+/************************************************************************/\r
+// $Id: ims_import.php 10319 2010-10-08 20:43:03Z hwong $\r
+\r
+/**\r
+* This class contains all the utility functions to set/get/clean progress \r
+* information\r
+* @access      public\r
+* @author      Cindy Qi Li\r
+*/\r
+if (!defined('AT_INCLUDE_PATH')) exit;\r
+\r
+class StudentToolsUtil {\r
+\r
+       /**\r
+        * Return an array of all the student tools for current course.\r
+        * Return an empty array if no student tools defined.\r
+        */\r
+       public static function getStudentTools($course_id) \r
+       {\r
+               global $db;\r
+               \r
+               $sql = "SELECT links FROM ".TABLE_PREFIX."fha_student_tools WHERE course_id=$course_id";\r
+               $result = mysql_query($sql, $db);\r
+               if ($row = mysql_fetch_assoc($result)) {\r
+                       $student_tools = explode('|', $row['links']);\r
+               }\r
+               // removed the empty array value\r
+               $cleaned_student_tools = array();\r
+               \r
+               foreach ($student_tools as $tool) {\r
+                       if (trim($tool) <> '') $cleaned_student_tools[] = $tool;\r
+               }\r
+               \r
+               return $cleaned_student_tools;\r
+       }\r
+}\r
+?>
\ No newline at end of file
index b4a396d..aa2a24e 100644 (file)
 
 define('AT_INCLUDE_PATH', '../../../include/');
 require (AT_INCLUDE_PATH.'vitals.inc.php');
+require ('classes/StudentToolsUtil.class.php');
 
-$fha_student_tools = array();
+$fha_student_tools = StudentToolsUtil::getStudentTools($_SESSION['course_id']);
 
-$sql = "SELECT links FROM ".TABLE_PREFIX."fha_student_tools WHERE course_id=$_SESSION[course_id]";
-$result = mysql_query($sql, $db);
-if ($row = mysql_fetch_assoc($result)) {
-       $fha_student_tools = explode('|', $row['links']);
-}
-
-if($fha_student_tools[0] == "" ){
+if(count($fha_student_tools) == "" ){
        $msg->addInfo('NO_TOOLS_FOUND');
 }