diff --git a/content-review/impl/turnitin-oc/README.md b/content-review/impl/turnitin-oc/README.md index f3b762375ef4..f81e9f80e28f 100644 --- a/content-review/impl/turnitin-oc/README.md +++ b/content-review/impl/turnitin-oc/README.md @@ -164,6 +164,18 @@ assignment.useContentReview=true # turnitin.oc.roles.administrator.mapping=Administrator,Admin # turnitin.oc.roles.undefined.mapping="" +#turnitin.oc.roles.[TII_ROLE].may_save_report_changes=true/false +# Allows you to customize the default Turnitin setting for each role controlling whether a report can be saved when modified. +# If true, any changes to the report, including changes that effect the score, will be saved and persist for all users. +# Default: +# turnitin.oc.roles.instructor.may_save_report_changes=true +# turnitin.oc.roles.learner.may_save_report_changes=false +# turnitin.oc.roles.editor.may_save_report_changes=false +# turnitin.oc.roles.user.may_save_report_changes=false +# turnitin.oc.roles.applicant.may_save_report_changes=false +# turnitin.oc.roles.administrator.may_save_report_changes=true +# turnitin.oc.roles.undefined.may_save_report_changes=false + # Please make sure the property 'version.sakai' is set correctly ``` diff --git a/content-review/impl/turnitin-oc/src/main/java/org/sakaiproject/contentreview/turnitin/oc/ContentReviewServiceTurnitinOC.java b/content-review/impl/turnitin-oc/src/main/java/org/sakaiproject/contentreview/turnitin/oc/ContentReviewServiceTurnitinOC.java index ca82448caf8f..67a1d467f9ff 100644 --- a/content-review/impl/turnitin-oc/src/main/java/org/sakaiproject/contentreview/turnitin/oc/ContentReviewServiceTurnitinOC.java +++ b/content-review/impl/turnitin-oc/src/main/java/org/sakaiproject/contentreview/turnitin/oc/ContentReviewServiceTurnitinOC.java @@ -18,9 +18,9 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.IOException; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; @@ -167,17 +167,20 @@ public class ContentReviewServiceTurnitinOC extends BaseContentReviewService { private static final String VIEWER_PERMISSION_MAY_VIEW_MATCH_SUBMISSION_INFO = "may_view_match_submission_info"; private static final String VIEWER_DEFAULT_PERMISSIONS = "viewer_default_permission_set"; private enum ROLES{ - INSTRUCTOR(Arrays.asList("Faculty", "Instructor", "Mentor", "Staff", "maintain", "Teaching Assistant")), - LEARNER(Arrays.asList("Learner", "Student", "access")), - EDITOR(Arrays.asList()), - USER(Arrays.asList("Alumni", "guest", "Member", "Observer", "Other")), - APPLICANT(Arrays.asList("ProspectiveStudent")), - ADMINISTRATOR(Arrays.asList("Administrator", "Admin")), - UNDEFINED(Arrays.asList()); + INSTRUCTOR(Arrays.asList("Faculty", "Instructor", "Mentor", "Staff", "maintain", "Teaching Assistant"), Boolean.TRUE), + LEARNER(Arrays.asList("Learner", "Student", "access"), Boolean.FALSE), + EDITOR(Arrays.asList(), Boolean.FALSE), + USER(Arrays.asList("Alumni", "guest", "Member", "Observer", "Other"), Boolean.FALSE), + APPLICANT(Arrays.asList("ProspectiveStudent"), Boolean.FALSE), + ADMINISTRATOR(Arrays.asList("Administrator", "Admin"), Boolean.TRUE), + UNDEFINED(Arrays.asList(), Boolean.FALSE); List mappedRoles; - private ROLES(List mappedRoles) { + Boolean maySaveReportChanges; + + private ROLES(List mappedRoles, Boolean maySaveReportChanges) { this.mappedRoles = mappedRoles; + this.maySaveReportChanges = maySaveReportChanges; } private void setMappedRoles(List mappedRoles) { this.mappedRoles = mappedRoles; @@ -185,6 +188,12 @@ private void setMappedRoles(List mappedRoles) { private List getMappedRoles() { return mappedRoles; } + public Boolean getMaySaveReportChanges() { + return maySaveReportChanges; + } + public void setMaySaveReportChanges(Boolean maySaveReportChanges) { + this.maySaveReportChanges = maySaveReportChanges; + } }; private static final String GENERATE_REPORTS_IMMEDIATELY_AND_ON_DUE_DATE= "1"; @@ -335,7 +344,10 @@ public void init() { // Override default Sakai->Turnitin roles mapping for(ROLES role : ROLES.values()) { + //map Sakai roles to Turnitin roles role.setMappedRoles(serverConfigurationService.getStringList("turnitin.oc.roles." + role.name().toLowerCase() + ".mapping", role.getMappedRoles())); + //set maySaveReportChanges permission for each role + role.setMaySaveReportChanges(serverConfigurationService.getBoolean("turnitin.oc.roles." + role.name().toLowerCase() + ".may_save_report_changes", role.getMaySaveReportChanges())); } // Populate base headers that are needed for all calls to TCA @@ -573,10 +585,11 @@ public String getReviewReportRedirectUrl(String contentId, String assignmentRef, modes.put(ALL_SOURCES, Boolean.TRUE); similarity.put(MODES, modes); Map viewSettings = new HashMap<>(); - viewSettings.put(SAVE_CHANGES, Boolean.TRUE); similarity.put(VIEW_SETTINGS, viewSettings); data.put(SIMILARITY, similarity); - data.put(VIEWER_DEFAULT_PERMISSIONS, mapUserRole(userId, contextId, isInstructor)); + ROLES userRole = mapUserRole(userId, contextId, isInstructor); + data.put(VIEWER_DEFAULT_PERMISSIONS, userRole.name()); + viewSettings.put(SAVE_CHANGES, userRole.getMaySaveReportChanges()); //Check if there are any sakai.properties overrides for the default permissions Map viewerPermissionsOverride = new HashMap(); if(!isInstructor && mayViewSubmissionFullSourceOverrideStudent != null) { @@ -929,12 +942,12 @@ private String getSubmissionId(ContentReviewItem item, String fileName, Site sit Map data = new HashMap(); data.put("owner", userID); if(site != null) { - data.put("owner_default_permission_set", mapUserRole(userID, site.getId(), false)); + data.put("owner_default_permission_set", mapUserRole(userID, site.getId(), false).name()); } if (StringUtils.isNotBlank(submitterID)) { data.put("submitter", submitterID); if(site != null) { - data.put("submitter_default_permission_set", mapUserRole(submitterID, site.getId(), false)); + data.put("submitter_default_permission_set", mapUserRole(submitterID, site.getId(), false).name()); } } data.put("title", fileName); @@ -1865,15 +1878,14 @@ public void webhookEvent(HttpServletRequest request, int providerId, Optional r.getMappedRoles().stream().anyMatch(siteRole::equalsIgnoreCase)) - .map(r -> r.name()) .findFirst() .orElse(role); }catch(Exception e) {