ATutor 2.0
[atutor.git] / mods / _standard / student_tools / index.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002 - 2009                                            */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 define('AT_INCLUDE_PATH', '../../../include/');
14 require (AT_INCLUDE_PATH.'vitals.inc.php');
15
16 $fha_student_tools = array();
17
18 $sql = "SELECT links FROM ".TABLE_PREFIX."fha_student_tools WHERE course_id=$_SESSION[course_id]";
19 $result = mysql_query($sql, $db);
20 if ($row = mysql_fetch_assoc($result)) {
21         $fha_student_tools = explode('|', $row['links']);
22 }
23
24 if($fha_student_tools[0] == "" ){
25         $msg->addInfo('NO_TOOLS_FOUND');
26 }
27
28 $sql = "SELECT home_view FROM ".TABLE_PREFIX."fha_student_tools WHERE course_id = $_SESSION[course_id]";
29 $result = mysql_query($sql,$db);
30 $row= mysql_fetch_assoc($result);
31 $home_view = $row['home_view'];
32
33 // Enable drag and drop to reorder displayed modules when the module view mode is 
34 // set to "detail view" and user role is instructor
35 if ($home_view == 1 && authenticate(AT_PRIV_ADMIN,AT_PRIV_RETURN))
36 {
37         $_custom_head .= '
38 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-layout.css" />
39 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-text.css" />
40 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-theme-mist.css" />
41 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-theme-hc.css" />
42 <link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/components/reorderer/css/Reorderer.css" />
43
44 <script type="text/javascript">
45 jQuery(document).ready(function () {
46         var reorder_example_grid = fluid.reorderGrid("#details_view",  {
47                 selectors : {
48                         movables : ".home_box"
49                 },
50             listeners: {
51                         afterMove: function (item, requestedPosition, movables) {
52                                 //save the state to the db
53                                 var myDivs = jQuery ("div[class^=home_box]", "#details_view");
54                                 var moved_modules = "";
55                                 
56                                 if (myDivs.constructor.toString().indexOf("Array"))   // myDivs is an array
57                                 {
58                                         for (i=0; i<myDivs.length; i++)
59                                                 moved_modules += myDivs[i].id+"|";
60                                 }
61                                 moved_modules = moved_modules.substring(0, moved_modules.length-1); // remove the last "|"
62                                 
63                                 if (moved_modules != "")
64                                         jQuery.post("'.AT_BASE_HREF.'move_module.php", { "moved_modules":moved_modules, "from":"student_tools" }, function(data) {});     
65                 }
66             },
67                 styles: {
68                     selected: "draggable_selected",
69                     hover: "draggable_selected"
70                 }
71 });
72
73 });
74
75 function remove_module(module)
76 {
77         jQuery.post("'.AT_BASE_HREF.'move_module.php", { "remove":module, "from":"student_tools" }, function(data) {});
78         jQuery("div[id="+module.replace(/\//g,"-")+"]").remove();
79 }
80
81 </script>
82         
83 ';
84 }
85
86 require (AT_INCLUDE_PATH.'header.inc.php');
87
88 $home_links = array();
89
90 if($fha_student_tools[0] != "" ){
91         //query reading the type of home viewable. 0: icon view   1: detail view
92         
93         $savant->assign('view_mode', $home_view);
94         $savant->assign('home_links', get_home_navigation($fha_student_tools));
95 }
96
97 $savant->assign('num_pages', 0);
98 $savant->assign('current_page', 0);
99 $savant->display('index.tmpl.php');
100
101 ?>
102
103
104 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>