Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
242 lines (227 loc) · 13.7 KB
/
Copy pathindex.php
File metadata and controls
242 lines (227 loc) · 13.7 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?php
require_once "../config.php";
require_once "./terms.php";
use \Tsugi\Core\LTIX;
$LAUNCH = LTIX::requireData();
$p = $CFG->dbprefix;
if (!$USER->instructor) {
?>
<link rel="stylesheet" href="css/learner.css" type="text/css">
<?php
echo '<p class="learner-text">This tool is for instructors only.</p>';
return;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!isset($_POST["action"])) {
$_SESSION["error"] = "Unable to process that action. Please try again.";
header('Location: ' . addSession('index.php'));
}
if ($_POST["action"] == "add") {
// Add new course plan and go to planner
$term = (is_numeric($_POST["term"]) ? (int) $_POST["term"] : 202080);
$newStmt = "INSERT INTO {$p}course_planner_main (user_id, title, term) VALUES (:userId, :title, :term);";
$arr = array(':userId' => $USER->id, ':title' => $_POST["title"], ":term" => $term);
$PDOX->queryDie($newStmt, $arr);
$course_id = $PDOX->lastInsertId();
$_SESSION["success"] = "Course plan saved successfully.";
header('Location: ' . addSession('edit.php?course='.$course_id));
}
}
$menu = new \Tsugi\UI\MenuSet();
$menu->setHome('Course Planner', 'index.php');
$OUTPUT->header();
?>
<link rel="stylesheet" href="css/planner.css" type="text/css">
<?php
$OUTPUT->bodyStart();
$OUTPUT->topNav($menu);
echo '<div class="container-fluid">';
$OUTPUT->flashMessages();
?>
<div class="row" style="margin-top: 3.23rem;margin-bottom:2rem;">
<div class="col-sm-5">
<h2 style="margin-top:0;">Course Planner</h2>
<p>
Planning is an essential first step in constructing and delivering a quality course. There are many key decisions that must be made up front that inform how a course will ultimately be constructed.
</p>
<ul>
<li>What topics will I cover and what order should they be delivered in?</li>
<li>How many assignments should I have?</li>
<li>What readings or lecture materials will I need to provide if I'm going to ask them to participate in a discussion?</li>
<li>When will I deliver my first test?</li>
<li>How will the holiday schedule affect my course?</li>
</ul>
<p>
Course Planner is a simple utility tool designed to help faculty start laying out the key elements of a course. It also provides a great way to visualize how all of the elements will fit together. Faculty can create as many individual course plans as they want and each course plan can be shared with colleagues for easy collaboration.
</p>
</div>
<div class="col-sm-7">
<div class="planbox">
<a href="#addPlanModal" data-toggle="modal" class="btn btn-link pull-right"><span class="fas fa-plus" aria-hidden="true"></span> Add Course Plan</a>
<h3 style="margin:0;">My Course Plans</h3>
<?php
$plansqry = $PDOX->prepare("SELECT * FROM {$p}course_planner_main WHERE user_id = :user_id ORDER BY term desc, title");
$plansqry->execute(array(":user_id" => $USER->id));
$plans = $plansqry->fetchAll(PDO::FETCH_ASSOC);
if (!$plans) {
echo '<p style="clear:right;"><em>No course plans created yet.</em></p>';
} else {
echo '<p>Click on the title of a plan below to edit.</p>';
$current_term = -1;
foreach ($plans as $plan) {
$sharestmt = $PDOX->prepare("SELECT count(*) as total FROM {$p}course_planner_share WHERE course_id = :course_id");
$sharestmt->execute(array(":course_id" => $plan["course_id"]));
$sharecount = $sharestmt->fetch(PDO::FETCH_ASSOC);
if ($current_term != $plan["term"]) {
if ($current_term != -1) {
echo '</div>'; // End list group if not first iteration
}
$current_term = $plan["term"];
$termTitle = getTerm($current_term);
echo '<h5>'.$termTitle.'</h5>';
echo '<div class="list-group">';
}
echo '<div class="list-group-item h4">';
echo '<a href="edit.php?course='.$plan["course_id"].'"><span class="fas fa-cube" style="padding-right:8px;" aria-hidden="true"></span> '.$plan["title"].'</a> ';
if ($sharecount["total"] > 1) {
echo '<span data-toggle="tooltip" title="Shared with multiple people"><span class="fas fa-users fa-fw" aria-hidden="true"></span></span>';
} else if ($sharecount["total"] > 0) {
echo '<span data-toggle="tooltip" title="Shared with one other person"><span class="fas fa-user-friends fa-fw" aria-hidden="true"></span></span>';
}
echo '<div class="pull-right">
<a href="preview.php?course='.$plan["course_id"].'" class="plan-link" title="Preview"><span class="far fa-eye" aria-hidden="true"></span><span class="sr-only">Preview</span></a>
<a href="share.php?course='.$plan["course_id"].'" class="plan-link" title="Share"><span class="fas fa-user-plus" aria-hidden="true"></span><span class="sr-only">Share</span></a>
<a href="copyplan.php?course='.$plan["course_id"].'" class="plan-link" title="Copy"><span class="far fa-clone" aria-hidden="true"></span><span class="sr-only">Copy</span></a>
<a href="javascript:void(0);" class="plan-link rename-link" title="Rename" data-course="'.$plan["course_id"].'" data-plantitle="'.$plan["title"].'" data-term="'.$plan["term"].'">
<span class="fas fa-pencil-alt" aria-hidden="true"></span><span class="sr-only">Rename</span>
</a>
<a href="deleteplan.php?course='.$plan["course_id"].'" onclick="return confirm(\'Are you sure you want to delete this course plan? Deleting a course plan also deletes it for everyone it was shared with. This can not be undone.\');" class="plan-link" title="Delete"><span class="far fa-trash-alt" aria-hidden="true"></span><span class="sr-only">Delete</span></a>
</div>';
echo '</div>';
}
echo '</div>';
}
$sharedplansqry = $PDOX->prepare("SELECT m.course_id as course_id, m.title as title, m.user_id as creator_id, s.can_edit as can_edit, m.term as term FROM
{$p}course_planner_share s join {$p}course_planner_main m on s.course_id = m.course_id
WHERE s.user_email = :email ORDER BY m.term desc, m.title");
$sharedplansqry->execute(array(":email" => $USER->email));
$shared_plans = $sharedplansqry->fetchAll(PDO::FETCH_ASSOC);
?>
<hr />
<h4>Shared with me</h4>
<?php
if (!$shared_plans) {
echo '<p><em>No shared course plans yet.</em></p>';
} else {
echo '<div class="list-group">';
$current_term = -1;
foreach ($shared_plans as $shared_plan) {
// Get owner's name
$displayname_qry = "SELECT displayname FROM {$p}lti_user WHERE user_id = :user_id;";
$displayname_arr = array(':user_id' => $shared_plan["creator_id"]);
$lti_user = $PDOX->rowDie($displayname_qry, $displayname_arr);
$displayname = $lti_user ? $lti_user["displayname"] : "";
if ($current_term != $shared_plan["term"]) {
if ($current_term != -1) {
echo '</div>'; // End list group if not first iteration
}
$current_term = $shared_plan["term"];
$termTitle = getTerm($current_term);
echo '<h5>'.$termTitle.'</h5>';
echo '<div class="list-group">';
}
echo '<div class="list-group-item h4">';
echo '<a href="edit.php?course='.$shared_plan["course_id"].'"><span class="fas fa-cube" style="padding-right:8px;" aria-hidden="true"></span> '.$shared_plan["title"].'</a> ';
echo '<span data-toggle="tooltip" title="Owner: '.$displayname.'"><span class="fas fa-user-shield" aria-hidden="true"></span><span class="sr-only">Owner</span></span>';
echo '<div class="pull-right">';
if ($shared_plan["can_edit"] == 0) {
echo '<span data-toggle="tooltip" title="Read-only access" class="fas fa-lock" style="padding-left:8px;" aria-hidden="true"></span><span class="sr-only">Read-only</span>';
}
echo ' <a href="preview.php?course='.$shared_plan["course_id"].'" class="plan-link" title="Preview"><span class="far fa-eye" aria-hidden="true"></span><span class="sr-only">Preview</span></a>
<a href="copyplan.php?course='.$shared_plan["course_id"].'" class="plan-link" title="Copy"><span class="far fa-clone" aria-hidden="true"></span><span class="sr-only">Copy</span></a>
<a href="unshare.php?course='.$shared_plan["course_id"].'&email='.urlencode($USER->email).'" onclick="return confirm(\'Are you sure you want to remove your access to this plan. The creator of the plan will need to grant you access to undo this action.\');" class="plan-link" title="Remove from my list"><span class="fas fa-user-slash" aria-hidden="true"></span><span class="sr-only">Remove from my list</span></a>
</div>';
echo '</div>';
}
echo '</div>';
}
?>
</div>
</div>
</div>
<div id="addPlanModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add New Course Plan</h4>
</div>
<div class="modal-body">
<form class="form" method="post">
<input type="hidden" name="action" value="add">
<div class="form-group">
<label for="planTitle" id="planTitleLabel">Course Plan Title</label>
<input type="text" class="form-control" name="title" id="planTitle" value="" placeholder="e.g. TST 100 (Fall 2020)" required autofocus>
</div>
<div class="form-group">
<label for="term">Term Schedule</label>
<select id="term" name="term" class="form-control">
<?= renderTermOptions(); ?>
</select>
</div>
<button type="submit" class="btn btn-primary">Save</button> <button type="button" class="btn btn-link" data-dismiss="modal">Cancel</button>
</form>
</div>
</div>
</div>
</div>
<div id="renameModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Update <span id="renameHeader"></span></h4>
</div>
<div class="modal-body">
<form class="form" method="post" action="renameplan.php">
<input type="hidden" id="renameCourse" name="course" value="">
<input type="hidden" name="back" value="index">
<div class="form-group">
<label for="planTitle" id="planTitleLabel">Course Plan Title</label>
<input type="text" class="form-control" name="title" id="renameTitle" value="" placeholder="e.g. TST 100 (Fall 2020)" required autofocus>
</div>
<div class="form-group">
<label for="renameTerm">Term Schedule</label>
<select id="renameTerm" name="term" class="form-control">
<?= renderTermOptions(null); ?>
</select>
</div>
<button type="submit" class="btn btn-primary">Save</button> <button type="button" class="btn btn-link" data-dismiss="modal">Cancel</button>
</form>
</div>
</div>
</div>
</div>
<?php
echo '</div>';// end container
$OUTPUT->footerStart();
?>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
$("a.rename-link").off("click").on("click", function() {
let course = $(this).data("course");
let plantitle = $(this).data("plantitle");
let term = $(this).data("term");
$("#renameCourse").val(course);
$("#renameTitle").val(plantitle);
$('#renameTerm option[value="'+term+'"]').prop("selected", true);
$("#renameHeader").text(plantitle);
$("#renameModal").modal("show");
});
});
</script>
<?php
$OUTPUT->footerEnd();