-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff
3008 lines (2857 loc) · 148 KB
/
diff
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
diff --git a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentContent.java b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentContent.java
index d5f7b05..ae19d53 100644
--- a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentContent.java
+++ b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentContent.java
@@ -189,7 +189,15 @@ public interface AssignmentContent extends Entity, AttachmentContainer
*/
public boolean getAllowStudentViewReport();
+
+ /**
+ * Access whether this AssignmentContent allows students to view review service grades.
+ *
+ * @return true if the AssignmentContent allows students to view review service grades, false otherwise.
+ */
+ public boolean getAllowStudentViewExternalGrade();
+
/**
* Access the list of authors.
*
@@ -238,6 +246,10 @@ public interface AssignmentContent extends Entity, AttachmentContainer
public void setExcludeQuoted(boolean m_excludeQuoted);
+ public boolean isAllowAnyFile();
+
+ public void setAllowAnyFile(boolean m_allowAnyFile);
+
/**
* Exclude type options:
* 0 none
diff --git a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentContentEdit.java b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentContentEdit.java
index 5dd0a7b..15a86d5 100644
--- a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentContentEdit.java
+++ b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentContentEdit.java
@@ -157,7 +157,7 @@ public interface AssignmentContentEdit extends AssignmentContent, AttachmentCont
public void setAllowReviewService(boolean allow);
/**
- * Set whether this sssignment allow students to view review service reports?
+ * Set whether this assignment allow students to view review service reports?
*
* @param allow -
* true if the Assignment allows review service, false otherwise?
@@ -165,6 +165,14 @@ public interface AssignmentContentEdit extends AssignmentContent, AttachmentCont
public void setAllowStudentViewReport(boolean allow);
/**
+ * Set whether this assignment allow students to view review service grades?
+ *
+ * @param allow -
+ * true if the Assignment allows students to view review service grade, false otherwise
+ */
+ public void setAllowStudentViewExternalGrade(boolean allow);
+
+ /**
* Add an author to the author list.
*
* @param author -
diff --git a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentService.java b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentService.java
index b4d9231..1a4239e 100644
--- a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentService.java
+++ b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentService.java
@@ -591,6 +591,14 @@ public interface AssignmentService extends EntityProducer
* The AssignmentSubmissionEdit object to commit.
*/
public void commitEdit(AssignmentSubmissionEdit submission);
+
+ /**
+ * Method for allowing to commit TII properties into the Submission object
+ *
+ * @param submission
+ * The AssignmentSubmissionEdit object to commit.
+ */
+ public void commitEditFromCallback(AssignmentSubmissionEdit submission);
/**
* Cancel the changes made to a AssignmentSubmissionEdit object, and release the lock. The AssignmentSubmissionEdit is disabled, and not to be used after this call.
diff --git a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentSubmission.java b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentSubmission.java
index 0feb3e7..fb08b42 100644
--- a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentSubmission.java
+++ b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentSubmission.java
@@ -282,6 +282,18 @@ public interface AssignmentSubmission extends Entity
* @return
*/
public String getReviewIconUrl();
+
+ /**
+ * the color of the content review Icon associated with this submission
+ * @return
+ */
+ public String getReviewIconColor();
+
+ /**
+ * indicates whether the external grade for this submission is different than the assignments one
+ * @return
+ */
+ public boolean isExternalGradeDifferent();
/**
*
diff --git a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentSubmissionEdit.java b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentSubmissionEdit.java
index 609b422..53d5474 100644
--- a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentSubmissionEdit.java
+++ b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/AssignmentSubmissionEdit.java
@@ -206,6 +206,18 @@ public interface AssignmentSubmissionEdit extends AssignmentSubmission, Edit
public void setReviewIconUrl(String url);
/**
+ * Set the color of the Review Report
+ * @param color
+ */
+ public void setReviewIconColor(String color);
+
+ /**
+ * When the external grade for this submission is different than the assignments one
+ * @param url
+ */
+ public void setExternalGradeDifferent(boolean different);
+
+ /**
* Set the content review status
* @param status
*/
@@ -265,6 +277,13 @@ public interface AssignmentSubmissionEdit extends AssignmentSubmission, Edit
* @param attachments
*/
public void postAttachment(List attachments);
+
+ /**
+ * Post resubmission attachments to the content review service
+ * @param attachments
+ */
+ public void postAttachmentResub(List attachments);
+
/**
* Set whether this submission was generated by a user or the system
diff --git a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/ContentReviewResult.java b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/ContentReviewResult.java
index c0add8a..d04be4c 100644
--- a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/ContentReviewResult.java
+++ b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/api/ContentReviewResult.java
@@ -33,6 +33,16 @@ public class ContentReviewResult
* The URL of the content review icon associated with this item
*/
private String reviewIconURL;
+
+ /**
+ * The URL of the content review color associated with this item
+ */
+ private String reviewIconColor;
+
+ /**
+ * Indicates whether the external grade for this submission is different than the assignments one
+ */
+ private String externalGrade;
/**
* An error string, if any, return from the review service
@@ -128,6 +138,38 @@ public class ContentReviewResult
{
this.reviewIconURL = reviewIconURL;
}
+
+ /**
+ * Getter for the color of the content review icon associated with this item
+ */
+ public String getReviewIconColor()
+ {
+ return reviewIconColor;
+ }
+
+ /**
+ * Setter for the color of the content review icon associated with this item
+ */
+ public void setReviewIconColor(String reviewIconColor)
+ {
+ this.reviewIconColor = reviewIconColor;
+ }
+
+ /**
+ * Getter for the external grade
+ */
+ public String getExternalGrade()
+ {
+ return externalGrade;
+ }
+
+ /**
+ * Setter for the external grade
+ */
+ public void setExternalGrade(String externalGrade)
+ {
+ this.externalGrade = externalGrade;
+ }
/**
* Getter for the error string, if any, returned from the review service
diff --git a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/cover/AssignmentService.java b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/cover/AssignmentService.java
index 22939a1..065a354 100644
--- a/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/cover/AssignmentService.java
+++ b/assignment/assignment-api/api/src/java/org/sakaiproject/assignment/cover/AssignmentService.java
@@ -420,6 +420,15 @@ public class AssignmentService {
service.commitEdit(param0);
}
+
+ public static void commitEditFromCallback(
+ org.sakaiproject.assignment.api.AssignmentSubmissionEdit param0) {
+ org.sakaiproject.assignment.api.AssignmentService service = getInstance();
+ if (service == null)
+ return;
+
+ service.commitEditFromCallback(param0);
+ }
public static void cancelEdit(
org.sakaiproject.assignment.api.AssignmentSubmissionEdit param0) {
diff --git a/assignment/assignment-bundles/resources/assignment.properties b/assignment/assignment-bundles/resources/assignment.properties
index 7205992..7564fd5 100644
--- a/assignment/assignment-bundles/resources/assignment.properties
+++ b/assignment/assignment-bundles/resources/assignment.properties
@@ -97,6 +97,7 @@ gen.can.discard = Your changes will be discarded. Are you sure you want to can
gen.clocli = Close, click to open assignment instructions
gen.closed = Closed
gen.creby = Created by
+gen.cr.submit = You can choose to have students submit their assignments inline only (typed directly into a text box), as attachments only, or both. Student submissions must be 'Single Upload File only' or 'Inline only' if using Turnitin integration.
gen.don = Done
gen.dra1 = Draft
gen.closeexit = Close and Exit
@@ -109,6 +110,7 @@ gen.forpoi = For points, enter maximum possible
gen.assign.gra = Grade
gen.gra = Grade
gen.gra2 = Grade:
+gen.gra.ext = External Grade:
gen.grade.override = Override grade with:
gen.grading = Grading
gen.group = Group
@@ -697,6 +699,7 @@ review.use = Use {0}
review.switch.ne.1 = {0} is not available for non-electronic submissions.
review.switch.ne.2 = {0} is not available for non-electronic submissions. "Use Turnitin" has been deselected below.
review.allow = Allow students to view report
+review.allow.grades = Allow students to view external grades
review.report = Report
review.report.expand = Expand reports
review.report.collapse = Collapse reports
@@ -713,6 +716,7 @@ review.originality.check.turnitin=Turnitin paper repository
review.originality.check.internet=Current and archived internet
review.originality.check.pub=Periodicals, journals, and publications
review.originality.check.institution=Institution-specific repository
+review.originality.allow.any.file=Allow submissions of any kind of file
review.exclude.bibliographic=Exclude bibliographic materials from Similarity Index for all papers in this assignment
review.exclude.quoted=Exclude quoted materials from Similarity Index for all papers in this assignment
review.exclude.smallMatches=Exclude small matches
@@ -899,6 +903,7 @@ content_review.pending.info = This attachment has been submitted and is pending
content_review.error = An unknown error occurred. The originality review for this attachment is not available.
content_review.error.createAssignment=An error with {0} has occurred while creating this assignment. {1} has saved the assignment in draft mode. Please try posting this assignment again later. {2}
content_review.note=<div><br /><em>NOTE:</em><ul><li>When submitting attachments, students should only use these file types: {0}.</li> <li>Students should always save files with the appropriate extension.</li> </ul></div>
+content_review.studentNote = Only use file types: Microsoft Word (.doc, .docx), PowerPoint (.ppt, .pptx), PostScript (.ps), PDF (.pdf), HTML (.html), OpenOffice (ODT), Hangul (HWP), rich or plain text (.rtf, .txt).</li><li>Always include file extension.</li><li>Maximum file size is 20 Mb. The document must contain more than 20 words.</li></ol>
content_review.accepted.types.delimiter=,
content_review.accepted.types.lparen=(
content_review.accepted.types.rparen=)
@@ -1010,6 +1015,24 @@ grades.late=Late submission
grades.lateness.late=Late
grades.lateness.ontime=On time
grades.lateness.unknown=Unknown
+
+cr.notprocess.warning = You have uploaded a file with an extension that will not be processed by the content review service
+cr.size.warning = You have uploaded a file which size is too big for the content review service
+submission.inline=Inline Submission
+content.review=Content Review
+content.review.inbox=Assignment Inbox
+review.oldsite=This site was created more than {0} years ago and there's a risk the content review site might have expired.
+ review.sitechars=The title of this site is shorter than the minimum allowed by the content review service. If you wish to route submissions through {0} then you need to choose a site title with more than {1} characters.
+review.sitecharslong=The title of this site is longer than the maximum allowed by the content review service. If you wish to route submissions through {0} then you need to choose a site title with less than {1} characters.
+review.assignchars=The title of this assignment is shorter than the minimum allowed by the content review service. If you wish to route submissions through {0} then you need to choose a title with more than {1} characters.
+review.assigncharslong=The title of this assignment is longer than the maximum allowed by the content review service. If you wish to route submissions through {0} then you need to choose a title with less than {1} characters.
+review.originality.alt=View originality report: score
+review.user.email=The content review service requires your email to be set. Your submission cannot be reviewed by {0} until you update your details.
+review.user.name=The content review service requires your first name and surname to be set. Your submission cannot be reviewed by {0} until you update your details.
+review.user.lastname=The content review service requires your surname to be set. Your submission cannot be reviewed by {0} until you update your details.
+review.instructor.fields=The content review service requires your first name, surname and email must to be set. If you wish to route submissions through {0} then you need to update your details.
+review.conflicting.popup=This item has been graded in both Turnitin and in the Assignments Tool. The mark set in the Assignments Tool is the one that is displayed here.
+allowResubmission.review.warning=Any submissions made after the Assignment Due Date will not be sent to {0}
rubric.title=Rubric
rubric.addNoRubric=No Rutgers Rubric will be added to this assignment
diff --git a/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java b/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java
index ee300da..39bbf20 100644
--- a/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java
+++ b/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java
@@ -21,6 +21,8 @@
package org.sakaiproject.assignment.impl;
+import java.text.SimpleDateFormat;
+
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
@@ -51,6 +53,7 @@ import org.sakaiproject.contentreview.exception.ReportException;
import org.sakaiproject.contentreview.exception.SubmissionException;
import org.sakaiproject.contentreview.model.ContentReviewItem;
import org.sakaiproject.contentreview.service.ContentReviewService;
+import org.sakaiproject.contentreview.service.ContentReviewSiteAdvisor;
import org.sakaiproject.email.cover.DigestService;
import org.sakaiproject.email.cover.EmailService;
import org.sakaiproject.entity.api.*;
@@ -75,6 +78,7 @@ import org.sakaiproject.time.api.Time;
import org.sakaiproject.time.cover.TimeService;
import org.sakaiproject.tool.api.SessionBindingEvent;
import org.sakaiproject.tool.api.SessionBindingListener;
+import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.cover.SessionManager;
import org.sakaiproject.tool.cover.ToolManager;
import org.sakaiproject.user.api.User;
@@ -163,6 +167,11 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
this.contentReviewService = contentReviewService;
}
+ protected ContentReviewSiteAdvisor contentReviewSiteAdvisor;
+ public void setContentReviewSiteAdvisor(ContentReviewSiteAdvisor contentReviewSiteAdvisor) {
+ this.contentReviewSiteAdvisor = contentReviewSiteAdvisor;
+ }
+
private AssignmentPeerAssessmentService assignmentPeerAssessmentService = null;
public void setAssignmentPeerAssessmentService(AssignmentPeerAssessmentService assignmentPeerAssessmentService){
this.assignmentPeerAssessmentService = assignmentPeerAssessmentService;
@@ -757,6 +766,10 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
{
contentReviewService = (ContentReviewService) ComponentManager.get(ContentReviewService.class.getName());
}
+ if (contentReviewSiteAdvisor == null)
+ {
+ contentReviewSiteAdvisor = (ContentReviewSiteAdvisor) ComponentManager.get(ContentReviewSiteAdvisor.class.getName());
+ }
} // init
/**
@@ -2016,6 +2029,7 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
ResourcePropertiesEdit pEdit = (BaseResourcePropertiesEdit) retVal.getPropertiesEdit();
pEdit.addAll(existingContent.getProperties());
+ pEdit.removeProperty("lti_id");
addLiveProperties(pEdit);
}
}
@@ -2539,6 +2553,32 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
} // commitEdit(Submission)
+ public void commitEditFromCallback(AssignmentSubmissionEdit submission)
+ {
+ String submissionRef = submission.getReference();
+
+ // check for closed edit
+ if (!submission.isActiveEdit())
+ {
+ try
+ {
+ throw new Exception();
+ }
+ catch (Exception e)
+ {
+ M_log.warn(" commitEditFromCallback(): closed AssignmentSubmissionEdit assignment submission id=" + submission.getId() + e.getMessage());
+ }
+ return;
+ }
+
+ // complete the edit
+ m_submissionStorage.commit(submission);
+
+ // close the edit object
+
+ ((BaseAssignmentSubmissionEdit) submission).closeEdit();
+ }
+
protected void sendGradeReleaseNotification(boolean released, String notificationSetting, User[] allSubmitters, AssignmentSubmission s)
{
if (allSubmitters == null) return;
@@ -6046,6 +6086,231 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
return true;
}
+ //TODO all that follows was taken from BaseContentService, removed and changed code, should be revised
+ protected static final int STREAM_BUFFER_SIZE = 102400;
+ protected static final String SECURE_INLINE_HTML = "content.html.forcedownload";
+ public static final String RFC1123_DATE = "EEE, dd MMM yyyy HH:mm:ss zzz";
+ public static final Locale LOCALE_US = Locale.US;
+
+ protected void handleAccessResource(HttpServletRequest req, HttpServletResponse res, ContentResource resource){
+
+ // Set some headers to tell browsers to revalidate and check for updated files
+ res.addHeader("Cache-Control", "must-revalidate, private");
+ res.addHeader("Expires", "-1");
+ try
+ {
+ long len = resource.getContentLength();
+ String contentType = resource.getContentType();
+ ResourceProperties rp = resource.getProperties();
+ long lastModTime = 0;
+
+ try {
+ Time modTime = rp.getTimeProperty(ResourceProperties.PROP_MODIFIED_DATE);
+ lastModTime = modTime.getTime();
+ } catch (Exception e1) {
+ M_log.info("Could not retrieve modified time for: " + resource.getId());
+ }
+
+ // KNL-1316 tell the browser when our file was last modified for caching reasons
+ if (lastModTime > 0) {
+ SimpleDateFormat rfc1123Date = new SimpleDateFormat(RFC1123_DATE, LOCALE_US);
+ rfc1123Date.setTimeZone(TimeZone.getTimeZone("GMT"));
+ res.addHeader("Last-Modified", rfc1123Date.format(lastModTime));
+ }
+
+ // for url content type, encode a redirect to the body URL
+ if (contentType.equalsIgnoreCase(ResourceProperties.TYPE_URL))
+ {
+ M_log.warn("REMOVED CODE (url type) - SHOULD NOT ENTER HERE");
+ } else
+ {
+ // use the last part, the file name part of the id, for the download file name
+ // String fileName = Web.encodeFileName( req, Validator.getFileName(ref.getId()) );
+ String fileName = Web.encodeFileName( req, rp.getProperty(rp.getNamePropDisplayName()) );
+ M_log.debug("fileName " + fileName);
+
+ String disposition = null;
+ if (Validator.letBrowserInline(contentType))
+ {
+ // if this is an html file we have more checks
+ String lcct = contentType.toLowerCase();
+ if ( ( lcct.startsWith("text/") || lcct.startsWith("image/")
+ || lcct.contains("html") || lcct.contains("script") ) &&
+ m_serverConfigurationService.getBoolean(SECURE_INLINE_HTML, true)) {
+ // increased checks to handle more mime-types - https://jira.sakaiproject.org/browse/KNL-749
+
+ boolean fileInline = false;
+ boolean folderInline = false;
+
+ try {
+ fileInline = rp.getBooleanProperty(ResourceProperties.PROP_ALLOW_INLINE);
+ }
+ catch (EntityPropertyNotDefinedException e) {
+ // we expect this so nothing to do!
+ }
+
+ if (!fileInline)
+ try
+ {
+ folderInline = resource.getContainingCollection().getProperties().getBooleanProperty(ResourceProperties.PROP_ALLOW_INLINE);
+ }
+ catch (EntityPropertyNotDefinedException e) {
+ // we expect this so nothing to do!
+ }
+
+ if (fileInline || folderInline) {
+ disposition = "inline; filename=\"" + fileName + "\"";
+ }
+ } else {
+ disposition = "inline; filename=\"" + fileName + "\"";
+ }
+ }
+
+ // drop through to attachment
+ if (disposition == null)
+ {
+ disposition = "attachment; filename=\"" + fileName + "\"";
+ }
+
+ // NOTE: Only set the encoding on the content we have to.
+ // Files uploaded by the user may have been created with different encodings, such as ISO-8859-1;
+ // rather than (sometimes wrongly) saying its UTF-8, let the browser auto-detect the encoding.
+ // If the content was created through the WYSIWYG editor, the encoding does need to be set (UTF-8).
+ String encoding = resource.getProperties().getProperty(ResourceProperties.PROP_CONTENT_ENCODING);
+ if (encoding != null && encoding.length() > 0)
+ {
+ contentType = contentType + "; charset=" + encoding;
+ }
+
+ // KNL-1316 let's see if the user already has a cached copy. Code copied and modified from Tomcat DefaultServlet.java
+ long headerValue = req.getDateHeader("If-Modified-Since");
+ if (headerValue != -1 && (lastModTime < headerValue + 1000)) {
+ // The entity has not been modified since the date specified by the client. This is not an error case.
+ res.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+
+ res.addHeader("Accept-Ranges", "bytes");
+
+ // stream the content using a small buffer to keep memory managed
+ InputStream content = null;
+ OutputStream out = null;
+
+ try
+ {
+ content = resource.streamContent();
+ if (content == null)
+ {
+ //throw new IdUnusedException(ref.getReference());
+ M_log.warn("NULL CONTENT - SHOULD NOT ENTER HERE");
+ return;
+ }
+
+ res.setContentType(contentType);
+ res.addHeader("Content-Disposition", disposition);
+ // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4187336
+ if (len <= Integer.MAX_VALUE){
+ res.setContentLength((int)len);
+ } else {
+ res.addHeader("Content-Length", Long.toString(len));
+ }
+
+ // set the buffer of the response to match what we are reading from the request
+ if (len < STREAM_BUFFER_SIZE)
+ {
+ res.setBufferSize((int)len);
+ }
+ else
+ {
+ res.setBufferSize(STREAM_BUFFER_SIZE);
+ }
+
+ out = res.getOutputStream();
+
+ copyRange(content, out, 0, len-1);
+ }
+ catch (ServerOverloadException e)
+ {
+ throw e;
+ }
+ catch (Exception ignore)
+ {
+ }
+ finally
+ {
+ // be a good little program and close the stream - freeing up valuable system resources
+ if (content != null)
+ {
+ content.close();
+ }
+
+ if (out != null)
+ {
+ try
+ {
+ out.close();
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ }
+ // Track event - only for full reads
+ //TODO eventTrackingService.post(eventTrackingService.newEvent(EVENT_RESOURCE_READ, resource.getReference(null), false));
+ } // output resource
+ }
+ catch (Exception t)
+ {
+ M_log.error("Exception handling content " + t.getMessage());
+ }
+ }
+
+ /**
+ * Copy the partial contents of the specified input stream to the specified
+ * output stream.
+ *
+ * @param istream The input stream to read from
+ * @param ostream The output stream to write to
+ * @param start Start of the range which will be copied
+ * @param end End of the range which will be copied
+ * @return Exception which occurred during processing
+ */
+ protected IOException copyRange(InputStream istream,
+ OutputStream ostream,
+ long start, long end) {
+
+ try {
+ istream.skip(start);
+ } catch (IOException e) {
+ return e;
+ }
+
+ IOException exception = null;
+ long bytesToRead = end - start + 1;
+
+ byte buffer[] = new byte[STREAM_BUFFER_SIZE];
+ int len = buffer.length;
+ while ( (bytesToRead > 0) && (len >= buffer.length)) {
+ try {
+ len = istream.read(buffer);
+ if (bytesToRead >= len) {
+ ostream.write(buffer, 0, len);
+ bytesToRead -= len;
+ } else {
+ ostream.write(buffer, 0, (int) bytesToRead);
+ bytesToRead = 0;
+ }
+ } catch (IOException e) {
+ exception = e;
+ len = -1;
+ }
+ if (len < buffer.length)
+ break;
+ }
+
+ return exception;
+ }
+
/**
* {@inheritDoc}
*/
@@ -6057,9 +6322,68 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
Collection copyrightAcceptedRefs) throws EntityPermissionException, EntityNotDefinedException,
EntityAccessOverloadException, EntityCopyrightException
{
+ M_log.debug("handleAccess from getHttpAccess ");
+ M_log.debug("ref " + ref.getId() + " - " + ref.getSubType() + " - " + ref.getReference() + " - " + ref.getContainer());
if (SessionManager.getCurrentSessionUserId() == null)
{
- // fail the request, user not logged in yet.
+ M_log.debug("user not logged in");
+ try{
+ if ("s".equals(ref.getSubType()))
+ {
+ M_log.debug("getting submission");
+ //TODO should we check the assignment settings?
+ Session newsession = SessionManager.startSession();
+ newsession.setActive();
+ SessionManager.setCurrentSession(newsession);
+ newsession.setUserId("admin");
+ newsession.setUserEid("admin");
+ if (newsession == null){
+ M_log.debug("startSession() failed.");
+ } else {
+ M_log.debug(newsession.getId());
+ }
+ if(!ref.getId().contains(":")){
+ M_log.debug("No content review item specified");
+ return;
+ }
+ String[] ids = ref.getId().split(":");
+ String submissionId = ids[0];
+ String criId = ids[1];
+ AssignmentSubmission s = getSubmission(submissionId);
+ ContentReviewItem cri = contentReviewService.getItemById(criId);
+ M_log.debug("cri " + criId + " - content " + cri.getContentId());
+ ContentResource cr = m_contentHostingService.getResource(cri.getContentId());
+ if(s == null || cr == null || cri == null){
+ M_log.warn("Could not get submission, content or contentreviewitem " + ref.getId());
+ return;
+ } else {
+ M_log.debug("submission url " + s.getUrl());
+ if (s.getSubmittedAttachments().isEmpty())
+ M_log.debug(this + " getReviewScore No attachments submitted.");
+ else {
+ if(cri.isUrlAccessed()){
+ M_log.warn("Trying to access an url already accessed, submission id " + s.getId());
+ return;
+ }
+
+ handleAccessResource(req, res, cr);
+
+ boolean itemUpdated = contentReviewService.updateItemAccess(cr.getId());
+ if(!itemUpdated){
+ M_log.error("Could not update cr item access status");
+ }
+
+ //TODO close sakai session
+ }
+ }
+ }
+ // else fail the request, user not logged in yet.
+ }
+ catch (Throwable t)
+ {
+ M_log.warn(" HandleAccess: caught exception " + t.toString() + " and rethrow it!");
+ throw new EntityNotDefinedException(ref.getReference());
+ }
}
else
{
@@ -8750,6 +9074,8 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
protected boolean m_allowReviewService;
protected boolean m_allowStudentViewReport;
+
+ protected boolean m_allowStudentViewExternalGrade;
String m_submitReviewRepo;
String m_generateOriginalityReport;
@@ -8757,6 +9083,7 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
boolean m_checkInternet = true;
boolean m_checkPublications = true;
boolean m_checkInstitution = true;
+ boolean m_allowAnyFile = false;
boolean m_excludeBibliographic = true;
boolean m_excludeQuoted = true;
int m_excludeType = 0;
@@ -8837,12 +9164,14 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
m_hideDueDate = getBool(el.getAttribute("hideduedate"));
m_allowReviewService = getBool(el.getAttribute("allowreview"));
m_allowStudentViewReport = getBool(el.getAttribute("allowstudentview"));
+ m_allowStudentViewExternalGrade = getBool(el.getAttribute("allowstudentviewexternalgrade"));
m_submitReviewRepo = el.getAttribute("submitReviewRepo");
m_generateOriginalityReport = el.getAttribute("generateOriginalityReport");
m_checkTurnitin = getBool(el.getAttribute("checkTurnitin"));
m_checkInternet = getBool(el.getAttribute("checkInternet"));
m_checkPublications = getBool(el.getAttribute("checkPublications"));
m_checkInstitution = getBool(el.getAttribute("checkInstitution"));
+ m_allowAnyFile = getBool(el.getAttribute("allowAnyFile"));
m_excludeBibliographic = getBool(el.getAttribute("excludeBibliographic"));
m_excludeQuoted = getBool(el.getAttribute("excludeQuoted"));
String excludeTypeStr = el.getAttribute("excludeType");
@@ -9049,12 +9378,14 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
m_hideDueDate = getBool(attributes.getValue("hideduedate"));
m_allowReviewService = getBool(attributes.getValue("allowreview"));
m_allowStudentViewReport = getBool(attributes.getValue("allowstudentview"));
+ m_allowStudentViewExternalGrade = getBool(attributes.getValue("allowstudentviewexternalgrade"));
m_submitReviewRepo = attributes.getValue("submitReviewRepo");
m_generateOriginalityReport = attributes.getValue("generateOriginalityReport");
m_checkTurnitin = getBool(attributes.getValue("checkTurnitin"));
m_checkInternet = getBool(attributes.getValue("checkInternet"));
m_checkPublications = getBool(attributes.getValue("checkPublications"));
m_checkInstitution = getBool(attributes.getValue("checkInstitution"));
+ m_allowAnyFile = getBool(attributes.getValue("allowAnyFile"));
m_excludeBibliographic = getBool(attributes.getValue("excludeBibliographic"));
m_excludeQuoted = getBool(attributes.getValue("excludeQuoted"));
String excludeTypeStr = attributes.getValue("excludeType");
@@ -9230,12 +9561,14 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
content.setAttribute("allowreview", getBoolString(m_allowReviewService));
content.setAttribute("allowstudentview", getBoolString(m_allowStudentViewReport));
+ content.setAttribute("allowstudentviewexternalgrade", getBoolString(m_allowStudentViewExternalGrade));
content.setAttribute("submitReviewRepo", m_submitReviewRepo);
content.setAttribute("generateOriginalityReport", m_generateOriginalityReport);
content.setAttribute("checkTurnitin", getBoolString(m_checkTurnitin));
content.setAttribute("checkInternet", getBoolString(m_checkInternet));
content.setAttribute("checkPublications", getBoolString(m_checkPublications));
content.setAttribute("checkInstitution", getBoolString(m_checkInstitution));
+ content.setAttribute("allowAnyFile", getBoolString(m_allowAnyFile));
content.setAttribute("excludeBibliographic", getBoolString(m_excludeBibliographic));
content.setAttribute("excludeQuoted", getBoolString(m_excludeQuoted));
content.setAttribute("excludeType", Integer.toString(m_excludeType));
@@ -9311,12 +9644,14 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
//Uct
m_allowReviewService = content.getAllowReviewService();
m_allowStudentViewReport = content.getAllowStudentViewReport();
+ m_allowStudentViewExternalGrade = content.getAllowStudentViewExternalGrade();
m_submitReviewRepo = content.getSubmitReviewRepo();
m_generateOriginalityReport = content.getGenerateOriginalityReport();
m_checkTurnitin = content.isCheckTurnitin();
m_checkInternet = content.isCheckInternet();
m_checkPublications = content.isCheckPublications();
m_checkInstitution = content.isCheckInstitution();
+ m_allowAnyFile = content.isAllowAnyFile();
m_excludeBibliographic = content.isExcludeBibliographic();
m_excludeQuoted = content.isExcludeQuoted();
m_excludeType = content.getExcludeType();
@@ -9676,6 +10011,9 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
return m_allowStudentViewReport;
}
+ public boolean getAllowStudentViewExternalGrade() {
+ return m_allowStudentViewExternalGrade;
+ }
/**
* Access the time that this object was created.
@@ -9840,6 +10178,14 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
public void setExcludeValue(int m_excludeValue){
this.m_excludeValue = m_excludeValue;
}
+
+ public boolean isAllowAnyFile() {
+ return m_allowAnyFile;
+ }
+
+ public void setAllowAnyFile(boolean m_allowAnyFile) {
+ this.m_allowAnyFile = m_allowAnyFile;
+ }
}// BaseAssignmentContent
@@ -10112,6 +10458,16 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
}
/**
+ * Does this Assignment allow students to view the external grades?
+ *
+ * @param allow -
+ * true if the Assignment allows students to view the external grades, false otherwise
+ */
+ public void setAllowStudentViewExternalGrade(boolean allow) {
+ m_allowStudentViewExternalGrade = allow;
+ }
+
+ /**
* Does this Assignment allow attachments?
*
* @param allow -
@@ -10326,6 +10682,9 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
protected String m_reviewStatus;
protected String m_reviewIconUrl;
+ protected String m_reviewIconColor;
+
+ protected boolean m_externalGradeDifferent;
protected String m_reviewError;
@@ -10394,7 +10753,8 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
return m_reviewScore.intValue();
}
- ContentResource cr = getFirstAcceptableAttachement();
+ boolean allowAnyFile = this.getAssignment().getContent().isAllowAnyFile();
+ ContentResource cr = getFirstAcceptableAttachement(allowAnyFile);
if (cr == null )
{
M_log.debug(this + " getReviewScore No suitable attachments found in list");
@@ -10423,10 +10783,9 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
catch (QueueException cie) {
//should we add the item
try {
-
M_log.debug(this + " getReviewScore Item is not in queue we will try add it");
- try {
- contentReviewService.queueContent(getContentReviewSubmitterId(cr), this.getContext(), getAssignment().getReference(), Arrays.asList(cr));
+ try {
+ contentReviewService.queueContent(getContentReviewSubmitterId(cr), this.getContext(), getAssignment().getReference(), Arrays.asList(cr), this.getId(), false);
}
catch (QueueException qe) {
M_log.warn(" getReviewScore Unable to queue content with content review Service: " + qe.getMessage());
@@ -10498,7 +10857,7 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
M_log.debug(" getReviewScore(ContentResource) Item is not in queue we will try to add it");
try
{
- contentReviewService.queueContent(getContentReviewSubmitterId(cr), this.getContext(), getAssignment().getReference(), Arrays.asList(cr));
+ contentReviewService.queueContent(getContentReviewSubmitterId(cr), this.getContext(), getAssignment().getReference(), Arrays.asList(cr), this.getId(), false);
}
catch (QueueException qe)
{
@@ -10540,7 +10899,8 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
else
{
try {
- ContentResource cr = getFirstAcceptableAttachement();
+ boolean allowAnyFile = this.getAssignment().getContent().isAllowAnyFile();
+ ContentResource cr = getFirstAcceptableAttachement(allowAnyFile);
if (cr == null )
{
M_log.debug(this + " getReviewReport No suitable attachments found in list");
@@ -10548,11 +10908,22 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
}
String contentId = cr.getId();
-
- if (allowGradeSubmission(getReference()))
- return contentReviewService.getReviewReportInstructor(contentId, getAssignment().getReference(), UserDirectoryService.getCurrentUser().getId());
- else
- return contentReviewService.getReviewReportStudent(contentId, getAssignment().getReference(), UserDirectoryService.getCurrentUser().getId());
+ try {
+ Site site = SiteService.getSite(m_context);
+ boolean siteCanUseLTIReviewService = contentReviewSiteAdvisor.siteCanUseLTIReviewService(site);
+ if (siteCanUseLTIReviewService) {
+ return contentReviewService.getReviewReport(contentId, null, null);
+ } else {
+ if (allowGradeSubmission(getReference())){
+ return contentReviewService.getReviewReportInstructor(contentId, getAssignment().getReference(), UserDirectoryService.getCurrentUser().getId());
+ } else {
+ return contentReviewService.getReviewReportStudent(contentId, getAssignment().getReference(), UserDirectoryService.getCurrentUser().getId());
+ }
+ }
+ } catch (IdUnusedException _iue) {
+ M_log.debug(this + " getReviewReport Could not find site from m_context value " + m_context);
+ return "error";
+ }
} catch (Exception e) {
M_log.warn(":getReviewReport() " + e.getMessage());
@@ -10578,13 +10949,21 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
try
{
String contentId = cr.getId();
- if (allowGradeSubmission(getReference()))
- {
- return contentReviewService.getReviewReportInstructor(contentId, getAssignment().getReference(), UserDirectoryService.getCurrentUser().getId());
- }
- else
- {
- return contentReviewService.getReviewReportStudent(contentId, getAssignment().getReference(), UserDirectoryService.getCurrentUser().getId());
+ try {
+ Site site = SiteService.getSite(m_context);
+ boolean siteCanUseLTIReviewService = contentReviewSiteAdvisor.siteCanUseLTIReviewService(site);
+ if (siteCanUseLTIReviewService) {
+ return contentReviewService.getReviewReport(contentId, null, null);
+ } else {
+ if (allowGradeSubmission(getReference())){
+ return contentReviewService.getReviewReportInstructor(contentId, getAssignment().getReference(), UserDirectoryService.getCurrentUser().getId());
+ } else {
+ return contentReviewService.getReviewReportStudent(contentId, getAssignment().getReference(), UserDirectoryService.getCurrentUser().getId());
+ }
+ }
+ } catch (IdUnusedException _iue) {
+ M_log.debug(this + " getReviewReport Could not find site from m_context value " + m_context);
+ return "error";
}
}
catch (Exception e)
@@ -10595,13 +10974,13 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
}
//TODO: delete this and all calling methods if there are no repercussions
- private ContentResource getFirstAcceptableAttachement() {
+ private ContentResource getFirstAcceptableAttachement(boolean allowAnyFile) {
String contentId = null;
try {
for( int i =0; i < m_submittedAttachments.size();i++ ) {
Reference ref = (Reference)m_submittedAttachments.get(i);
ContentResource contentResource = (ContentResource)ref.getEntity();
- if (contentReviewService.isAcceptableContent(contentResource)) {
+ if (contentReviewService.isAcceptableSize(contentResource) && (allowAnyFile || contentReviewService.isAcceptableContent(contentResource))){
return (ContentResource)contentResource;
}
}
@@ -10616,7 +10995,7 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
/**
* SAK-26322 - Gets all attachments in m_submittedAttachments that are acceptable to the content review service
*/
- private List<ContentResource> getAllAcceptableAttachments()
+ private List<ContentResource> getAllAcceptableAttachments(boolean allowAnyFile)
{
List<ContentResource> attachments = new ArrayList<ContentResource>();
for (int i = 0; i< m_submittedAttachments.size(); i++)
@@ -10625,7 +11004,7 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
{
Reference ref = (Reference)m_submittedAttachments.get(i);
ContentResource contentResource = (ContentResource)ref.getEntity();
- if (contentReviewService.isAcceptableContent(contentResource))
+ if (contentReviewService.isAcceptableSize(contentResource) && (allowAnyFile || contentReviewService.isAcceptableContent(contentResource)))
{
attachments.add((ContentResource)contentResource);
}
@@ -10652,7 +11031,8 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
else
{
try {
- ContentResource cr = getFirstAcceptableAttachement();
+ boolean allowAnyFile = this.getAssignment().getContent().isAllowAnyFile();
+ ContentResource cr = getFirstAcceptableAttachement(allowAnyFile);
if (cr == null )
{
M_log.debug(this + " getReviewError No suitable attachments found in list");
@@ -10771,6 +11151,17 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
return m_reviewIconUrl;
}
+
+ public String getReviewIconColor() {
+ if (m_reviewIconColor == null )
+ m_reviewIconColor = contentReviewService.getIconColorforScore(Long.valueOf(this.getReviewScore()));
+
+ return m_reviewIconColor;
+ }
+
+ public boolean isExternalGradeDifferent() {
+ return m_externalGradeDifferent;
+ }
/**
* @inheritDoc
@@ -10781,7 +11172,8 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
ArrayList<ContentReviewResult> reviewResults = new ArrayList<ContentReviewResult>();
//get all the attachments for this submission and populate the reviewResults
- List<ContentResource> contentResources = getAllAcceptableAttachments();
+ boolean allowAnyFile = this.getAssignment().getContent().isAllowAnyFile();
+ List<ContentResource> contentResources = getAllAcceptableAttachments(allowAnyFile);
Iterator<ContentResource> itContentResources = contentResources.iterator();
while (itContentResources.hasNext())
{
@@ -10795,6 +11187,8 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
//skip review status, it's unused
String iconUrl = contentReviewService.getIconUrlforScore(Long.valueOf(reviewScore));
reviewResult.setReviewIconURL(iconUrl);
+ reviewResult.setReviewIconColor(contentReviewService.getIconColorforScore(Long.valueOf(reviewScore)));
+ reviewResult.setExternalGrade(contentReviewService.getExternalGradeForContentId(cr.getId()));
reviewResult.setReviewError(getReviewError(cr));
if ("true".equals(cr.getProperties().getProperty(PROP_INLINE_SUBMISSION)))
@@ -10944,6 +11338,8 @@ public abstract class BaseAssignmentService implements AssignmentService, Entity
m_gradeReleased = getBool(el.getAttribute("gradereleased"));
m_honorPledgeFlag = getBool(el.getAttribute("pledgeflag"));
m_hideDueDate = getBool(el.getAttribute("hideduedate"));
+
+ m_externalGradeDifferent = getBool(el.getAttribute("isexternalgradedif"));
m_submittedText = FormattedText.decodeFormattedTextAttribute(el, "submittedtext");
m_feedbackComment = FormattedText.decodeFormattedTextAttribute(el, "feedbackcomment");