-
Notifications
You must be signed in to change notification settings - Fork 65
/
turnitintooltwo_view.class.php
executable file
·2026 lines (1729 loc) · 108 KB
/
turnitintooltwo_view.class.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
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__."/lib.php");
require_once(__DIR__.'/turnitintooltwo_form.class.php');
require_once(__DIR__.'/turnitintooltwo_submission.class.php');
class turnitintooltwo_view {
/**
* Abstracted version of print_header() / header()
*
* @param string $url The URL of the page
* @param string $title Appears at the top of the window
* @param string $heading Appears at the top of the page
* @param bool $return If true, return the visible elements of the header instead of echoing them.
* @return mixed If return=true then string else void
*/
public function output_header($url, $title = '', $heading = '', $return = false) {
global $PAGE, $OUTPUT;
$PAGE->set_url($url);
$PAGE->set_title($title);
$PAGE->set_heading($heading);
if ($return) {
return $OUTPUT->header();
} else {
echo $OUTPUT->header();
}
}
/**
* Load the Javascript and CSS components for page.
*
* @global type $PAGE
*/
public function load_page_components($hidebg = false) {
global $PAGE;
// Include CSS.
if ($hidebg) {
$cssurl = new moodle_url('/mod/turnitintooltwo/css/hide_bg.css');
$PAGE->requires->css($cssurl);
}
$cssurl = new moodle_url('/mod/turnitintooltwo/styles.css');
$PAGE->requires->css($cssurl);
$cssurl = new moodle_url('/mod/turnitintooltwo/css/jquery-ui-1.8.4.custom.css');
$PAGE->requires->css($cssurl);
$cssurl = new moodle_url('/mod/turnitintooltwo/css/font-awesome.min.css');
$PAGE->requires->css($cssurl);
$cssurl = new moodle_url('/mod/turnitintooltwo/css/tii-icon-webfont.css');
$PAGE->requires->css($cssurl);
// Include JS.
$PAGE->requires->jquery();
$PAGE->requires->jquery_plugin('ui');
$PAGE->requires->jquery_plugin('turnitintooltwo-dataTables', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-dataTables_plugins', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-turnitintooltwo', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-turnitintooltwo_extra', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-turnitintooltwo_settings', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-datatables_columnfilter', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-colorbox', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-cookie', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-uieditable', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('turnitintooltwo-moment', 'mod_turnitintooltwo');
// Javascript i18n strings.
$PAGE->requires->string_for_js('close', 'turnitintooltwo');
$PAGE->requires->string_for_js('nointegration', 'turnitintooltwo');
$PAGE->requires->string_for_js('sprevious', 'turnitintooltwo');
$PAGE->requires->string_for_js('snext', 'turnitintooltwo');
$PAGE->requires->string_for_js('sprocessing', 'turnitintooltwo');
$PAGE->requires->string_for_js('szerorecords', 'turnitintooltwo');
$PAGE->requires->string_for_js('sinfo', 'turnitintooltwo');
$PAGE->requires->string_for_js('ssearch', 'turnitintooltwo');
$PAGE->requires->string_for_js('slengthmenu', 'turnitintooltwo');
$PAGE->requires->string_for_js('semptytable', 'turnitintooltwo');
$PAGE->requires->string_for_js('tiisubmissionsgeterror', 'turnitintooltwo');
$PAGE->requires->string_for_js('membercheckerror', 'turnitintooltwo');
$PAGE->requires->string_for_js('resubmissiongradewarn', 'turnitintooltwo');
$PAGE->requires->string_for_js('submitnothingwarning', 'turnitintooltwo');
$PAGE->requires->string_for_js('maxmarkserror', 'turnitintooltwo');
$PAGE->requires->string_for_js('disableanonconfirm', 'turnitintooltwo');
$PAGE->requires->string_for_js('closebutton', 'turnitintooltwo');
$PAGE->requires->string_for_js('loadingdv', 'turnitintooltwo');
$PAGE->requires->string_for_js('postdate_warning', 'turnitintooltwo');
$PAGE->requires->string_for_js('deleteconfirm', 'turnitintooltwo');
$PAGE->requires->string_for_js('turnitindeleteconfirm', 'turnitintooltwo');
$PAGE->requires->string_for_js('max_marks_warning', 'turnitintooltwo');
$PAGE->requires->string_for_js('download_button_warning', 'turnitintooltwo');
}
/**
* Output the Menu in the settings area as an HTML list
*
* @global type $CFG
* @global type $DB
* @return output the menu as an HTML list
*/
public function draw_settings_menu($cmd) {
global $CFG, $DB;
$tabs = array();
$tabs[] = new tabobject('settings', $CFG->wwwroot.'/admin/settings.php?section=modsettingturnitintooltwo',
get_string('settings', 'turnitintooltwo'), get_string('settings', 'turnitintooltwo'), false);
$tabs[] = new tabobject('viewreport', $CFG->wwwroot.'/mod/turnitintooltwo/settings_extras.php?cmd=viewreport',
get_string('showusage', 'turnitintooltwo'), get_string('showusage', 'turnitintooltwo'), false);
$tabs[] = new tabobject('savereport', $CFG->wwwroot.'/mod/turnitintooltwo/settings_extras.php?cmd=savereport',
get_string('saveusage', 'turnitintooltwo'), get_string('saveusage', 'turnitintooltwo'), false);
$tabs[] = new tabobject('apilog', $CFG->wwwroot.'/mod/turnitintooltwo/settings_extras.php?cmd=apilog',
get_string('logs'), get_string('logs'), false);
$tabs[] = new tabobject('unlinkusers', $CFG->wwwroot.'/mod/turnitintooltwo/settings_extras.php?cmd=unlinkusers',
get_string('unlinkusers', 'turnitintooltwo'), get_string('unlinkusers', 'turnitintooltwo'), false);
$tabs[] = new tabobject('files', $CFG->wwwroot.'/mod/turnitintooltwo/settings_extras.php?cmd=files',
get_string('files', 'turnitintooltwo'), get_string('files', 'turnitintooltwo'), false);
$tabs[] = new tabobject('courses', $CFG->wwwroot.'/mod/turnitintooltwo/settings_extras.php?cmd=courses',
get_string('restorationheader', 'turnitintooltwo'), get_string('restorationheader', 'turnitintooltwo'), false);
// Include Moodle v1 migration tab if v1 is installed.
$module = $DB->get_record('config_plugins', array('plugin' => 'mod_turnitintool'));
if ( $module ) {
$tabs[] = new tabobject('v1migration', $CFG->wwwroot.'/mod/turnitintooltwo/settings_extras.php?cmd=v1migration',
get_string('v1migrationtitle', 'turnitintooltwo'), get_string('v1migrationtitle', 'turnitintooltwo'), false);
}
$selected = ($cmd == 'activitylog') ? 'apilog' : $cmd;
// Read the LTI launch form in the output buffer and put in link to test Turnitin connection.
ob_start();
print_tabs(array($tabs), $selected);
$settingstabs = ob_get_contents();
ob_end_clean();
return $settingstabs;
}
/**
* Prints the tab link menu across the top of the activity module
*
* @param object $cm The moodle course module object for this instance
* @param object $selected The query string parameter to determine the page we are on
* @param array $notice
*/
public function draw_tool_tab_menu($cm, $selected) {
global $CFG;
$tabs = array();
if (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) {
$tabs[] = new tabobject('submissions', $CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.'&do=submissions',
get_string('allsubmissions', 'turnitintooltwo'), get_string('allsubmissions', 'turnitintooltwo'), false);
$tabs[] = new tabobject('tutors', $CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.'&do=tutors',
get_string('turnitintutors', 'turnitintooltwo'), get_string('turnitintutors', 'turnitintooltwo'), false);
$tabs[] = new tabobject('students', $CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.'&do=students',
get_string('turnitinstudents', 'turnitintooltwo'), get_string('turnitinstudents', 'turnitintooltwo'), false);
} else {
$tabs[] = new tabobject('submissions', $CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.'&do=submissions',
get_string('mysubmissions', 'turnitintooltwo'), get_string('mysubmissions', 'turnitintooltwo'), false);
}
print_tabs(array($tabs), $selected);
}
/**
* Configure html for a notice to be shown at the top of the screen if required
*
* @param type $notice
* @return mixed html containing notice
*/
public function show_notice($notice) {
global $OUTPUT;
return $OUTPUT->box($notice["message"], 'alert alert-'.$notice["type"], "alert");
}
public function show_digital_receipt($digitalreceipt) {
global $OUTPUT;
$receipt = html_writer::tag('p', get_string('submissionuploadsuccess', 'turnitintooltwo'),
array('class' => 'bold', 'id' => 'mod_turnitintooltwo_upload_success'));
$receipt .= html_writer::tag('h2', get_string('digitalreceipt', 'turnitintooltwo'),
array("id" => "digital_receipt"));
$receipt .= html_writer::tag('p', html_writer::tag('span',
get_string('turnitinsubmissionid', 'turnitintooltwo').":",
array('class' => 'bold'))." ".
html_writer::tag('span', $digitalreceipt["tii_submission_id"],
array('class' => 'tii_submission_id')));
$receipt .= html_writer::tag('p', get_string('submissionextract', 'turnitintooltwo').":", array('class' => 'bold'));
$receipt .= html_writer::tag('span', html_writer::tag('p', $digitalreceipt["extract"]), array('class' => 'extract_text'));
$icon = $OUTPUT->box($OUTPUT->pix_icon('icon', get_string('turnitin', 'turnitintooltwo'),
'mod_turnitintooltwo'), 'centered_div');
$output = $OUTPUT->box($icon.$receipt, 'generalbox', 'digital_receipt');
return $output;
}
/**
* Warning display to indicate duplicated assignments, normally as a result of a backup and restore
*
* @param object $cm The moodle course module object for this instance
* @param object $turnitintooltwo The turnitin assignment data object
* @return mixed Returns HTML duplication warning if the logged in users has grade rights otherwise null
*/
public function show_duplicate_assignment_warning($turnitintooltwoassignment, $parts) {
global $CFG, $OUTPUT;
$dups = array();
$output = '';
foreach ($parts as $part) {
$dupparts = $turnitintooltwoassignment->get_duplicate_parts($part->tiiassignid, $part->turnitintooltwoid);
$dups = array_merge($dups, $dupparts);
}
if (count($dups) > 0) {
$output .= $OUTPUT->box_start('generalbox boxaligncenter notepost', 'warning');
$output .= html_writer::tag("h3", get_string('notice'), array("class" => "error"));
$output .= html_writer::tag("p", get_string('duplicatesfound', 'turnitintooltwo'));
$listcourses = array();
foreach ($dups as $duppart) {
$listcourses[] = html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$duppart->cm_id,
$duppart->course_name.' (' . $duppart->course_shortname . ') - '.
$duppart->tool_name.' - ' . $duppart->partname);
}
$output .= html_writer::alist($listcourses);
$output .= $OUTPUT->box_end();
}
return $output;
}
/**
* Outputs the HTML for the submission form
*
* @global object $CFG
* @global object $OUTPUT
* @param object $cm The moodle course module object for this instance
* @param object $turnitintooltwoassignment The turnitintooltwo object for this activity
* @param int $partid The part id being submitted to
* @param int $userid The user id who the submission is for
* @param array $turnitintooltwofileuploadoptions upload options for the file manager
* @return string returns the HTML of the form
*/
public function show_submission_form($cm, $turnitintooltwoassignment, $partid, $turnitintooltwofileuploadoptions,
$viewcontext = "box", $userid = 0) {
global $CFG, $OUTPUT, $USER;
$output = "";
$config = turnitintooltwo_admin_config();
$istutor = has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id));
// Check if the submitting user has accepted the EULA.
$eulaaccepted = false;
if ($userid == $USER->id) {
$user = new turnitintooltwo_user($userid, "Learner");
$coursetype = turnitintooltwo_get_course_type($turnitintooltwoassignment->turnitintooltwo->legacy);
$coursedata = $turnitintooltwoassignment->get_course_data($turnitintooltwoassignment->turnitintooltwo->course, $coursetype);
$user->join_user_to_class($coursedata->turnitin_cid);
$eulaaccepted = ($user->useragreementaccepted != 1) ? $user->get_accepted_user_agreement() : $user->useragreementaccepted;
}
$parts = $turnitintooltwoassignment->get_parts_available_to_submit(0, $istutor);
if (!empty($parts)) {
$elements = array();
$elements[] = array('header', 'submitpaper', get_string('submitpaper', 'turnitintooltwo'));
$elements[] = array('hidden', 'submissionassignment', $turnitintooltwoassignment->turnitintooltwo->id);
$elements[] = array('hidden', 'action', 'submission');
// Get any previous submission to determine if this is a resubmission.
$prevsubmission = $turnitintooltwoassignment->get_user_submissions($userid, $turnitintooltwoassignment->turnitintooltwo->id, $partid);
if ($istutor || $eulaaccepted == 1) {
if ($prevsubmission && ($istutor || $turnitintooltwoassignment->turnitintooltwo->studentreports)) {
$genparams = turnitintooltwo_get_report_gen_speed_params();
$elements[] = array('html', '<div class="tii_checkagainstnote">' . get_string('reportgenspeed_resubmission', 'turnitintooltwo', $genparams) . '</div>');
}
// Upload type.
switch ($turnitintooltwoassignment->turnitintooltwo->type) {
case 0:
$options = $this->get_filetypes(false);
$elements[] = array('select', 'submissiontype', get_string('submissiontype', 'turnitintooltwo'),
'submissiontype', $options);
break;
case 1:
case 2:
$elements[] = array('hidden', 'submissiontype', $turnitintooltwoassignment->turnitintooltwo->type);
break;
}
// User id if applicable.
if ($istutor) {
$elements[] = array('hidden', 'studentsname', $userid);
}
// Submission Title.
$elements[] = array('text', 'submissiontitle', get_string('submissiontitle', 'turnitintooltwo'), 'submissiontitle', '',
'required', get_string('submissiontitleerror', 'turnitintooltwo'), PARAM_TEXT);
// Submission Part(s).
if ($partid == 0) {
$options = array();
foreach ($parts as $part) {
$options[$part->id] = $part->partname;
}
$elements[] = array('select', 'submissionpart', get_string('submissionpart', 'turnitintooltwo'),
'submissionpart', $options);
} else {
$elements[] = array('hidden', 'submissionpart', $partid);
}
// File input for uploads.
if ($turnitintooltwoassignment->turnitintooltwo->type == 0 || $turnitintooltwoassignment->turnitintooltwo->type == 1) {
$elements[] = array('filemanager', 'submissionfile', get_string('filetosubmit', 'turnitintooltwo'),
'filetosubmit', $turnitintooltwofileuploadoptions);
}
// Textarea.
if ($turnitintooltwoassignment->turnitintooltwo->type == 0) {
$elements[] = array('textarea', 'submissiontext', get_string('texttosubmit', 'turnitintooltwo'), 'texttosubmit');
} else if ($turnitintooltwoassignment->turnitintooltwo->type == 2) {
$elements[] = array('textarea', 'submissiontext', get_string('texttosubmit', 'turnitintooltwo'),
'texttosubmit', '', 'required', get_string('submissiontexterror', 'turnitintooltwo'),
PARAM_TEXT);
}
// Show agreement if applicable.
if ($istutor || empty($config->agreement)) {
$elements[] = array('hidden', 'submissionagreement', 1);
$customdata["checkbox_label_after"] = false;
} else {
$elements[] = array('advcheckbox', 'submissionagreement', $config->agreement, '', array(0, 1),
'required', get_string('copyrightagreementerror', 'turnitintooltwo'), PARAM_INT);
$customdata["checkbox_label_after"] = true;
}
}
// Output a link for the student to accept the turnitin licence agreement.
$noscripteula = "";
$eula = "";
if ($userid == $USER->id) {
if ($eulaaccepted != 1) {
$eula = html_writer::tag('p', get_string('turnitinula', 'turnitintooltwo'), array('class' => 'mod_turnitintooltwo_eula_text'));
$eula .= html_writer::tag('div', self::output_dv_launch_form("useragreement", 0, $user->tiiuserid,
"Learner", get_string('turnitinula_btn', 'turnitintooltwo'), false),
array('class' => 'mod_turnitintooltwo_eula', 'data-userid' => $userid));
$noscripteula = html_writer::tag('noscript',
$this->output_dv_launch_form("useragreement", 0, $user->tiiuserid, "Learner",
get_string('turnitinula', 'turnitintooltwo'), false)." ".
get_string('noscriptula', 'turnitintooltwo'),
array('class' => 'warning mod_turnitintooltwo_eula_noscript'));
}
}
$customdata["elements"] = $elements;
$customdata["show_cancel"] = false;
// Determine which label to show based on whether this is a resubmission.
$submitstr = (count($prevsubmission) == 0) ? 'addsubmission' : 'resubmission';
$customdata["submit_label"] = get_string($submitstr, 'turnitintooltwo');
$customdata["disable_form_change_checker"] = true;
$optionsform = new turnitintooltwo_form($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.
'&do=submitpaper&view_context='.$viewcontext, $customdata);
$output .= $eula.$noscripteula;
$output .= $OUTPUT->box($optionsform->display(), "submission_form_container");
$turnitincomms = new turnitintooltwo_comms();
$turnitincall = $turnitincomms->initialise_api();
$customdata = array("disable_form_change_checker" => true,
"elements" => array(array('html', $OUTPUT->box('', '', 'useragreement_inputs'))));
$eulaform = new turnitintooltwo_form($turnitincall->getApiBaseUrl().TiiLTI::EULAENDPOINT, $customdata,
'POST', 'eulaWindow', array('id' => 'eula_launch'));
$output .= $OUTPUT->box($eulaform->display(), '', 'useragreement_form');
}
return $output;
}
/**
* Outputs the file type array for acceptable file type uploads
*
* @param boolean $setup True if the call is from the assignment activity setup screen
* @param array The array of filetypes ready for the modform parameter
*/
public function get_filetypes($setup = true) {
$output = array(
1 => get_string('fileupload', 'turnitintooltwo'),
2 => get_string('textsubmission', 'turnitintooltwo')
);
if ($setup) {
$output[0] = get_string('anytype', 'turnitintooltwo');
}
ksort($output);
return $output;
}
/**
* Output the table structures with headings for the Submission inbox, they will be populated via Ajax
*
* @global type $CFG
* @global type $OUTPUT
* @param type $cm
* @param type $turnitintooltwoassignment
* @return type
*/
public function init_submission_inbox($cm, $turnitintooltwoassignment, $partdetails, $turnitintooltwouser) {
global $CFG, $OUTPUT;
$config = turnitintooltwo_admin_config();
$istutor = has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id));
// Output user role to hidden var for use in jQuery calls.
$output = $OUTPUT->box($turnitintooltwouser->get_user_role(), '', 'user_role');
$output .= $OUTPUT->box($turnitintooltwoassignment->turnitintooltwo->id, '', 'assignment_id');
if ($turnitintooltwouser->get_user_role() == 'Learner') {
$output .= html_writer::tag('noscript', get_string('noscriptsummary', 'turnitintooltwo'), array("class" => "warning"));
}
$origreportenabled = ($turnitintooltwoassignment->turnitintooltwo->studentreports) ? 1 : 0;
$grademarkenabled = ($config->usegrademark) ? 1 : 0;
// Do the table headers.
$cells = array();
$cells["part"] = new html_table_cell('part');
$selectallcb = html_writer::checkbox(false, false, false, '', array("class" => "select_all_checkbox"));
$cells["checkbox"] = new html_table_cell( ($istutor) ? $selectallcb : ' ' );
if ($turnitintooltwouser->get_user_role() != 'Learner') {
// These columns are used for sorting, and should retain their hidden_class class.
$cells["studentlastname"] = new html_table_cell( get_string('studentlastname', 'turnitintooltwo'));
$cells["studentlastname"]->attributes["class"] = 'sorting_name sorting_name_last';
}
if ($istutor) {
$cells["student"] = new html_table_cell(
html_writer::tag('div', get_string('studentfirstname', 'turnitintooltwo'), array('class' => 'data-table-splitter splitter-firstname sorting', 'data-col'=> 18 )).
html_writer::tag('div', ' / '.get_string('studentlastname', 'turnitintooltwo'), array('class' => 'data-table-splitter splitter-lastname sorting', 'data-col' => 2))
);
} else {
$cells["student"] = new html_table_cell(' ');
}
$cells["student"]->attributes['class'] = 'left';
$cells["title_raw"] = new html_table_cell(' ');
$cells["title_raw"]->attributes['class'] = 'raw_data';
$cells["title"] = new html_table_cell(get_string('submissiontitle', 'turnitintooltwo'));
$cells["title"]->attributes['class'] = 'left';
$cells["paper_id"] = new html_table_cell(get_string('objectid', 'turnitintooltwo'));
$cells["paper_id"]->attributes['class'] = 'right';
$cells["submitted_date_raw"] = new html_table_cell(' ');
$cells["submitted_date_raw"]->attributes['class'] = 'raw_data';
$cells["submitted_date"] = new html_table_cell(get_string('submitted', 'turnitintooltwo'));
$cells["submitted_date"]->attributes['class'] = 'right';
if (($turnitintooltwouser->get_user_role() == 'Instructor') ||
($turnitintooltwouser->get_user_role() == 'Learner' && $origreportenabled)) {
$cells["report_raw"] = new html_table_cell(' ');
$cells["report_raw"]->attributes['class'] = 'raw_data';
$cells["report"] = new html_table_cell(get_string('submissionorig', 'turnitintooltwo'));
$cells["report"]->attributes['class'] = 'right';
}
if ($grademarkenabled) {
$cells["grade_raw"] = new html_table_cell(' ');
$cells["grade_raw"]->attributes['class'] = 'raw_data';
$cells["grade"] = new html_table_cell(get_string('submissiongrade', 'turnitintooltwo'));
$cells["grade"]->id = "grademark";
$cells["grade"]->attributes['class'] = 'right';
if (count($partdetails) > 1 || $turnitintooltwoassignment->turnitintooltwo->grade < 0) {
$cells["overallgrade"] = new html_table_cell(get_string('overallgrade', 'turnitintooltwo'));
$cells["overallgrade"]->attributes['class'] = 'right';
}
}
if (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) {
$cells["student_read"] = new html_table_cell(' ');
}
$cells["upload"] = new html_table_cell(' ');
$cells["upload"]->attributes['class'] = "noscript_hide";
if (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) {
$cells["refresh"] = new html_table_cell(' ');
}
$cells["download"] = new html_table_cell(' ');
$cells["delete"] = new html_table_cell(' ');
if ($turnitintooltwouser->get_user_role() != 'Learner') {
// These columns are used for sorting, and should retain their hidden_class class.
// Put the user firstame in the latest hidden cell.
$cells["studentfirstname"] = new html_table_cell( get_string('studentfirstname', 'turnitintooltwo'));
$cells["studentfirstname"]->attributes["class"] = 'sorting_name sorting_first_last';
}
$tableheaders = $cells;
$tables = "";
$output .= $OUTPUT->box_start('', 'tabs');
$tabitems = array();
$i = 0;
// Determine which tab position to enable after a submission deletion.
$tabposition = array_search(optional_param('partid', 0, PARAM_INT), array_keys($partdetails));
if ($tabposition) {
$output .= html_writer::tag('div', $tabposition, array('id' => 'tab_position', 'class' => 'hidden_class'));
}
foreach ($partdetails as $partid => $partobject) {
if (!empty($partid)) {
$i++;
$tabitems[$i] = html_writer::link("#tabs-".$partid, $partobject->partname);
$tables .= html_writer::tag('h2', $partobject->partname,
array('class' => 'js_hide', 'data-submitted' => $partobject->submitted));
$tables .= $OUTPUT->box_start('part_table', 'tabs-'.$partid, array('data-submitted' => $partobject->submitted));
$downloadlinks = "";
if ($turnitintooltwouser->get_user_role() == 'Instructor') {
$origfilesziplang = "origfileszip";
$grademarkziplang = "grademarkzip";
// Output icon to download zip file of selected submissions in original format.
$exportorigfileszip = html_writer::tag('div',
html_writer::tag('i', '', array('class' => 'fa fa-file-o',
'title' => get_string($origfilesziplang, 'turnitintooltwo'))).' '.
get_string($origfilesziplang, 'turnitintooltwo'),
array('class' => 'mod_turnitintooltwo_zip_open mod_turnitintooltwo_origchecked_zip_open',
'id' => 'origchecked_zip_'.$partobject->id));
// Put in div placeholder for launch form.
$exportorigfileszip .= $OUTPUT->box('', 'launch_form', 'origchecked_zip_form_'.$partobject->id);
// Output icon to download zip file of submissions in pdf format.
$exportgrademarkzip = html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.
$cm->id.'&part='.$partid.'&do=export_pdfs&view_context=box_solid',
html_writer::tag('i', '', array('class' => 'fa fa-file-pdf-o',
'title' => get_string($grademarkziplang, 'turnitintooltwo'))).' '.
get_string($grademarkziplang, 'turnitintooltwo'),
array("class" => "mod_turnitintooltwo_gmpdfzip_box", "id" => "gmpdf_zip_".$partobject->id));
$linkstyles = array('class' => 'btn dropdown-toggle', 'data-toggle' => 'dropdown', 'disabled' => 'disabled', 'title' => get_string("download_button_warning", 'turnitintooltwo'));
$linkdropdown = html_writer::tag('ul',
html_writer::tag('li', $exportorigfileszip).
html_writer::tag('li', $exportgrademarkzip),
array('class' => 'dropdown-menu mod_turnitintooltwo_dropdown-menu'));
$downloadlinks = html_writer::tag('div',
html_writer::tag('button', get_string('download', 'turnitintooltwo'),
$linkstyles).$linkdropdown,
array('id' => 'mod_turnitintooltwo_download_links', 'class' => 'btn-group'));
}
// Include download links and info table.
$tables .= html_writer::tag('div', $downloadlinks, array('id' => 'part_' . $partobject->id, 'class' => 'mod_turnitintooltwo_zip_downloads'));
$tables .= $this->get_submission_inbox_part_details($cm, $turnitintooltwoassignment, $partdetails, $partid);
// Construct submissions table.
$table = new html_table();
$table->id = $partid;
$table->attributes['class'] = 'mod_turnitintooltwo_submissions_data_table';
$table->head = $tableheaders;
// Populate inbox if user is a student incase they do not have javascript enabled.
if ($turnitintooltwouser->get_user_role() == 'Learner') {
$submission = current($this->get_submission_inbox($cm, $turnitintooltwoassignment, $partdetails, $partid));
// If not logged in as a tutor then refresh submissions.
$turnitintooltwoassignment->refresh_submissions($cm, $partobject);
$j = 0;
$cells = array();
foreach ($submission as $cell) {
$cells[$j] = new html_table_cell($cell);
if ($j == 2 || $j == 3 || $j == 4) {
$cells[$j]->attributes['class'] = "left";
} else if ($j == 5 || $j == 7) {
$cells[$j]->attributes['class'] = "right";
} else if (($j == 8 && $origreportenabled) || ($j == 8 && !$origreportenabled && $grademarkenabled) ||
($j == 10 && $origreportenabled && $grademarkenabled)) {
$cells[$j]->attributes['class'] = "raw_data";
} else if (($j == 12 && $origreportenabled) || ($j == 11 && !$origreportenabled)) {
$cells[$j]->attributes['class'] = "right";
} else {
$cells[$j]->attributes['class'] = "centered_cell";
}
if ((count($submission) == 16 && $j == 11) || (count($submission) == 15 && $j == 10)) {
$cells[$j]->attributes['class'] = "noscript_hide";
}
$j++;
}
$rows[0] = new html_table_row($cells);
$table->data = $rows;
}
$tables .= html_writer::table($table);
$tables .= $OUTPUT->box_end(true);
// Link to open Turnitin Messages inbox.
$messagesinbox = '';
if ($turnitintooltwouser->get_user_role() == 'Instructor') {
$icon = html_writer::tag('i', '', array('class' => 'fa fa-envelope-o fa-lg'));
$loading_icon = $OUTPUT->pix_icon('loading',
get_string('turnitinloading', 'turnitintooltwo'), 'mod_turnitintooltwo');
$messagesinbox = html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.
'&user='.$turnitintooltwouser->id.'&do=loadmessages&view_context=box',
$icon.' '.get_string('messagesinbox', 'turnitintooltwo').
' ('.html_writer::tag('span', '', array('class' => 'messages_amount')).
html_writer::tag('span', $loading_icon,
array('class' => 'mod_turnitintooltwo_messages_loading')).')',
array("class" => "mod_turnitintooltwo_messages_inbox"));
}
// Check that nonsubmitter messages have been configured to be sent.
$nonsubsemailpermitted = $this->is_nonsubmitter_emails_enabled();
// Link to email nonsubmitters.
$emailnonsubmitters = '';
if ($turnitintooltwouser->get_user_role() == 'Instructor' && $nonsubsemailpermitted) {
$icon = html_writer::tag('i', '', array('class' => 'fa fa-reply-all fa-lg'));
$emailnonsubmitters = html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.
'&part='.$partid.'&do=emailnonsubmittersform&view_context=box_solid',
$icon.' '.get_string('messagenonsubmitters', 'turnitintooltwo'),
array("class" => "mod_turnitintooltwo_nonsubmitters_link", "id" => "nonsubmitters_".$partid));
}
// Link to refresh submissions with latest data from Turnitin.
$refreshlink = html_writer::tag('div', html_writer::tag('i', '', array('class' => 'fa fa-refresh fa-lg',
'title' => get_string('turnitinrefreshingsubmissions', 'turnitintooltwo')))." ".
get_string('turnitinrefreshsubmissions', 'turnitintooltwo'),
array('class' => 'mod_turnitintooltwo_refresh_link', 'id' => 'refresh_'.$partid));
// Link which appears during the refresh of submissions.
$refreshinglink = html_writer::tag('div', html_writer::tag('i', '', array('class' => 'fa fa-spinner fa-spin fa-lg',
'title' => get_string('turnitinrefreshingsubmissions', 'turnitintooltwo')))." ".
get_string('turnitinrefreshingsubmissions', 'turnitintooltwo'),
array('class' => 'mod_turnitintooltwo_refreshing_link', 'id' => 'refreshing_'.$partid));
// Output the links.
$output .= $OUTPUT->box($messagesinbox.$emailnonsubmitters.$refreshlink.$refreshinglink,
'tii_table_functions', 'tii_table_functions_'.$partid);
}
}
$output .= html_writer::alist($tabitems, array("id" => "part_tabs_menu"));
$output .= $tables;
$output .= $OUTPUT->box_end(true);
return $output;
}
/**
* Construct table with part details
*
* @global type $OUTPUT
* @global type $CFG
* @param type $cm
* @param type $turnitintooltwoassignment
* @param type $partdetails
* @param type $partid
* @return type
*/
private function get_submission_inbox_part_details($cm, $turnitintooltwoassignment, $partdetails, $partid) {
global $OUTPUT, $CFG;
$config = turnitintooltwo_admin_config();
$table = new html_table();
$rows = array();
$istutor = has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id));
$cells = array();
$cells[0] = new html_table_cell(get_string('title', 'turnitintooltwo'));
$cells[0]->attributes['class'] = 'left';
$cells[1] = new html_table_cell(get_string('dtstart', 'turnitintooltwo'));
$cells[2] = new html_table_cell(get_string('dtdue', 'turnitintooltwo'));
$cells[3] = new html_table_cell(get_string('dtpost', 'turnitintooltwo'));
if (!empty($config->usegrademark)) {
$cells[4] = new html_table_cell(get_string('marksavailable', 'turnitintooltwo'));
}
if ($istutor) {
$cells[5] = new html_table_cell(get_string('downloadexport', 'turnitintooltwo'));
$cells[6] = new html_table_cell('');
}
$partsheaders = $cells;
$cells = array();
// Allow part name to be editable if a tutor is logged in.
$textfield = $partdetails[$partid]->partname;
if ($istutor) {
$textfield = html_writer::link('#', $partdetails[$partid]->partname,
array('title' => get_string('edit', 'turnitintooltwo'),
'class' => 'editable_text editable_text_'.$partid,
'data-type' => 'text', 'data-pk' => $partid, 'data-name' => 'partname',
'id' => 'part_name_'.$partid,
'data-params' => "{ 'assignment': ".
$turnitintooltwoassignment->turnitintooltwo->id.", ".
"'action': 'edit_field', 'sesskey': '".sesskey()."' }"));
}
$cells[0] = new html_table_cell($turnitintooltwoassignment->turnitintooltwo->name." - ".$textfield." ");
// Allow start date field to be editable if a tutor is logged in.
$dateformat = ($CFG->ostype == 'WINDOWS') ? '%d %b %Y - %H:%M' : '%d %h %Y - %H:%M';
$datefield = userdate($partdetails[$partid]->dtstart, $dateformat);
if ($istutor) {
$datefield = html_writer::link('#', $datefield,
array('title' => get_string('edit', 'turnitintooltwo'),
'class' => 'editable_date editable_date_'.$partid,
'data-pk' => $partid, 'data-name' => 'dtstart', 'id' => 'date_start_'.$partid,
'data-params' => "{ 'assignment': ".
$turnitintooltwoassignment->turnitintooltwo->id.", ".
"'action': 'edit_field', 'sesskey': '".sesskey()."' }"));
}
$cells[1] = new html_table_cell($datefield);
$cells[1]->attributes['class'] = 'data';
// Allow due date field to be editable if a tutor is logged in.
$dateformat = ($CFG->ostype == 'WINDOWS') ? '%d %b %Y - %H:%M' : '%d %h %Y - %H:%M';
$datefield = userdate($partdetails[$partid]->dtdue, $dateformat);
if ($istutor) {
$datefield = html_writer::link('#', $datefield,
array('data-anon' => $turnitintooltwoassignment->turnitintooltwo->anon,
'title' => get_string('edit', 'turnitintooltwo'),
'class' => 'editable_postdue editable_date editable_date_'.$partid,
'data-pk' => $partid, 'data-name' => 'dtdue', 'id' => 'date_due_'.$partid,
'data-params' => "{ 'assignment': ".
$turnitintooltwoassignment->turnitintooltwo->id.", ".
"'action': 'edit_field', 'sesskey': '".sesskey()."' }"));
}
$cells[2] = new html_table_cell($datefield);
$cells[2]->attributes['class'] = 'data';
// Allow post date field to be editable if a tutor is logged in.
$dateformat = ($CFG->ostype == 'WINDOWS') ? '%d %b %Y - %H:%M' : '%d %h %Y - %H:%M';
$datefield = userdate($partdetails[$partid]->dtpost, $dateformat);
if ($istutor) {
$datefield = html_writer::link('#', $datefield,
array('data-anon' => $turnitintooltwoassignment->turnitintooltwo->anon,
'data-unanon' => $partdetails[$partid]->unanon,
'data-submitted' => $partdetails[$partid]->submitted,
'title' => get_string('edit', 'turnitintooltwo'),
'class' => 'editable_postdue editable_date editable_date_'.$partid,
'data-pk' => $partid, 'data-name' => 'dtpost', 'id' => 'date_post_'.$partid,
'data-params' => "{ 'assignment': ".
$turnitintooltwoassignment->turnitintooltwo->id.", ".
"'action': 'edit_field', 'sesskey': '".sesskey()."' }"));
}
$cells[3] = new html_table_cell($datefield);
$cells[3]->attributes['class'] = 'data';
// Don't show Grade column if not using GradeMark.
if (!empty($config->usegrademark)) {
// Show Rubric view if applicable to students.
$rubricviewlink = '';
if (!$istutor && !empty($turnitintooltwoassignment->turnitintooltwo->rubric)) {
$rubricviewlink .= $OUTPUT->box_start('row_rubric_manager', '');
$rubricviewlink .= html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.
'&part='.$partid.'&do=rubricview&view_context=box',
html_writer::tag('span', '',
array('class' => 'tiiicon icon-rubric icon-lg', 'id' => 'mod_turnitintooltwo_rubric_view_form')),
array('class' => 'mod_turnitintooltwo_rubric_view_launch', 'id' => 'rubric_view_launch',
'title' => get_string('launchrubricview', 'turnitintooltwo')));
$rubricviewlink .= $OUTPUT->box_end(true);
}
// Show warning to instructor when changing maxmarks if grades exist
$turnitintooltwosubmission = new turnitintooltwo_submission();
$getgrades = $turnitintooltwosubmission->count_graded_submissions($turnitintooltwoassignment->turnitintooltwo->id);
$class = $getgrades > 0 ? 'max_marks_warning' : '';
// Allow marks to be editable if a tutor is logged in.
$textfield = $partdetails[$partid]->maxmarks.$rubricviewlink;
if ($istutor) {
$textfield = html_writer::link('#', $partdetails[$partid]->maxmarks,
array('title' => get_string('edit', 'turnitintooltwo'),
'class' => 'editable_text editable_text_'.$partid . ' ' . $class, 'id' => 'marks_'.$partid,
'data-type' => 'text', 'data-pk' => $partid, 'data-name' => 'maxmarks',
'data-params' => "{ 'assignment': ".
$turnitintooltwoassignment->turnitintooltwo->id.", ".
"'action': 'edit_field', 'sesskey': '".sesskey()."' }"));
}
$cells[4] = new html_table_cell($textfield);
$cells[4]->attributes['class'] = 'data';
}
if ($istutor) {
// Output icon to download zip file of submissions in original format.
$exportoriginalzip = $OUTPUT->box_start('row_export_orig', '');
$exportoriginalzip .= $OUTPUT->box(
html_writer::tag('i', '', array('title' => get_string('exportoriginal', 'turnitintooltwo'),
'class' => 'fa fa-file-o fa-lg')),
'mod_turnitintooltwo_zip_open orig_zip_open', 'orig_zip_'.$partdetails[$partid]->tiiassignid
);
// Put in div placeholder for launch form.
$exportoriginalzip .= $OUTPUT->box('', 'launch_form', 'orig_zip_form_'.$partdetails[$partid]->tiiassignid);
$exportoriginalzip .= $OUTPUT->box_end(true);
// Output icon to download zip file of submissions in pdf format.
$exportpdfzip = html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.
$cm->id.'&part='.$partid.'&do=export_pdfs&view_context=box_solid',
html_writer::tag('i', '', array('title' => get_string('exportpdf', 'turnitintooltwo'),
'class' => 'fa fa-file-pdf-o fa-lg middle-padding')),
array("class" => "downloadpdf_box",
"id" => "download_".$partdetails[$partid]->tiiassignid));
// Output icon to download excel spreadsheet of grades.
$exportxlszip = $OUTPUT->box_start('row_export_xls', '');
$exportxlszip .= $OUTPUT->box(
html_writer::tag('i', '', array('title' => get_string('exportexcel', 'turnitintooltwo'),
'class' => 'fa fa-file-excel-o fa-lg')),
'mod_turnitintooltwo_zip_open xls_inbox_open', 'xls_inbox_'.$partdetails[$partid]->tiiassignid
);
// Put in div placeholder for launch form.
$exportxlszip .= $OUTPUT->box('', 'launch_form', 'xls_inbox_form_'.$partdetails[$partid]->tiiassignid);
$exportxlszip .= $OUTPUT->box_end(true);
$showexport = ($turnitintooltwoassignment->turnitintooltwo->anon == 0 || time() > $partdetails[$partid]->dtpost);
$exportoptions = $showexport ? 'tii_export_options_show' : 'tii_export_options_hide';
$links = $OUTPUT->box_start($exportoptions, 'export_options');
// Show the export links if they should be available.
if ($turnitintooltwoassignment->turnitintooltwo->anon == 0 || time() > $partdetails[$partid]->dtpost) {
$links .= $exportxlszip.$exportpdfzip.$exportoriginalzip;
}
$links .= $OUTPUT->box_end(true);
if ($turnitintooltwoassignment->count_submissions($cm, $partid) == 0) {
$links = html_writer::tag('div', $links, array('id' => 'export_links', 'class' => 'hidden_class'));
}
$cells[5] = new html_table_cell($links);
$cells[5]->attributes['class'] = 'export_data';
// Show feature links (rubric and quickmark).
if ($config->usegrademark) {
// Rubric Manager.
$coursetype = turnitintooltwo_get_course_type($turnitintooltwoassignment->turnitintooltwo->legacy);
$coursedata = $turnitintooltwoassignment->get_course_data($turnitintooltwoassignment->turnitintooltwo->course, $coursetype);
$rubricmanagerlink = $OUTPUT->box_start('row_rubric_manager', '');
$rubricmanagerlink .= html_writer::link($CFG->wwwroot.
'/mod/turnitintooltwo/extras.php?cmd=rubricmanager&tiicourseid='.
$coursedata->turnitin_cid.'&view_context=box',
html_writer::tag('i', '', array('class' => 'tiiicon icon-rubric icon-lg')),
array('class' => 'mod_turnitintooltwo_rubric_manager_launch', 'id' => 'rubric_manager_inbox_launch',
'title' => get_string('launchrubricmanager', 'turnitintooltwo')));
$rubricmanagerlink .= html_writer::tag('span', '', array('class' => 'launch_form', 'id' => 'rubric_manager_form'));
$rubricmanagerlink .= $OUTPUT->box_end(true);
// Quickmark Manager.
$quickmarkmanagerlink = $OUTPUT->box_start('row_quickmark_manager', '');
$quickmarkmanagerlink .= html_writer::link($CFG->wwwroot.
'/mod/turnitintooltwo/extras.php?cmd=quickmarkmanager&view_context=box',
html_writer::tag('i', '', array('class' => 'tiiicon icon-quickmarks icon-lg')),
array('class' => 'mod_turnitintooltwo_quickmark_manager_launch',
'title' => get_string('launchquickmarkmanager', 'turnitintooltwo')));
$quickmarkmanagerlink .= html_writer::tag('span', '', array('class' => 'launch_form',
'id' => 'quickmark_manager_form'));
$quickmarkmanagerlink .= $OUTPUT->box_end(true);
$cells[6] = new html_table_cell($rubricmanagerlink.$quickmarkmanagerlink);
$cells[6]->attributes['class'] = 'rubric_qm';
}
}
$rows['part_details'] = new html_table_row($cells);
// Show summary box.
if (!empty($turnitintooltwoassignment->turnitintooltwo->intro)) {
$cells = array();
$introtext = format_module_intro('turnitintooltwo', $turnitintooltwoassignment->turnitintooltwo, $cm->id);
$intro = html_writer::tag('div', get_string("turnitintooltwointro", "turnitintooltwo").": ".
$introtext, array("class" => "introduction"));
$cells[0] = new html_table_cell($intro);
$cells[0]->attributes['class'] = 'introduction_cell';
$cells[0]->colspan = ($config->usegrademark) ? '7' : '6';
$rows['intro'] = new html_table_row($cells);
}
// Show Peermark row if enabled.
if ($config->enablepeermark) {
$cells = array();
// Show Peermark hide/show links.
$hideclass = 'hide_peermarks_'.$turnitintooltwoassignment->turnitintooltwo->id;
$hidetext = html_writer::tag('i', '', array('class' => 'fa fa-minus-circle red fa-lg '.$hideclass));
$showclass = 'show_peermarks_'.$turnitintooltwoassignment->turnitintooltwo->id;
$showtext = html_writer::tag('i', '', array('class' => 'fa fa-plus-circle green fa-lg '.$showclass));
$links = html_writer::link('javascript:void(0)', $showtext.$hidetext , array('class' => 'toggle_peermarks js_hide'));
// Peermark Settings Link.
$peermarkmanagerlink = "";
if ($istutor) {
$peermarkmanagerlink .= $OUTPUT->box_start('row_peermark_manager', '');
$peermarkmanagerlink .= html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.
'&part='.$partid.'&do=peermarkmanager&view_context=box',
html_writer::tag('i', '', array('class' => 'tiiicon icon-settings icon-lg')),
array('class' => 'tii_peermark_manager_launch',
'id' => 'peermark_manager_'.$partid,
'title' => get_string('launchpeermarkmanager', 'turnitintooltwo')));
$peermarkmanagerlink .= html_writer::tag('span', '', array('class' => 'launch_form',
'id' => 'peermark_manager_form'));
$peermarkmanagerlink .= $OUTPUT->box_end(true);
}
// Peermark Reviews Link.
$peermarkreviewslink = $OUTPUT->box_start('row_peermark_reviews', '');
$peermarkreviewslink .= html_writer::link($CFG->wwwroot.'/mod/turnitintooltwo/view.php?id='.$cm->id.
'&part='.$partid.'&do=peermarkreviews&view_context=box',
html_writer::tag('i', '', array('class' => 'tiiicon icon-peermark icon-lg')),
array('class' => 'tii_peermark_reviews_launch',
'title' => get_string('launchpeermarkreviews', 'turnitintooltwo')));
$peermarkreviewslink .= html_writer::tag('span', '', array('class' => 'launch_form', 'id' => 'peermark_reviews_form'));
$peermarkreviewslink .= $OUTPUT->box_end(true);
// If logged in as a student then show peermark data straightaway as they may have javascript disabled.
$count = ($istutor) ? 0 : count($partdetails[$partid]->peermark_assignments);
// Build peermark header row.
if ($istutor || $count > 0) {
$cells[0] = new html_table_cell($links.html_writer::tag('div',
get_string('peermarkassignments', 'turnitintooltwo').' ('.
html_writer::tag('span', $count, array('class' => 'peermark_count')).
html_writer::tag('span', $OUTPUT->pix_icon('loading',
get_string('turnitinloading', 'turnitintooltwo'), 'mod_turnitintooltwo'),
array('class' => 'peermark-loading mod_turnitintooltwo_peermark-loading-span')).')',
array('class' => 'peermark_header')).$peermarkreviewslink.$peermarkmanagerlink);
$cells[0]->attributes['class'] = 'peermarks';
$cells[0]->colspan = ($config->usegrademark) ? '7' : '6';
$rows['peermark'] = new html_table_row($cells);
$peermarktable = ($istutor) ? '' : $this->show_peermark_assignment($partdetails[$partid]->peermark_assignments);
$cells[0] = new html_table_cell(html_writer::tag('div', $peermarktable,
array("class" => "peermark_assignments_container")).
html_writer::tag('div', $OUTPUT->pix_icon('loading',
get_string('turnitinloading', 'turnitintooltwo'), 'mod_turnitintooltwo'),
array('class' => 'peermark_loading peermark_loading_row')));
$cells[0]->attributes['class'] = 'peermark_assignments_cell';
$cells[0]->colspan = ($config->usegrademark) ? '7' : '6';
$rows['peermark_assignments'] = new html_table_row($cells);
}
}
$table->attributes['class'] = 'mod_turnitintooltwo_part_details';
$table->head = $partsheaders;
$table->data = $rows;
$output = html_writer::table($table);
return $output;
}
public function show_peermark_assignment($peermarkassignments) {
$table = new html_table();
$rows = array();
// Headers.
$cells = array();
$cells[0] = new html_table_cell(get_string('title', 'turnitintooltwo'));
$cells[0]->attributes['class'] = 'left';
$cells[1] = new html_table_cell(get_string('dtstart', 'turnitintooltwo'));
$cells[2] = new html_table_cell(get_string('dtdue', 'turnitintooltwo'));