-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
302 lines (259 loc) · 13.7 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
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?php
include_once("GradeInc.php");
$course = Course::createCourse();
$username = getUsername();
if ($username === "TIMED_OUT_USER") {
login();
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Grading Checker</title>
<script type="text/javascript" src="./js/jquery-3.7.1.min.js"></script>
<link rel="stylesheet" href="./css/jquery-ui.css">
<script type="text/javascript" src="./js/jquery-ui.1.13.2.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"
integrity="sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm"
crossorigin="anonymous"></script>
<script src="js/hotkey.js"></script>
<script type="text/javascript">
function redirectHTTPS() {
if (window.location.protocol !== "https:") {
window.location.href = "https:" + window.location.href.substring(window.location.protocol.length);
}
}
function raiseError(msg) {
var newDiv = '<div class="alert alert-danger alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Warning!</strong> ' + msg + '</div>';
$("#errorDiv").append(newDiv).hide().fadeIn("slow");
}
function restoreButton() {
$("#submitButton").removeClass("disabled").prop("disabled", false);
}
function validateSubmit() {
let title = 'Grading Checker';
$(document).prop('title', title);
$("#errorDiv").empty();
$("#submitButton").addClass("disabled").prop("disabled", true);
let hwNum = $("#hw_num").val();
let login = $("#cse_login").val();
let urlParams = new URLSearchParams(window.location.search);
let ticket = urlParams.get('ticket');
if (hwNum < 0) {
raiseError("You must choose a valid assignment number.");
restoreButton();
return false;
} else if (!login || login.trim().length === 0) {
raiseError("Enter your login.");
restoreButton();
return false;
}
$("#graderResultsHeader").html("<h2>Grader Results</h2>");
$("#graderResults").html("");
$("#graderResults").append("<div id='grade_content'><img src='images/loading.gif' alt='loading'/></div>");
$.ajax({
url: 'grade.php',
method: 'POST',
data: {
hw_num: hwNum,
cse_login: '<?php echo $username; ?>',
ticket,
},
success: function (data) {
$('#graderResults').html(data).hide().fadeIn("slow");
//add necessary classes for google code prettifier
// and run if code is displayed to student-facing interface
//$('pre').addClass('prettyprint linenums');
//PR.prettyPrint();
$(document).prop('title', `\u2714 ${title}`);
restoreButton();
},
error: function (xhr, statusText) {
$('#graderResults').html("<span style='color:red;font-weight:bold'>Internal Server Error</span>");
$(document).prop('title', `\u2716 ${title}`);
restoreButton();
},
dataType: 'html'
});
return false;
}
</script>
<script src="./google-code-prettify/run_prettify.js" defer></script>
<style type="text/css">
/* Necessary for wrapping long lines,
however it only breas on whitespace;
very long lines of "data" will still
extend past the pre area. */
pre {
white-space: pre-wrap;
border: 1px solid #d3d3d3;
padding: 10px;
}
/* Necessary for line numbering on every line */
li.L0, li.L1, li.L2, li.L3,
li.L5, li.L6, li.L7, li.L8 {
list-style-type: decimal !important;
}
@media (min-width: 768px) {
.right-button {
position: absolute;
right: 10px;
}
}
</style>
</head>
<body onload="redirectHTTPS()">
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="https://github.com/cbourke/grade" target="_blank">Webgrader</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<?php
if ($config['homepage']) {
print '<a class="nav-link" target="_blank" href="' . $config['homepage'] . '">' . $config['course_name'] . '</a>';
} else {
print '<a class="nav-link">' . $config['course_name'] . '</a>';
}
?>
</li>
<li>
<button class="btn btn-dark" data-toggle="modal" data-target="#modalHelp">Help</button>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown01" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">Resources</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="https://cse-apps.unl.edu/handin" target="_blank">Handin</a>
<a class="dropdown-item" href="https://canvas.unl.edu/" target="_blank">Canvas</a>
<a class="dropdown-item" href="https://computing.unl.edu/faq" target="_blank">System FAQ</a>
<a class="dropdown-item" href="https://computing.unl.edu/" target="_blank">Department Home</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item"
href="https://github.com/cbourke/grade/">Version <?php print $config['version']; ?></a>
</div>
</li>
<li class="right-button">
<button class="btn btn-dark" onclick="window.location.href='logout.php'">Logout</button>
</li>
</ul>
</div>
</nav>
<main role="main">
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<?php
if (!$course) {
print '<div class="alert alert-danger"><strong>Error!</strong> The grader has not been properly setup, please notify your instructor that the homework file has not been synched with the webhandin.</div>';
exit(1);
}
?>
<h4>Student Grader Interface</h4>
<p>This web interface allows you to run the same grading script
that we use in evaluating and grading your program(s).</p>
<div id="errorDiv"></div>
<div class="col-md-6">
<form name="grade_form" action="grade.php" method="post" onsubmit="return validateSubmit()">
<div class="form-group row">
<label for="cse_login" class="col-sm-3 col-form-label">Username</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="cse_login" value="<?php echo $username; ?>" disabled>
</div>
</div>
<div class="form-group row">
<label for="hw_num" class="col-sm-3 col-form-label">Assignment</label>
<div class="col-sm-9">
<select name="hw_num" class="custom-select" id="hw_num">
<option value="-1">(choose)</option>
<?php
foreach ($course->getAssignments() as $assign) {
$option = "<option value=\"" . $assign->getNumber() . "\"";
if (!$assign->hasGradeScript()) {
$option .= " disabled=\"disabled\"";
}
$option .= ">" . $assign->getNumber() . " " . $assign->getLabel() . "</option>\n";
print $option;
}
?>
</select>
<small class="form-text text-muted">Disabled assignments cannot be graded as the grade
script has not been setup.</small>
<?php
if (count($course->getAssignments()) == 0) {
$div = getBootstrapDiv("Error!", "The grader has not been properly setup, please notify your instructor that the homework file has not been synched with the webhandin.");
print $div;
}
?>
</div><!-- /.col-sm-9 -->
</div>
<div class="form-group row">
<label for="cse_password" class="col-sm-3 col-form-label"> </label>
<div class="col-sm-9">
<button id="submitButton" type="submit" class="btn btn-primary active">Grade Me</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="container-fluid" style="margin: auto">
<div id="graderResultsHeader"></div>
<div id="graderResults"></div>
</div>
<div style="color: white;"><?php print Egg::getEgg(); ?></div>
</main>
</body>
<div class="modal fade" id="modalHelp" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Webgrader Help</h4>
</div>
<div class="modal-body">
<h3>Frequently Asked Questions</h3>
<ol>
<li><b>What is webhandin?</b></li>
<p>Webhandin is our web-based interface that we use that allows you to hand-in electronic versions
of files (source, data, archive, JARs, etc.).
Instructions (how to create an account, reset a password, handin for a specific course) are
available on that page. Use webhandin to handin all electronic copies of your homework as
specified. You can re-handin any materials as many times as you want up to the due date. Older
versions are archived, but only the most recently handed-in version will be considered.</p>
<li><b>What is webgrader</b></li>
<p>Webgrader is the companion system that allows you to run the same script(s) that graders run when
they grade your assignments. You can use it to determine if your program(s) will compile and
execute as specified. You can regrade yourself as many times as you like. Keep in mind that
webgrader should be your last sanity check. It is not a useful tool for debugging or figuring
out what is wrong with your program(s). You should thoroughly test and debug your code prior to
using webgrader.</p>
<li><b>I tried to use webgrader, but it never came back with a response, my browser just sat there
loading.</b></li>
<p>Most likely, your program is either 1) stuck in an infinite loop, or 2) prompting a user for
input when no input is being given. You need to a) debug and thoroughly test your program before
you rely on the webgrader; and b) you need to follow instructions on how input should be given
and handled (command line arguments, not re-prompting when given bad input, etc.)</p>
<li><b>Okay, so webgrader is still failing, but I don't know why. Help!</b></li>
<p>Webgrader is not a debugging tool. You need to debug using the proper tools. Contact
your instructor.</p>
</ol>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</html>