2 /****************************************************************/
\r
4 /****************************************************************/
\r
5 /* Copyright (c) 2002-2008 */
\r
6 /* Written by Greg Gay & Joel Kronenberg & Chris Ridpath */
\r
7 /* Inclusive Design Institute */
\r
8 /* http://atutor.ca */
\r
10 /* This program is free software. You can redistribute it and/or*/
\r
11 /* modify it under the terms of the GNU General Public License */
\r
12 /* as published by the Free Software Foundation. */
\r
13 /****************************************************************/
\r
15 define('AT_INCLUDE_PATH', '../../../include/');
\r
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
\r
17 authenticate(AT_PRIV_READING_LIST);
\r
19 if (isset($_GET['edit'])) {
\r
20 if (!isset($_GET['reading'])) {
\r
21 $msg->addError('NO_ITEM_SELECTED');
\r
22 header('Location: index_instructor.php');
\r
26 // reading ID of item that will be edited
\r
27 $_GET['reading'] = intval($_GET['reading']);
\r
29 // get resource ID of reading
\r
30 $sql = "SELECT resource_id FROM ".TABLE_PREFIX."reading_list WHERE course_id=$_SESSION[course_id] AND reading_id=$_GET[reading]";
\r
31 $result = mysql_query($sql, $db);
\r
32 if ($row = mysql_fetch_assoc($result)){
\r
33 // what kind of resource is it? (book, URL, file etc.)
\r
34 $sql = "SELECT type FROM ".TABLE_PREFIX."external_resources WHERE course_id=$_SESSION[course_id] AND resource_id=$row[resource_id]";
\r
35 $result = mysql_query($sql, $db);
\r
36 if ($row = mysql_fetch_assoc($result)){
\r
37 // display the correct page for editing the resource
\r
38 header('Location: edit_reading_'.substr($_rl_types[$row['type']], 3).'.php?id='. $_GET['reading']);
\r
42 $msg->addError('ITEM_NOT_FOUND');
\r
43 } else if (isset($_GET['delete'])) {
\r
44 if (!isset($_GET['reading'])) {
\r
45 $msg->addError('NO_ITEM_SELECTED');
\r
46 header('Location: index_instructor.php');
\r
49 $_GET['reading'] = intval($_GET['reading']);
\r
50 header('Location: delete_reading.php?id='. $_GET['reading']);
\r
52 } else if (isset($_GET['create'])){
\r
53 $_GET['new_reading'] = intval($_GET['new_reading']);
\r
55 if (isset($_rl_types[$_GET['new_reading']])){
\r
56 // Note: the '3' substring is used here to strip out the 'rl_' from the name
\r
57 header('Location: new_reading_'.substr($_rl_types[$_GET['new_reading']], 3).'.php');
\r
62 require(AT_INCLUDE_PATH.'header.inc.php');
\r
65 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
\r
66 <div class="input-form" style="width: 90%">
\r
67 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('create'); ?></legend>
\r
69 <label for="question"><?php echo _AT('rl_type_of_reading'); ?></label><br />
\r
70 <select name="new_reading" class="dropdown" id="type">
\r
72 <?php foreach ($_rl_types as $key => $value): ?>
\r
73 <option value="<?php echo $key; ?>"><?php echo _AT($value); ?></option>
\r
74 <?php endforeach; ?>
\r
78 <div class="row buttons">
\r
79 <input type="submit" name="create" value="<?php echo _AT('create'); ?>" />
\r
86 $sql = "SELECT * FROM ".TABLE_PREFIX."reading_list WHERE course_id=$_SESSION[course_id] ORDER BY date_start";
\r
87 $result = mysql_query($sql, $db);
\r
90 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
\r
91 <table class="data" style="width: 90%;">
\r
95 <th><?php echo _AT('rl_start'); ?></th>
\r
96 <th><?php echo _AT('rl_end'); ?></th>
\r
97 <th><?php echo _AT('title'); ?></th>
\r
98 <th><?php echo _AT('required'); ?></th>
\r
99 <th><?php echo _AT('comment'); ?></th>
\r
105 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
\r
106 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
\r
110 <?php if ($row = mysql_fetch_assoc($result)): ?>
\r
114 <?php // get the external resource using the resource ID from the reading
\r
115 $id = $row['resource_id'];
\r
116 $sql = "SELECT title FROM ".TABLE_PREFIX."external_resources WHERE course_id=$_SESSION[course_id] AND resource_id=$id";
\r
117 $resource_result = mysql_query($sql, $db);
\r
118 if ($resource_row = mysql_fetch_assoc($resource_result)){
\r
120 <tr onmousedown="document.form['t<?php echo $row['reading_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['reading_id']; ?>_0">
\r
122 <td><input type="radio" id="t<?php echo $row['reading_id']; ?>" name="reading" value="<?php echo $row['reading_id']; ?>"
\r
124 <?php // set first item as checked if nothing selected
\r
125 if (isset($_GET['reading'])){
\r
126 if ($_GET['reading'] == $row['reading_id']){
\r
127 echo ' checked="checked"';
\r
130 echo ' checked="checked"';
\r
131 $_GET['reading'] = $row['reading_id'];
\r
134 <td><?php if ($row['date_start'] == '0000-00-00'){
\r
137 echo AT_Date(_AT('rl_date_format'), $row['date_start'], AT_DATE_MYSQL_DATETIME);
\r
140 <td><?php if ($row['date_end'] == '0000-00-00'){
\r
143 echo AT_Date(_AT('rl_date_format'), $row['date_end'], AT_DATE_MYSQL_DATETIME);
\r
145 <td><label for="t<?php echo $row['reading_id'];?>"><strong><?php echo AT_print($resource_row['title'], 'reading_list.title'); ?></strong></label></td>
\r
146 <td><?php echo _AT ($row['required']); ?></td>
\r
147 <td><?php echo AT_print($row['comment'], 'reading_list.comment'); ?></td>
\r
152 <?php } while($row = mysql_fetch_assoc($result)); ?>
\r
156 <td colspan="6"><strong><?php echo _AT('none_found'); ?></strong></td>
\r
162 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>