-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.php
677 lines (606 loc) · 24 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
<?php
require_once "../config.php";
use \Tsugi\Blob\BlobUtil;
require_once "peer_util.php";
use \Tsugi\Util\U;
use \Tsugi\Core\Cache;
use \Tsugi\Core\Settings;
use \Tsugi\Core\LTIX;
use \Tsugi\Util\LTI;
use \Tsugi\UI\SettingsForm;
// Sanity checks
$LAUNCH = LTIX::requireData();
$p = $CFG->dbprefix;
if ( SettingsForm::handleSettingsPost() ) {
header( 'Location: '.addSession('index') ) ;
return;
}
// Grab the due date information
$dueDate = SettingsForm::getDueDate();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_POST) < 1 ) {
$_SESSION['error'] = 'File upload size exceeded, please re-upload a smaller file';
error_log("Upload size exceeded");
header('Location: '.addSession('index'));
return;
}
// Model
$row = loadAssignment();
$assn_json = null;
$assn_id = false;
if ( $row !== false && U::isNotEmpty($row['json']) ) {
$assn_json = json_decode(upgradeSubmission($row['json']));
$assn_id = $row['assn_id'];
}
$upload_max_size_bytes = BlobUtil::maxUploadBytes();
$image_max = isset($assn_json->image_size) ? (int) $assn_json->image_size : 0;
$image_max = $image_max * 1024 * 1024;
if ( $image_max == 0 ) $image_max = $upload_max_size_bytes;
$image_max_text = U::displaySize($image_max);
$pdf_max = isset($assn_json->pdf_size) ? (int) $assn_json->pdf_size : 0;
$pdf_max = $pdf_max * 1024 * 1024;
if ( $pdf_max == 0 ) $pdf_max = $upload_max_size_bytes;
$pdf_max_text = U::displaySize($pdf_max);
// Load up the submission and parts if they exist
$submit_id = false;
$submit_row = loadSubmission($assn_id, $USER->id);
if ( $submit_row !== false ) $submit_id = $submit_row['submit_id'];
// Handle the submission post
if ( $assn_id != false && $assn_json != null &&
isset($_POST['notes']) && isset($_POST['doSubmit']) ) {
if ( $submit_row !== false ) {
$_SESSION['error'] = 'Cannot submit an assignment twice';
header( 'Location: '.addSession('index') ) ;
return;
}
/* TODO: Remove this
// Check all files to be within our size limit
foreach($_FILES as $fdes) {
if ( $fdes['size'] > 1024*1024 ) {
$_SESSION['error'] = 'Error - '.$fdes['name'].' has a size of '.$fdes['size'].' (1M max size per file)';
header( 'Location: '.addSession('index') ) ;
return;
}
}
*/
$blob_ids = array();
$urls = array();
$code_ids = array();
$html_ids = array();
$content_items = array();
$partno = 0;
foreach ( $assn_json->parts as $part ) {
if ( $part->type == 'image' || $part->type == 'pdf') {
$fname = 'uploaded_file_'.$partno;
if( ! isset($_FILES[$fname]) ) {
$_SESSION['error'] = 'Problem with uploaded files - perhaps your files were too large';
header( 'Location: '.addSession('index') ) ;
return;
}
$fdes = $_FILES[$fname];
$filename = isset($fdes['name']) ? basename($fdes['name']) : false;
// Check to see if they left off a file
if( $fdes['error'] == 4) {
$_SESSION['error'] = 'Missing file, make sure to select all files before pressing submit';
header( 'Location: '.addSession('index') ) ;
return;
}
$filesize = $part->type == 'image' ? $assn_json->image_size : $assn_json->pdf_size;
$filesize = $filesize * 1024 * 1024;
if ( $filesize == 0 ) $filesize = $upload_max_size_bytes;
$filesize_text = U::displaySize($filesize);
if ( $fdes['size'] > $filesize ) {
$_SESSION['error'] = 'Error - '.$fdes['name'].' has a size of '.$fdes['size'].' which is > '.$filesize_text;
header( 'Location: '.addSession('index') ) ;
return;
}
// Sanity-check the file
$mime_types = $part->type == 'image' ? array("image/png", "image/jpeg") : array("application/pdf");
$safety = BlobUtil::checkFileSafety($fdes, $mime_types);
if ( $safety !== true ) {
$_SESSION['error'] = "Error: ".$safety;
error_log("Upload Error: ".$safety);
header( 'Location: '.addSession('index') ) ;
return;
}
// Check the kind of file
if ( $part->type == 'image' && ! BlobUtil::isPngOrJpeg($fdes) ) {
$_SESSION['error'] = 'Files must either contain JPG, or PNG images: '.$filename;
error_log("Upload Error - Not an Image: ".$filename);
header( 'Location: '.addSession('index') ) ;
return;
}
// Indicate this is not really used yet in case the submission is not saved
// We update this by calling setBackref after the submission is complete
$backref = "{$p}peer_submit::submit_id::-1";
$SAFETY_CHECK=true;
$blob_id = BlobUtil::uploadToBlob($fdes, $SAFETY_CHECK, $backref);
if ( $blob_id === false ) {
$_SESSION['error'] = 'Problem storing file in server: '.$filename;
header( 'Location: '.addSession('index') ) ;
return;
}
$blob_ids[] = $blob_id;
} else if ( $part->type == 'url' ) {
$url = $_POST['input_url_'.$partno];
if ( strpos($url,'http://') === false && strpos($url,'https://') === false ) {
$_SESSION['error'] = 'URLs must start with http:// or https:// ';
header( 'Location: '.addSession('index') ) ;
return;
}
$urls[] = $_POST['input_url_'.$partno];
} else if ( $part->type == 'content_item' ) {
$content_item = $_POST['input_content_item_'.$partno];
$content_data = json_decode($content_item);
if ( $content_data === null || ! isset($content_data->url)) {
$_SESSION['error'] = 'ContentItems must be valid JSON';
header( 'Location: '.addSession('index') ) ;
return;
}
$content_items[] = $content_data;
} else if ( $part->type == 'code' ) {
$code = $_POST['input_code_'.$partno];
if( U::isEmpty($code) ) {
$_SESSION['error'] = 'Missing: '.$part->title;
header( 'Location: '.addSession('index') ) ;
return;
}
$PDOX->queryDie("
INSERT INTO {$p}peer_text
(assn_id, user_id, data, created_at, updated_at)
VALUES ( :AID, :UID, :DATA, NOW(), NOW() )",
array(
':AID' => $assn_id,
':DATA' => $code,
':UID' => $USER->id)
);
$code_ids[] = $PDOX->lastInsertId();
} else if ( $part->type == 'html' ) {
$html = $_POST['input_html_'.$partno];
if( U::isEmpty($html) ) {
$_SESSION['error'] = 'Missing: '.$part->title;
header( 'Location: '.addSession('index') ) ;
return;
}
$PDOX->queryDie("
INSERT INTO {$p}peer_text
(assn_id, user_id, data, created_at, updated_at)
VALUES ( :AID, :UID, :DATA, NOW(), NOW() )",
array(
':AID' => $assn_id,
':DATA' => $html,
':UID' => $USER->id)
);
$html_ids[] = $PDOX->lastInsertId();
}
$partno++;
}
$submission = new stdClass();
$submission->notes = $_POST['notes'];
$submission->blob_ids = $blob_ids;
$submission->urls = $urls;
$submission->codes = $code_ids;
$submission->htmls = $html_ids;
$submission->content_items = $content_items;
$json = json_encode($submission);
$stmt = $PDOX->queryReturnError(
"INSERT INTO {$p}peer_submit
(assn_id, user_id, json, created_at, updated_at)
VALUES ( :AID, :UID, :JSON, NOW(), NOW())
ON DUPLICATE KEY UPDATE json = :JSON, updated_at = NOW()",
array(
':AID' => $assn_id,
':JSON' => $json,
':UID' => $USER->id)
);
Cache::clear('peer_submit');
if ( $stmt->success ) {
$submit_id = $PDOX->lastInsertId();
// Mark our blobs as belonging to this submission
$backref = "{$p}peer_submit::submit_id::".$submit_id;
foreach($blob_ids as $file_id ) {
BlobUtil::setBackref($file_id, $backref);
}
$_SESSION['success'] = 'Assignment submitted';
header( 'Location: '.addSession('index') ) ;
} else {
$_SESSION['error'] = $stmt->errorImplode;
header( 'Location: '.addSession('index') ) ;
}
return;
}
// See if we are going to delete the submission
if ( isset($assn_json) && isset($assn_json->resubmit) &&
$assn_json->resubmit == "always" && $dueDate->dayspastdue <= 0 &&
$assn_id && $submit_id && isset($_POST['deleteSubmit']) ) {
deleteSubmission($row, $submit_row);
$msg = "Deleted submission for user ".$USER->id." ".$USER->email;
error_log($msg);
$_SESSION['success'] = "Submission deleted.";
header( 'Location: '.addSession('index') ) ;
return;
}
// Check to see how much grading we have done
$grade_count = 0;
$to_grade = 0;
if ( $assn_json && $assn_json->maxassess > 0 ) {
// See how much grading is left to do
$to_grade = loadUngraded($assn_id);
// See how many grades I have done
$grade_count = loadMyGradeCount($assn_id);
}
// Retrieve our grades...
$our_grades = retrieveSubmissionGrades($submit_id);
// Handle the flag...
if ( $assn_id != false && $assn_json != null && is_array($our_grades) &&
isset($_POST['submit_id']) && isset($_POST['grade_id']) && isset($_POST['note']) &&
isset($_POST['doFlag']) && $submit_id == $_POST['submit_id'] ) {
// Make sure we have a valid grade_id
$found = false;
foreach ( $our_grades as $grade ) {
if ( $grade['grade_id'] == $_POST['grade_id'] ) {
$found = true;
}
}
if ( ! $found ) {
$_SESSION['error'] = 'Cannot a grade that is not yours';
header( 'Location: '.addSession('index') ) ;
return;
}
$grade_id = $_POST['grade_id']+0;
$stmt = $PDOX->queryDie(
"INSERT INTO {$p}peer_flag
(submit_id, grade_id, user_id, note, created_at, updated_at)
VALUES ( :SID, :GID, :UID, :NOTE, NOW(), NOW())
ON DUPLICATE KEY UPDATE note = :NOTE, updated_at = NOW()",
array(
':SID' => $submit_id,
':GID' => $grade_id,
':UID' => $USER->id,
':NOTE' => $_POST['note'])
);
$_SESSION['success'] = "Flagged for the instructor to examine";
header( 'Location: '.addSession('index') ) ;
return;
}
$menu = false;
if ( $USER->instructor ) {
$menu = new \Tsugi\UI\MenuSet();
if ( $assn_json !== null ) {
$menu->addLeft('Student Data', 'admin');
}
$submenu = new \Tsugi\UI\Menu();
$submenu->addLink('Settings', '#', /* push */ false, SettingsForm::attr());
$submenu->addLink('Configure', 'configure');
$submenu->addLink('Send Grade', 'sendgrade.php');
if ( $CFG->launchactivity ) {
$submenu->addLink('Analytics', 'analytics');
}
if ( $assn_json != null && $assn_json->totalpoints > 0 ) {
$submenu->addLink('Maintenance', 'maint', 'target="_blank"');
}
$submenu->addLink('Debug Data', 'debug');
$menu->addRight('Instructor', $submenu);
}
// View
$OUTPUT->header();
?>
<link href="<?= U::get_rest_parent() ?>/static/prism.css" rel="stylesheet"/>
<!-- https://webaim.org/techniques/css/invisiblecontent/ -->
<script>
let html_loads = [];
</script>
<style>
.skipNav
{
position: absolute;
top: -30em;
left: -30em;
padding: 0 0 0 0;
}
</style>
<?php
$OUTPUT->bodyStart();
$OUTPUT->topNav($menu);
$OUTPUT->flashMessages();
?>
<div class="skipNav"><a href="access.php"
title="accessibility options for this assignment"
accesskey="a">Click here for accessibility options for this assignment</a></div>
<?php
if ( $USER->instructor ) {
SettingsForm::start();
SettingsForm::dueDate();
SettingsForm::done();
SettingsForm::end();
}
$OUTPUT->welcomeUserCourse();
if ( $assn_json != null ) {
echo('<div style="border: 1px solid black">');
echo("<p><h4>".$assn_json->title."</h4></p>\n");
echo('<p>'.htmlent_utf8($assn_json->description)."</p><p>\n");
echo('<p>'.htmlent_utf8($assn_json->grading)."\n");
if ( $assn_json->gallery != 'off' ) {
echo("<p>This assignment includes a public gallery where you can view all\n");
echo("student submissions.</p>\n");
}
if( isset($assn_json->assignment) ) {
echo('<br/>Assignment specification: <a href="'.$assn_json->assignment.'" target="_blank">');
echo($assn_json->assignment."</a>\n");
}
if( isset($assn_json->solution) ) {
echo('<br/>Sample solution: <a href="'.$assn_json->solution.'" target="_blank">');
echo($assn_json->solution."</a>\n");
}
echo('</p></div>');
}
if ( $assn_json == null ) {
echo('<p>This assignment is not yet configured</p>');
$OUTPUT->footer();
return;
}
$image_count = 0;
if ( $submit_row == false ) {
if ( $assn_json->gallery == 'always' ) {
echo('<p><a href="gallery.php" class="btn btn-default">View Student Submissions</a></p> '."\n");
}
echo("<p><b>Please Upload Your Submission:</b></p>\n");
echo('<form name="myform" enctype="multipart/form-data" method="post" action="'.
addSession('index').'">');
$partno = 0;
$content_items = array();
$html_items = array();
foreach ( $assn_json->parts as $part ) {
echo("\n<p>");
echo(htmlent_utf8($part->title)."\n");
if ( $part->type == "image" ) {
$image_count++;
echo('<input name="uploaded_file_'.$partno.'" data-max-size="'.$image_max.'"
accept="image/png, image/jpg"
type="file" class="tsugi_image"> (Please use PNG or JPG files '.$image_max_text.' max)</p>');
} else if ( $part->type == "pdf" ) {
$image_count++;
echo('<input name="uploaded_file_'.$partno.'" data-max-size="'.$pdf_max.'"
accept="application/pdf"
type="file" class="tsugi_pdf"> (Please upload a PDF '.$pdf_max_text.' max)</p>');
} else if ( $part->type == "content_item" ) {
$endpoint = $part->launch;
$info = LTIX::getKeySecretForLaunch($endpoint);
$content_items[] = $partno;
if ( $info === false ) {
echo('<p style="color:red">Unable to load key/secret for '.htmlentities($endpoint)."</p>\n");
} else {
$icon = $CFG->staticroot.'/font-awesome-4.4.0/png/check-square.png';
echo('<br/><button type="button" onclick="showModalIframe(\''.$part->title.'\',
\'content_item_dialog_'.$partno.'\',\'content_item_frame_'.$partno.'\', false); return false;">
Select/Create Item</button>'."\n");
echo('<img src="'.$icon.'" id="input_content_icon_'.$partno.'" style="display: none">'."\n");
echo('<br/><textarea name="input_content_item_'.$partno.'" id="input_content_item_'.$partno.'" rows="2" style="display: none; width: 90%"></textarea></p>');
}
} else if ( $part->type == "url" ) {
echo('<input name="input_url_'.$partno.'" type="url" size="80"></p>');
} else if ( $part->type == "code" ) {
echo('<br/><textarea name="input_code_'.$partno.'" rows="10" style="width: 90%"></textarea></p>');
} else if ( $part->type == "html" ) {
$html_items[] = $partno;
echo('<br/><textarea name="input_html_'.$partno.'" id="input_html_'.$partno.'" rows="10" style="width: 90%"></textarea></p>');
}
$partno++;
}
echo("<p>Enter optional comments below</p>\n");
echo('<textarea rows="5" style="width: 90%" name="notes"></textarea><br/>');
echo('<input type="submit" name="doSubmit" value="Submit" class="btn btn-default"> ');
$OUTPUT->exitButton('Cancel');
echo('</form>');
// Make all the dialogs here
$partno = 0;
foreach ( $assn_json->parts as $part ) {
if ( $part->type != "content_item" ) {
$partno++;
continue;
}
$return = $CFG->getCurrentUrlFolder()."/contentitem_return.php?partno=".$partno;
$return = addSession($return);
$parms = LTIX::getContentItem($return,array());
$endpoint = $part->launch;
$info = LTIX::getKeySecretForLaunch($endpoint);
$key = $info['key'];
$secret = $info['secret'];
$parms = LTI::signParameters($parms, $endpoint, "POST", $key, $secret,
"Begin Selection");
$content = LTI::postLaunchHTML($parms, $endpoint, true,
"width=\"100%\" height=\"500\" scrolling=\"auto\" frameborder=\"1\" transparency");
?>
<div id="content_item_dialog_<?= $partno ?>" title="Media dialog" style="display:none;">
<?= $content ?>
</div>
<?php
$partno++;
}
if ( $image_count > 0 ) {
$upload_max_size = ini_get('upload_max_filesize');
echo("\n<p>Make sure each uploaded image file is smaller than 1M. Total upload size limited to ");
echo(htmlent_utf8($upload_max_size)."</p>\n");
}
if ( isset($assn_json->totalpoints) && $assn_json->totalpoints > 0 ) {
echo("<p>");
echo(pointsDetail($assn_json));
echo("</p>");
}
$OUTPUT->footerStart();
?>
<script>
// Set up the checking of data-max-size in type="file" inputs
tsugiCheckFileMaxSize();
$('.basicltiDebugToggle').hide();
</script>
<script src="https://cdn.ckeditor.com/ckeditor5/16.0.0/classic/ckeditor.js"></script>
<script>
html_items = [];
<?php
foreach($html_items as $html_item) {
echo("html_items.push($html_item);\n");
}
?>
for(i=0; i< html_items.length; i++ ) {
var the_item = html_items[i];
ClassicEditor.defaultConfig = {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
// 'imageUpload',
'blockQuote',
'insertTable',
'mediaEmbed',
'undo',
'redo'
]
},
}
ClassicEditor
.create( document.querySelector( '#input_html_'+the_item )
).then(editor => {
// editor.isReadOnly = true;
} ).catch( error => {
console.error( error );
} );
console.log("Item", html_items[i]);
}
</script>
<?php
$OUTPUT->footerEnd();
return;
}
// We have a submission already
$submit_json = json_decode($submit_row['json']);
if ( $assn_json->maxassess > 0 ) {
if ( $submit_json && isset($submit_json->peer_exempt) ) {
echo("<p>You have no more peers to grade.</p>\n");
} else if ( count($to_grade) > 0 &&
($USER->instructor || $grade_count < $assn_json->maxassess ) ) {
if ( $assn_json->rating > 0 ) {
echo('<p><a href="grade" class="btn btn-default">Rate other students</a></p>'."\n");
} else {
echo('<p><a href="grade" class="btn btn-default">Review other students</a></p>'."\n");
}
// Add a done button if needed
echo("<p> You have reviewed ".$grade_count." other student submissions.
You must review at least ".$assn_json->minassess." submissions for
full credit on this assignment.\n");
if ( $assn_json->maxassess < 100 ) {
echo("You <i>can</i> review up to ".$assn_json->maxassess." submissions if you like.\n");
}
echo("</p>\n");
} else if ( count($to_grade) > 0 ) {
echo('<p>You have reviewed the maximum number of submissions. Congratulations!<p>');
} else {
echo('<p>There are no submisions ready to be reviewed. Please check back later.</p>');
}
}
if ( $assn_json->gallery != 'off') {
echo('<p><a href="gallery.php" class="btn btn-default">View All Submissions</a></p> '."\n");
}
echo("<p><b>Your Submission:</b></p>\n");
showSubmission($assn_json, $submit_json, $assn_id, $USER->id);
if ( $submit_row['inst_points'] > 0 ) {
echo("<p>Instructor grade on assignment: ". $submit_row['inst_points']."</p>\n");
}
if ( U::isNotEmpty($submit_row['inst_note']) ) {
echo("<p>Instructor Note:<br/>");
echo(htmlent_utf8($submit_row['inst_note']));
echo("</p>\n");
}
if ( $assn_json->maxassess < 1 ) {
// Do nothing
} else if ( count($our_grades) < 1 ) {
echo("<p>No peers have graded your submission yet.</p>");
} else {
echo("<div style=\"padding:3px\"><p>You have the following grades from other students:</p>");
echo('<table border="1" class="table table-hover table-condensed table-responsive"><tr>');
if ( $assn_json->peerpoints > 0 ) echo("<th>Points</th>");
echo("<th>Comments</th>");
if ( $assn_json->flag ) echo("<th>Action</th>");
echo("</tr>\n");
$max_points = false;
foreach ( $our_grades as $grade ) {
if ( $assn_json->peerpoints > 0 ) {
if ( $max_points === false ) $max_points = $grade['points'];
$show = $grade['points'];
if ( $show < $max_points ) $show = '';
echo("<tr><td>".$show."</td>");
}
echo("<td>".htmlent_utf8($grade['note'])."</td>\n");
if ( $assn_json->flag ) echo(
'<td><form><input type="submit" name="showFlag" value="Flag"'.
'onclick="$(\'#flag_grade_id\').val(\''.$grade['grade_id'].
'\'); $(\'#flagform\').toggle(); return false;" class="btn btn-danger">'.
'</form></td>');
echo("</tr>\n");
}
echo("</table>\n");
if ( $max_points !== false ) {
echo("<p>Your overall score from your peers: $max_points </p>\n");
}
}
if ( isset($assn_json->resubmit) && $assn_json->resubmit == 'always' && $dueDate->dayspastdue <= 0 ) {
echo('<p><form method = "post">
<input type="submit" name="deleteSubmit" value="Delete Your Submission" class="btn btn-danger"
onclick="return confirm(\'Are you sure you want to delete your submission?\');">
</form></p>
');
}
$OUTPUT->exitButton();
?>
<form method="post" id="flagform" style="display:none">
<p> </p>
<p>Please be considerate when flagging an item. It does not mean
that something is inappropriate - it simply brings the item to the
attention of the instructor.</p>
<input type="hidden" value="<?php echo($submit_id); ?>" name="submit_id">
<input type="hidden" value="<?php echo($USER->id); ?>" name="user_id">
<input type="hidden" value="" id="flag_grade_id" name="grade_id">
<textarea rows="5" cols="60" name="note"></textarea><br/>
<input type="submit" name="doFlag"
onclick="return confirm('Are you sure you want to bring this peer-grade entry to the attention of the instructor?');"
value="Submit To Instructor" class="btn btn-primary">
<input type="submit" name="doCancel" onclick="$('#flagform').toggle(); return false;" value="Cancel Flag" class="btn btn-default">
</form>
<p>
<?php if ( $assn_json->totalpoints > 0 ) { ?>
<div id="gradeinfo">Calculating grade....</div>
</p>
<script type="text/javascript">
function gradeLoad() {
window.console && console.log('Loading and updating your grade...');
$.getJSON('<?php echo(addSession('update_grade.php')); ?>', function(data) {
window.console && console.log(data);
if ( data.grade ) {
$("#gradeinfo").html('Your current grade is '+data.grade*100.0+'%');
} else {
$("#gradeinfo").html('You do not have a grade.');
window.console && console.log('Take a screen shot of the console output and send to support...');
}
});
}
</script>
<?php
}
$OUTPUT->footerStart();
$json_url = 'http://localhost:8888/py4e/mod/peer-grade/load_html.php?html_id=1&assn_id=1&user_id=6';
?>
<?php if ( $assn_json->totalpoints > 0 ) { ?>
<script type="text/javascript">
$(document).ready(function() {
gradeLoad();
} );
</script>
<?php } ?>
<script src="<?= U::get_rest_parent() ?>/static/prism.js" type="text/javascript"></script>
<?php
load_htmls();
$OUTPUT->footerEnd();