forked from atutor/ATutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
177 lines (145 loc) · 5.93 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
/************************************************************************/
/* ATutor */
/************************************************************************/
/* Copyright (c) 2002 - 2009 */
/* Inclusive Design Institute */
/* */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/************************************************************************/
//test
define('AT_INCLUDE_PATH', 'include/');
require(AT_INCLUDE_PATH . 'vitals.inc.php');
if (isset($_GET['cid'])) {
header('Location: '.$_base_href.'content.php?cid='.intval($_GET['cid']));
exit;
}
if (isset($_SESSION['course_id']))
$course_id = $_SESSION['course_id'];
else if (isset($_GET['p_course'])) // is set when pretty url is turned on and a public course is accessed
$course_id = $_GET['p_course'];
else // is set when guests access protected course
$course_id = $_GET['course'];
require(AT_INCLUDE_PATH . '../mods/_standard/tests/lib/test_result_functions.inc.php');
if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
$course_base_href = 'get.php/';
} else {
$course_base_href = 'content/' . $course_id . '/';
}
//query reading the type of home viewable. 0: icon view 1: detail view
$sql = "SELECT home_view FROM %scourses WHERE course_id = %d";
$row = queryDB($sql,array(TABLE_PREFIX, $course_id), TRUE);
$home_view = $row['home_view'];
// Get the course description to display in the description metadata
$sql2 = "SELECT description FROM %scourses WHERE course_id=%d";
$row2 = queryDB($sql2, array(TABLE_PREFIX, $course_id), TRUE);
if($row2['description'] != ''){
$content_description = $row2['description'];
}
// Enable drag and drop to reorder displayed modules when the module view mode is
// set to "detail view" and user role is instructor
if ($home_view == 1 && authenticate(AT_PRIV_ADMIN,AT_PRIV_RETURN))
{
$_custom_head .= '
<link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-text.css" />
<link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-theme-mist.css" />
<link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/framework/fss/css/fss-theme-hc.css" />
<link rel="stylesheet" type="text/css" href="'.AT_BASE_HREF.'jscripts/infusion/components/reorderer/css/Reorderer.css" />
<script type="text/javascript">
//<!--
jQuery(document).ready(function () {
var reorder_example_grid = fluid.reorderGrid("#details_view", {
selectors : {
movables : ".home_box"
/*,
grabHandle: ".home-title a"
*/
},
listeners: {
afterMove: function (item, requestedPosition, movables) {
//save the state to the db
var myDivs = jQuery ("div[class^=home_box]", "#details_view");
var moved_modules = "";
if (myDivs.constructor.toString().indexOf("Array")) // myDivs is an array
{
for (i=0; i<myDivs.length; i++)
moved_modules += myDivs[i].id+"|";
}
moved_modules = moved_modules.substring(0, moved_modules.length-1); // remove the last "|"
if (moved_modules != "")
jQuery.post("'.AT_BASE_HREF.'move_module.php", { "moved_modules":moved_modules, "from":"course_index" }, function(data) {});
}
},
styles: {
selected: "draggable_selected",
hover: "draggable_selected"
}
});
});
function remove_module(module)
{
jQuery.post("'.AT_BASE_HREF.'move_module.php", { "remove":module, "from":"course_index" }, function(data) {});
jQuery("div[id=\""+module.replace(/\//g,"-")+"\"]").hide("slow");
}
//-->
</script>
';
}
require(AT_INCLUDE_PATH . 'header.inc.php');
/* the "home" links: */
$home_links = get_home_navigation();
$savant->assign('home_links', $home_links);
/* the news announcements: */
$news = array();
$num_pages = 1;
$page = isset($_GET['p']) ? intval($_GET['p']) : 1;
if (!$page) {
$page = 1;
}
$module =& $moduleFactory->getModule(AT_MODULE_DIR_STANDARD.'/announcements');
if (!$module->isEnabled()) {
$result = FALSE;
$news = array();
} else {
$sql = "SELECT COUNT(*) AS cnt FROM %snews WHERE course_id=%d";
$row = queryDB($sql, array(TABLE_PREFIX, $course_id), TRUE);
}
if ($row['cnt'] > 0) {
$num_results = $row['cnt'];
$results_per_page = NUM_ANNOUNCEMENTS;
$num_pages = ceil($num_results / $results_per_page);
$count = (($page-1) * $results_per_page) + 1;
$offset = ($page-1)*$results_per_page;
$sql = "SELECT N.*, DATE_FORMAT(N.date, '%%Y-%%m-%%d %%H:%%i:%%s') AS date, first_name, last_name
FROM %snews N, %smembers M
WHERE N.course_id=%d
AND N.member_id = M.member_id
ORDER BY date DESC LIMIT %d, %d";
$news_rows = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $course_id, $offset,$results_per_page ));
foreach($news_rows as $row){
/* this can't be cached because it called _AT */
$news[$row['news_id']] = array(
'date' => AT_date( _AT('announcement_date_format'),
$row['date'],
AT_DATE_MYSQL_DATETIME),
'author' => $row['first_name'] . ' ' . $row['last_name'],
'title' => AT_print($row['title'], 'news.title'),
'body' => format_content($row['body'], $row['formatting'], $glossary));
}
}
$sql = "SELECT banner FROM %scourses WHERE course_id=%d";
$row = queryDB($sql, array(TABLE_PREFIX, $course_id), TRUE);
if ($row['banner'] != '') {
$savant->assign('banner', AT_print($row['banner'], 'courses.banner'));
} else {
$savant->assign('banner', '');
}
$savant->assign('view_mode', $home_view);
$savant->assign('announcements', $news);
$savant->assign('num_pages', $num_pages);
$savant->assign('current_page', $page);
$savant->display('index.tmpl.php');
require(AT_INCLUDE_PATH.'footer.inc.php');
?>