From 58ca0e50eb86169e7737e000981d8386b9c995a5 Mon Sep 17 00:00:00 2001 From: Earle Nietzel Date: Thu, 29 Feb 2024 11:48:55 -0500 Subject: [PATCH 1/4] SAK-49766 Assignments releasing submissions should work consistently #12390 https://sakaiproject.atlassian.net/browse/SAK-49766 - this also removes the outdated option withGrade --- .../assignment/api/AssignmentConstants.java | 2 - .../api/src/resources/assignment.properties | 3 +- .../impl/AssignmentServiceImpl.java | 33 +- .../impl/AssignmentServiceTest.java | 12 +- .../AssignmentEntityProvider.java | 15 +- .../assignment/tool/AssignmentAction.java | 358 ++++++++--------- .../assignment/tool/AssignmentToolUtils.java | 106 ++--- .../WEB-INF/tools/sakai.assignment.grades.xml | 1 - assignment/tool/src/webapp/js/assignments.js | 5 + .../webapp/vm/assignment/assignment_macros.vm | 8 +- ...signments_instructor_grading_submission.vm | 372 +++++++++--------- ...nts_instructor_list_deleted_assignments.vm | 2 +- ...assignments_instructor_list_submissions.vm | 175 ++++---- ...ignments_instructor_new_edit_assignment.vm | 4 +- ...signments_instructor_preview_assignment.vm | 116 +++--- ...s_instructor_preview_grading_submission.vm | 2 +- ...signments_instructor_reorder_assignment.vm | 4 +- ...signments_instructor_report_submissions.vm | 2 +- ...nts_instructor_student_list_submissions.vm | 38 +- .../chef_assignments_list_assignments.vm | 16 +- .../vm/assignment/chef_assignments_options.vm | 2 +- ..._assignments_student_confirm_submission.vm | 58 ++- ..._assignments_student_preview_submission.vm | 58 ++- .../chef_assignments_student_review_edit.vm | 74 ++-- .../chef_assignments_student_view_grade.vm | 76 ++-- ...hef_assignments_student_view_submission.vm | 136 +++---- 26 files changed, 807 insertions(+), 871 deletions(-) diff --git a/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentConstants.java b/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentConstants.java index c290403dbb95..014c27513b45 100644 --- a/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentConstants.java +++ b/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentConstants.java @@ -333,8 +333,6 @@ public enum IMSGradingProgress { public static final String STATE_CONTEXT_STRING = "Assignment.context_string"; - public static final String WITH_GRADES = "with_grades"; - public static final String GRADE_SUBMISSION_SUBMISSION_ID = "grade_submission_submission_id"; public static final String GRADE_SUBMISSION_ASSIGNMENT_ID = "grade_submission_assignment_id"; public static final String GRADE_SUBMISSION_GRADE = "grade_submission_grade"; diff --git a/assignment/api/src/resources/assignment.properties b/assignment/api/src/resources/assignment.properties index 3f97ccd6b4e5..fe3af62979df 100644 --- a/assignment/api/src/resources/assignment.properties +++ b/assignment/api/src/resources/assignment.properties @@ -1060,7 +1060,8 @@ sendFeedback.label = Send Feedback to Multiple Students sendFeedback.instruction = Select students from the table below. Write your feedback in the following text area, select any additional feedback options, and then click "Update" to save. sendFeedback.options = Feedback options sendFeedback.overwrite = Replace existing "Instructor Summary Comments" feedback for selected students. -sendFeedback.returnToStudents = Return feedback to selected students now. (NOTE: Only the feedback will be released, if you want to release the grades you must click on "Release Grades"). +sendFeedback.returnToStudents = Return feedback to selected students now +sendFeedback.returnToStudents.note = (NOTE: Only the feedback will be released, if you want to release the grades you must click on "Release Grades") sendFeedback.nouser = Please choose at least one student to send feedback. sendFeedback.nocomment = Please enter a feedback comment. sendFeedback.savedow = Feedback has been replaced and saved successfully. diff --git a/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java b/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java index cbbc4c547c2f..e1366c002a57 100644 --- a/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java +++ b/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java @@ -1942,21 +1942,31 @@ private AssignmentConstants.SubmissionStatus getGradersCanonicalSubmissionStatus } } else { if (returnTime != null && returnTime.isAfter(submitTime)) { - return resubmissionAllowed ? SubmissionStatus.RETURNED_PENDING_RESUBMIT : SubmissionStatus.RETURNED; + return resubmissionAllowed ? SubmissionStatus.RETURNED_PENDING_RESUBMIT : SubmissionStatus.RETURNED; } else { return SubmissionStatus.RETURNED; } } } else if (submission.getGraded()) { - return StringUtils.isNotBlank(submission.getGrade()) ? SubmissionStatus.GRADED : SubmissionStatus.COMMENTED; - } else { - return SubmissionStatus.UNGRADED; + if (StringUtils.isNotBlank(submission.getGrade())) { + return SubmissionStatus.GRADED; + } else if (StringUtils.isNotBlank(submission.getFeedbackComment())) { + return SubmissionStatus.COMMENTED; + } + } else if (StringUtils.isNotBlank(submission.getFeedbackComment())) { + return SubmissionStatus.COMMENTED; } } else { if (submission.getReturned()) { return SubmissionStatus.RETURNED; } else if (submission.getGraded()) { - return StringUtils.isNotBlank(submission.getGrade()) ? SubmissionStatus.GRADED : SubmissionStatus.COMMENTED; + if (StringUtils.isNotBlank(submission.getGrade())) { + return SubmissionStatus.GRADED; + } else if (StringUtils.isNotBlank(submission.getFeedbackComment())) { + return SubmissionStatus.COMMENTED; + } + } else if (StringUtils.isNotBlank(submission.getFeedbackComment())) { + return SubmissionStatus.COMMENTED; } else { return SubmissionStatus.NO_SUBMISSION; } @@ -1968,12 +1978,17 @@ private AssignmentConstants.SubmissionStatus getGradersCanonicalSubmissionStatus return SubmissionStatus.RETURNED; } else { // grade saved but not release yet, show this to graders - return StringUtils.isNotBlank(submission.getGrade()) ? AssignmentConstants.SubmissionStatus.GRADED : AssignmentConstants.SubmissionStatus.COMMENTED; + if (StringUtils.isNotBlank(submission.getGrade())) { + return SubmissionStatus.GRADED; + } else if (StringUtils.isNotBlank(submission.getFeedbackComment())) { + return SubmissionStatus.COMMENTED; + } } - } else { - return SubmissionStatus.UNGRADED; + } else if (StringUtils.isNotBlank(submission.getFeedbackComment())) { + return SubmissionStatus.COMMENTED; } } + return SubmissionStatus.UNGRADED; } private AssignmentConstants.SubmissionStatus getSubmittersCanonicalSubmissionStatus(AssignmentSubmission submission) { @@ -2936,8 +2951,6 @@ public boolean isGradeOverridden(AssignmentSubmission submission, String submitt * Contains logic to consistently output a String based version of a grade * Interprets the grade using the scale for display * - * This should probably be moved to a static utility class - ern - * * @param grade * @param typeOfGrade * @param scaleFactor diff --git a/assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentServiceTest.java b/assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentServiceTest.java index 769aebae8660..b233648c9ffb 100644 --- a/assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentServiceTest.java +++ b/assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentServiceTest.java @@ -833,15 +833,17 @@ public void submissionCanonicalStatus() { assignment.setDueDate(null); Assert.assertEquals(AssignmentConstants.SubmissionStatus.GRADED, assignmentService.getSubmissionCanonicalStatus(submission, true)); - // submission is Submitted | DateSubmitted exists | submission not Returned | submission is Graded | User can Grade | Grade not exists = COMMENTED + // submission is Submitted | DateSubmitted exists | submission not Returned | submission is Graded | User can Grade | Comment exists | Grade not exists = COMMENTED submission.setSubmitted(true); submission.setDateSubmitted(now); submission.setReturned(false); submission.setDateReturned(null); submission.setGraded(true); submission.setGrade(null); + submission.setFeedbackComment("Graders comment"); assignment.setDueDate(null); Assert.assertEquals(AssignmentConstants.SubmissionStatus.COMMENTED, assignmentService.getSubmissionCanonicalStatus(submission, true)); + submission.setFeedbackComment(null); // submission is Submitted | DateSubmitted exists | submission not Returned | User can't Grade = SUBMITTED submission.setSubmitted(true); @@ -884,15 +886,17 @@ public void submissionCanonicalStatus() { assignment.setDueDate(null); Assert.assertEquals(AssignmentConstants.SubmissionStatus.GRADED, assignmentService.getSubmissionCanonicalStatus(submission, true)); - // submission is Submitted | DateSubmitted not exists | submission not Returned | submission is Graded | User can Grade | Grade not exists = COMMENTED + // submission is Submitted | DateSubmitted not exists | submission not Returned | submission is Graded | User can Grade | Comment exists | Grade not exists = COMMENTED submission.setSubmitted(true); submission.setDateSubmitted(null); submission.setReturned(false); submission.setDateReturned(null); submission.setGraded(true); submission.setGrade(null); + submission.setFeedbackComment("Graders comment"); assignment.setDueDate(null); Assert.assertEquals(AssignmentConstants.SubmissionStatus.COMMENTED, assignmentService.getSubmissionCanonicalStatus(submission, true)); + submission.setFeedbackComment(null); // submission is Submitted | DateSubmitted not exists | submission not Returned | submission not Graded | User can't Grade | Assignment is HonorPledge | Submission is HonorPledge = HONOR_ACCEPTED submission.setSubmitted(true); @@ -991,12 +995,14 @@ public void submissionCanonicalStatus() { submission.setGrade("1000"); Assert.assertEquals(AssignmentConstants.SubmissionStatus.GRADED, assignmentService.getSubmissionCanonicalStatus(submission, true)); - // submission not Submitted | submission Graded | submission not Returned | User can Grade | Grade not exists = COMMENTED + // submission not Submitted | submission Graded | submission not Returned | User can Grade | Comment exists | Grade not exists = COMMENTED submission.setSubmitted(false); submission.setReturned(false); submission.setGraded(true); + submission.setFeedbackComment("Graders comment"); submission.setGrade(null); Assert.assertEquals(AssignmentConstants.SubmissionStatus.COMMENTED, assignmentService.getSubmissionCanonicalStatus(submission, true)); + submission.setFeedbackComment(null); // submission not Submitted | submission Graded | submission not Returned | User can't Grade = IN_PROGRESS submission.setSubmitted(false); diff --git a/assignment/tool/src/java/org/sakaiproject/assignment/entityproviders/AssignmentEntityProvider.java b/assignment/tool/src/java/org/sakaiproject/assignment/entityproviders/AssignmentEntityProvider.java index ee2fa382ef0c..87cf0c0d8f0c 100644 --- a/assignment/tool/src/java/org/sakaiproject/assignment/entityproviders/AssignmentEntityProvider.java +++ b/assignment/tool/src/java/org/sakaiproject/assignment/entityproviders/AssignmentEntityProvider.java @@ -1161,10 +1161,16 @@ public ActionReturn setGrade(Map params) { throw new EntityException("You don't have permission to set grades", "", HttpServletResponse.SC_FORBIDDEN); } - if (assignment.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { - grade = assignmentToolUtils.scalePointGrade(grade, assignment.getScaleFactor(), alerts); - } else if (assignment.getTypeOfGrade() == Assignment.GradeType.PASS_FAIL_GRADE_TYPE && grade.equals(AssignmentConstants.UNGRADED_GRADE_STRING)) { - grade = null; + switch (assignment.getTypeOfGrade()) { + case SCORE_GRADE_TYPE: + grade = assignmentToolUtils.scalePointGrade(grade, assignment.getScaleFactor(), alerts); + break; + case UNGRADED_GRADE_TYPE: + grade = ASSN_GRADE_TYPE_NOGRADE_PROP; + break; + case PASS_FAIL_GRADE_TYPE: + if (AssignmentConstants.UNGRADED_GRADE_STRING.equals(grade)) grade = null; + default: } Map options = new HashMap<>(); @@ -1187,7 +1193,6 @@ public ActionReturn setGrade(Map params) { options.put(GRADE_SUBMISSION_FEEDBACK_TEXT, feedbackText); options.put(GRADE_SUBMISSION_FEEDBACK_COMMENT, feedbackComment); options.put(GRADE_SUBMISSION_PRIVATE_NOTES, privateNotes); - options.put(WITH_GRADES, true); options.put(ALLOW_RESUBMIT_NUMBER, resubmitNumber); if (StringUtils.isNotBlank(resubmitDate)) { diff --git a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java index cbaab70dcbe3..30cc0c5fa8ad 100644 --- a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java +++ b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java @@ -47,13 +47,6 @@ import static org.sakaiproject.assignment.api.AssignmentServiceConstants.PROP_ASSIGNMENT_GROUP_FILTER_ENABLED; import static org.sakaiproject.assignment.api.AssignmentServiceConstants.REFERENCE_ROOT; import static org.sakaiproject.assignment.api.AssignmentServiceConstants.SECURE_UPDATE_ASSIGNMENT; -import static org.sakaiproject.assignment.api.model.Assignment.GradeType.CHECK_GRADE_TYPE; -import static org.sakaiproject.assignment.api.model.Assignment.GradeType.GRADE_TYPE_NONE; -import static org.sakaiproject.assignment.api.model.Assignment.GradeType.LETTER_GRADE_TYPE; -import static org.sakaiproject.assignment.api.model.Assignment.GradeType.PASS_FAIL_GRADE_TYPE; -import static org.sakaiproject.assignment.api.model.Assignment.GradeType.SCORE_GRADE_TYPE; -import static org.sakaiproject.assignment.api.model.Assignment.GradeType.UNGRADED_GRADE_TYPE; -import static org.sakaiproject.assignment.api.model.Assignment.GradeType.values; import org.sakaiproject.util.CalendarUtil; @@ -956,10 +949,6 @@ public class AssignmentAction extends PagedResourceActionII { * The selected view */ private static final String STATE_SELECTED_VIEW = "state_selected_view"; - /** - * The configuration choice of with grading option or not - */ - private static final String WITH_GRADES = "with_grades"; /** * The configuration choice of showing or hiding the number of submissions column */ @@ -1378,9 +1367,6 @@ public String buildMainPanelContext(VelocityPortlet portlet, Context context, Ru context.put("peerAssessmentUse", rb.getFormattedMessage("peerAssessmentUse")); } - // grading option - context.put("withGrade", state.getAttribute(WITH_GRADES)); - // the grade type table context.put("gradeTypeTable", gradeTypeTable()); @@ -3276,7 +3262,7 @@ protected void setAssignmentFormContext(SessionState state, Context context) { anonGrading = (Boolean) state.getAttribute(NEW_ASSIGNMENT_CHECK_ANONYMOUS_GRADING); } - Assignment.GradeType gradeType = values()[(Integer) state.getAttribute(NEW_ASSIGNMENT_GRADE_TYPE)]; + Assignment.GradeType gradeType = Assignment.GradeType.values()[(Integer) state.getAttribute(NEW_ASSIGNMENT_GRADE_TYPE)]; String maxGrade = (String) state.getAttribute(NEW_ASSIGNMENT_GRADE_POINTS); context.put("value_GradeType", gradeType.ordinal()); context.put("value_GradePoints", assignmentService.getGradeDisplay(maxGrade, gradeType, scaleFactor)); @@ -3846,7 +3832,7 @@ private String build_instructor_preview_assignment_context(VelocityPortlet portl context.put("gradeName", getGradeName(a, assignmentId)); context.put("value_CheckAnonymousGrading", assignmentService.assignmentUsesAnonymousGrading(a)); context.put("isDraft", a.getDraft()); - if (a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { String maxGrade = (String) state.getAttribute(NEW_ASSIGNMENT_GRADE_POINTS); context.put("value_GradePoints", displayGrade(state, maxGrade, a.getScaleFactor())); } @@ -3904,7 +3890,7 @@ protected String build_instructor_delete_assignment_context(VelocityPortlet port * build the instructor view to grade an submission */ protected String build_instructor_grade_submission_context(VelocityPortlet portlet, Context context, RunData data, SessionState state) { - Assignment.GradeType gradeType = GRADE_TYPE_NONE; + Assignment.GradeType gradeType = Assignment.GradeType.GRADE_TYPE_NONE; Integer scaleFactor = assignmentService.getScaleFactor(); // need to show the alert for grading drafts? @@ -3952,7 +3938,7 @@ protected String build_instructor_grade_submission_context(VelocityPortlet portl a.getAttachments().forEach(r -> attachmentReferences.put(r, entityManager.newReference(r))); context.put("assignmentAttachmentReferences", attachmentReferences); - if (a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { context.put("value_grade", displayGrade(state, (String) state.getAttribute(GRADE_SUBMISSION_GRADE), scaleFactor)); } } @@ -4774,7 +4760,7 @@ private String build_instructor_preview_grade_submission_context(VelocityPortlet // format to show "factor" decimal places String grade = (String) state.getAttribute(GRADE_SUBMISSION_GRADE); - if (assignment.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (assignment.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { grade = displayGrade(state, grade, assignment.getScaleFactor()); } context.put("grade", grade); @@ -4839,7 +4825,7 @@ private String build_instructor_grade_assignment_context(VelocityPortlet portlet Assignment.GradeType gradeType = assignment.getTypeOfGrade(); context.put("typeOfGrade", gradeType.ordinal()); context.put("typeOfGradeString", getTypeOfGradeString(gradeType)); - if (gradeType.equals(SCORE_GRADE_TYPE)) { + if (gradeType.equals(Assignment.GradeType.SCORE_GRADE_TYPE)) { Integer scaleFactor = assignment.getScaleFactor() != null ? assignment.getScaleFactor() : assignmentService.getScaleFactor(); context.put("maxGradePointString", assignmentService.getMaxPointGradeDisplay(scaleFactor, assignment.getMaxGradePoint())); } @@ -5178,7 +5164,7 @@ private String build_instructor_view_assignment_context(VelocityPortlet portlet, putCreatorIntoContext(context, assignment); context.put("typeOfGradeString", getTypeOfGradeString(assignment.getTypeOfGrade())); - if (assignment.getTypeOfGrade().equals(SCORE_GRADE_TYPE)) { + if (assignment.getTypeOfGrade().equals(Assignment.GradeType.SCORE_GRADE_TYPE)) { Integer scaleFactor = assignment.getScaleFactor() != null ? assignment.getScaleFactor() : assignmentService.getScaleFactor(); context.put("maxGradePointString", assignmentService.getMaxPointGradeDisplay(scaleFactor, assignment.getMaxGradePoint())); } @@ -5307,7 +5293,7 @@ private String build_instructor_reorder_assignment_context(VelocityPortlet portl } // build_instructor_reorder_assignment_context private String build_student_review_edit_context(VelocityPortlet portlet, Context context, RunData data, SessionState state) { - Assignment.GradeType gradeType = GRADE_TYPE_NONE; + Assignment.GradeType gradeType = Assignment.GradeType.GRADE_TYPE_NONE; context.put("context", state.getAttribute(STATE_CONTEXT_STRING)); List peerAssessmentItems = (List) state.getAttribute(PEER_ASSESSMENT_ITEMS); String assignmentId = (String) state.getAttribute(VIEW_ASSIGNMENT_ID); @@ -6115,14 +6101,16 @@ public void doView_submission_list_option(RunData data) { ParameterParser params = data.getParameters(); String option = params.getString("option"); - if ("upload".equals(option)) { - // go to upload all page - doPrep_upload_all(data); - } else if ("releaseGrades".equals(option)) { - // release all grades - doRelease_grades(data); + switch (option) { + case "releaseCommented": + case "releaseGrades": + doRelease_grades(data); + break; + case "upload": + doPrep_upload_all(data); + break; + default: } - } // doView_submission_list_option public void doView_submission_list_search(RunData data) @@ -6987,7 +6975,7 @@ private void post_save_submission(RunData data, boolean post) { if (StringUtils.isBlank(previousGrades)) { previousGrades = properties.get(ResourceProperties.PROP_SUBMISSION_PREVIOUS_GRADES); if (StringUtils.isNotBlank(previousGrades)) { - if (a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { // point grade assignment type // some old unscaled grades, need to scale the number and remove the old property String[] grades = StringUtils.split(previousGrades, " "); @@ -7583,21 +7571,17 @@ private void setNewAssignmentParameters(RunData data, boolean validify) { // ------------------- BEGIN GRADING PARAMS ------------------- - Assignment.GradeType gradeType = GRADE_TYPE_NONE; - // grade type and grade points - if (state.getAttribute(WITH_GRADES) != null && (Boolean) state.getAttribute(WITH_GRADES)) { - boolean gradeAssignment = params.getBoolean(NEW_ASSIGNMENT_GRADE_ASSIGNMENT); - state.setAttribute(NEW_ASSIGNMENT_GRADE_ASSIGNMENT, gradeAssignment); - int gType = gradeAssignment ? params.getInt(NEW_ASSIGNMENT_GRADE_TYPE) : UNGRADED_GRADE_TYPE.ordinal(); - gradeType = values()[gType]; - state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE, gradeType.ordinal()); - } + boolean gradeAssignment = params.getBoolean(NEW_ASSIGNMENT_GRADE_ASSIGNMENT); + state.setAttribute(NEW_ASSIGNMENT_GRADE_ASSIGNMENT, gradeAssignment); + int gType = gradeAssignment ? params.getInt(NEW_ASSIGNMENT_GRADE_TYPE) : Assignment.GradeType.UNGRADED_GRADE_TYPE.ordinal(); + Assignment.GradeType gradeType = Assignment.GradeType.values()[gType]; + state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE, gradeType.ordinal()); // check if grade type is switching and prompt for confirmation if graded submissions exist if (StringUtils.isNotBlank(assignmentRef)) { Assignment asn = getAssignment(assignmentRef, "setNewAssignmentParameters", state); - if (asn != null && gradeType != GRADE_TYPE_NONE && asn.getTypeOfGrade() != gradeType) { + if (asn != null && gradeType != Assignment.GradeType.GRADE_TYPE_NONE && asn.getTypeOfGrade() != gradeType) { state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE_SWITCHING, Boolean.TRUE); Set submissions = assignmentService.getSubmissions(asn); if (submissions.stream().anyMatch(s -> s.getGraded())) { @@ -7635,7 +7619,7 @@ private void setNewAssignmentParameters(RunData data, boolean validify) { String associateAssignment = params.getString(PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT); Double droppedCategoryPoints = -1D; - if (grading != null && gradeType != UNGRADED_GRADE_TYPE) { + if (grading != null && gradeType != Assignment.GradeType.UNGRADED_GRADE_TYPE) { if (grading.equals(GRADEBOOK_INTEGRATION_ASSOCIATE)) { state.setAttribute(PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT, associateAssignment); } else { @@ -7644,7 +7628,7 @@ private void setNewAssignmentParameters(RunData data, boolean validify) { if (!grading.equals(GRADEBOOK_INTEGRATION_NO)) { // gradebook integration only available to point-grade assignment - if (gradeType != SCORE_GRADE_TYPE) { + if (gradeType != Assignment.GradeType.SCORE_GRADE_TYPE) { addAlert(state, rb.getString("addtogradebook.wrongGradeScale")); } @@ -7724,7 +7708,7 @@ private void setNewAssignmentParameters(RunData data, boolean validify) { //Peer Assessment boolean peerAssessment = false; - if (gradeType == SCORE_GRADE_TYPE && params.getBoolean(NEW_ASSIGNMENT_USE_PEER_ASSESSMENT)) { + if (gradeType == Assignment.GradeType.SCORE_GRADE_TYPE && params.getBoolean(NEW_ASSIGNMENT_USE_PEER_ASSESSMENT)) { state.setAttribute(NEW_ASSIGNMENT_USE_PEER_ASSESSMENT, Boolean.TRUE.toString()); peerAssessment = true; } else { @@ -8028,11 +8012,11 @@ private void setNewAssignmentParameters(RunData data, boolean validify) { String option = params.get("option"); - if (!"attach".equals(option) && state.getAttribute(WITH_GRADES) != null && (Boolean) state.getAttribute(WITH_GRADES)) { + if (!"attach".equals(option)) { // the grade point String gradePoints = params.getString(NEW_ASSIGNMENT_GRADE_POINTS); state.setAttribute(NEW_ASSIGNMENT_GRADE_POINTS, gradePoints); - if (gradePoints != null && gradeType == SCORE_GRADE_TYPE) { + if (gradePoints != null && gradeType == Assignment.GradeType.SCORE_GRADE_TYPE) { if (gradePoints.length() == 0) { // in case of point grade assignment, user must specify maximum grade point addAlert(state, rb.getString("plespethe3")); @@ -8604,7 +8588,7 @@ private void post_save_assignment(RunData data, String postOrSave) { Assignment.SubmissionType submissionType = Assignment.SubmissionType.values()[(Integer) state.getAttribute(NEW_ASSIGNMENT_SUBMISSION_TYPE)]; - Assignment.GradeType gradeType = values()[(Integer) state.getAttribute(NEW_ASSIGNMENT_GRADE_TYPE)]; + Assignment.GradeType gradeType = Assignment.GradeType.values()[(Integer) state.getAttribute(NEW_ASSIGNMENT_GRADE_TYPE)]; String gradePoints = (String) state.getAttribute(NEW_ASSIGNMENT_GRADE_POINTS); @@ -9225,7 +9209,7 @@ private void initIntegrateWithGradebook(SessionState state, String siteId, Strin addUpdateRemoveAssignment = "update"; } - if (!"remove".equals(addUpdateRemoveAssignment) && gradeType == SCORE_GRADE_TYPE) { + if (!"remove".equals(addUpdateRemoveAssignment) && gradeType == Assignment.GradeType.SCORE_GRADE_TYPE) { try { addAlerts(state, assignmentToolUtils.integrateGradebook(stateToMap(state), assignmentReference, associateGradebookAssignment, addUpdateRemoveAssignment, aOldTitle, title, Integer.parseInt(gradePoints), dueTime, null, null, category)); @@ -9725,7 +9709,7 @@ private void commitAssignment(SessionState state, // post the assignment if appropriate a.setDraft(!post); - if (gradeType == SCORE_GRADE_TYPE) { + if (gradeType == Assignment.GradeType.SCORE_GRADE_TYPE) { if (a.getScaleFactor() == null) { // only set the default scale factor if the assignment does not have one a.setScaleFactor(assignmentService.getScaleFactor()); @@ -10219,7 +10203,7 @@ public void doEdit_assignment(RunData data) { state.setAttribute(NEW_ASSIGNMENT_SUBMISSION_TYPE, a.getTypeOfSubmission().ordinal()); state.setAttribute(NEW_ASSIGNMENT_CATEGORY, 0); state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE, a.getTypeOfGrade().ordinal()); - if (a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { state.setAttribute(NEW_ASSIGNMENT_GRADE_POINTS, a.getMaxGradePoint().toString()); } state.setAttribute(NEW_ASSIGNMENT_DESCRIPTION, a.getInstructions()); @@ -10875,18 +10859,12 @@ public void doRelease_grades(RunData data) { for (AssignmentSubmission s : submissions) { String grade = s.getGrade(); if (s.getGraded() || StringUtils.isNotBlank(grade)) { - boolean withGrade = state.getAttribute(WITH_GRADES) != null ? (Boolean) state.getAttribute(WITH_GRADES) : false; - if (withGrade) { - // for the assignment tool with grade option, a valide grade is needed - if (StringUtils.isNotBlank(grade)) { - s.setGradeReleased(true); - if (!s.getGraded()) { - s.setGraded(true); - } - } - } else { - // for the assignment tool without grade option, no grade is needed + // for the assignment tool with grade option, a valide grade is needed + if (StringUtils.isNotBlank(grade)) { s.setGradeReleased(true); + if (!s.getGraded()) { + s.setGraded(true); + } } // also set the return status @@ -11740,7 +11718,6 @@ public boolean readGradeForm(RunData data, SessionState state, String gradeOptio // security check for allowing grading submission or not if (assignmentService.allowGradeSubmission(sId)) { - boolean withGrade = state.getAttribute(WITH_GRADES) != null ? (Boolean) state.getAttribute(WITH_GRADES) : false; String feedbackComment = processFormattedTextFromBrowser(state, params.getCleanString(GRADE_SUBMISSION_FEEDBACK_COMMENT), true); // comment value changed? @@ -11782,120 +11759,117 @@ public boolean readGradeForm(RunData data, SessionState state, String gradeOptio int factor = a.getScaleFactor() != null ? a.getScaleFactor() : assignmentService.getScaleFactor(); Assignment.GradeType typeOfGrade = a.getTypeOfGrade(); - if (withGrade) { - // any change in grade. Do not check for ungraded assignment type - if (!hasChange && typeOfGrade != UNGRADED_GRADE_TYPE) { - if (typeOfGrade == SCORE_GRADE_TYPE) { - String currentGrade = submission.getGrade(); + // any change in grade. Do not check for ungraded assignment type + if (!hasChange && typeOfGrade != Assignment.GradeType.UNGRADED_GRADE_TYPE) { + if (typeOfGrade == Assignment.GradeType.SCORE_GRADE_TYPE) { + String currentGrade = submission.getGrade(); - String decSeparator = formattedText.getDecimalSeparator(); + String decSeparator = formattedText.getDecimalSeparator(); - if (currentGrade != null && currentGrade.contains(decSeparator)) { - currentGrade = scalePointGrade(state, submission.getGrade(), factor); - } - hasChange = valueDiffFromStateAttribute(state, scalePointGrade(state, g, factor), currentGrade); - } else { - hasChange = valueDiffFromStateAttribute(state, g, submission.getGrade()); + if (currentGrade != null && currentGrade.contains(decSeparator)) { + currentGrade = scalePointGrade(state, submission.getGrade(), factor); } - } - if (g != null) { - state.setAttribute(GRADE_SUBMISSION_GRADE, g); + hasChange = valueDiffFromStateAttribute(state, scalePointGrade(state, g, factor), currentGrade); } else { - state.removeAttribute(GRADE_SUBMISSION_GRADE); + hasChange = valueDiffFromStateAttribute(state, g, submission.getGrade()); } + } + if (g != null) { + state.setAttribute(GRADE_SUBMISSION_GRADE, g); + } else { + state.removeAttribute(GRADE_SUBMISSION_GRADE); + } - // for points grading, one have to enter number as the points - String grade = (String) state.getAttribute(GRADE_SUBMISSION_GRADE); - - // do grade validation only for Assignment with Grade tool - if (typeOfGrade == SCORE_GRADE_TYPE) { - if ((grade != null)) { - // the preview grade process might already scaled up the grade by "factor" - if (!((String) state.getAttribute(STATE_MODE)).equals(MODE_INSTRUCTOR_PREVIEW_GRADE_SUBMISSION)) { - if (state.getAttribute(STATE_MESSAGE) == null) { - validPointGrade(state, grade, factor); - int maxGrade = a.getMaxGradePoint(); - try { - if (state.getAttribute(STATE_MESSAGE) == null && Integer.parseInt(scalePointGrade(state, grade, factor)) > maxGrade) { - if (state.getAttribute(GRADE_GREATER_THAN_MAX_ALERT) == null) { - // alert user first when he enters grade bigger than max scale - addAlert(state, rb.getFormattedMessage("grad2", grade, displayGrade(state, String.valueOf(maxGrade), factor))); - state.setAttribute(GRADE_GREATER_THAN_MAX_ALERT, Boolean.TRUE); - } else { - // remove the alert once user confirms he wants to give student higher grade - state.removeAttribute(GRADE_GREATER_THAN_MAX_ALERT); - } + // for points grading, one have to enter number as the points + String grade = (String) state.getAttribute(GRADE_SUBMISSION_GRADE); + + // do grade validation only for Assignment with Grade tool + if (typeOfGrade == Assignment.GradeType.SCORE_GRADE_TYPE) { + if ((grade != null)) { + // the preview grade process might already scaled up the grade by "factor" + if (!((String) state.getAttribute(STATE_MODE)).equals(MODE_INSTRUCTOR_PREVIEW_GRADE_SUBMISSION)) { + if (state.getAttribute(STATE_MESSAGE) == null) { + validPointGrade(state, grade, factor); + int maxGrade = a.getMaxGradePoint(); + try { + if (state.getAttribute(STATE_MESSAGE) == null && Integer.parseInt(scalePointGrade(state, grade, factor)) > maxGrade) { + if (state.getAttribute(GRADE_GREATER_THAN_MAX_ALERT) == null) { + // alert user first when he enters grade bigger than max scale + addAlert(state, rb.getFormattedMessage("grad2", grade, displayGrade(state, String.valueOf(maxGrade), factor))); + state.setAttribute(GRADE_GREATER_THAN_MAX_ALERT, Boolean.TRUE); + } else { + // remove the alert once user confirms he wants to give student higher grade + state.removeAttribute(GRADE_GREATER_THAN_MAX_ALERT); } - } catch (NumberFormatException e) { - alertInvalidPoint(state, grade, factor); - log.warn(this + ":readGradeForm " + e.getMessage()); } + } catch (NumberFormatException e) { + alertInvalidPoint(state, grade, factor); + log.warn(this + ":readGradeForm " + e.getMessage()); } - - state.setAttribute(GRADE_SUBMISSION_GRADE, grade); } + + state.setAttribute(GRADE_SUBMISSION_GRADE, grade); } } + } - // if ungraded and grade type is not "ungraded" type - if ((grade == null || UNGRADED_GRADE_STRING.equals(grade)) && (typeOfGrade != UNGRADED_GRADE_TYPE) && "release".equals(gradeOption)) { - addAlert(state, rb.getString("plespethe2")); - } + // if ungraded and grade type is not "ungraded" type + if ((grade == null || UNGRADED_GRADE_STRING.equals(grade)) && (typeOfGrade != Assignment.GradeType.UNGRADED_GRADE_TYPE) && "release".equals(gradeOption)) { + addAlert(state, rb.getString("plespethe2")); + } - // check for grade overrides - if (a.getIsGroup()) { - HashMap scaledValues = new HashMap(); - Set submitters = submission.getSubmitters(); - for (AssignmentSubmissionSubmitter submitter : submitters) { - String ug = StringUtils.trimToNull(params.getCleanString(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter())); - if ("null".equals(ug)) ug = null; - if (!hasChange && typeOfGrade != UNGRADED_GRADE_TYPE) { - hasChange = valueDiffFromStateAttribute(state, ug, submitter.getGrade()); - } - if (ug == null) { - state.removeAttribute(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter()); - } else { - state.setAttribute(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter(), ug); - } - // for points grading, one have to enter number as the points - String ugrade = (String) state.getAttribute(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter()); - // do grade validation only for Assignment with Grade tool - if (typeOfGrade == SCORE_GRADE_TYPE) { - if (ugrade != null && !(ugrade.equals("null"))) { - // the preview grade process might already scaled up the grade by "factor" - if (!((String) state.getAttribute(STATE_MODE)).equals(MODE_INSTRUCTOR_PREVIEW_GRADE_SUBMISSION)) { - validPointGrade(state, ugrade, factor); - if (state.getAttribute(STATE_MESSAGE) == null) { - int maxGrade = a.getMaxGradePoint(); - try { - if (Integer.parseInt(scalePointGrade(state, ugrade, factor)) > maxGrade) { - if (state.getAttribute(GRADE_GREATER_THAN_MAX_ALERT) == null) { - // alert user first when he enters grade bigger than max scale - addAlert(state, rb.getFormattedMessage("grad2", ugrade, displayGrade(state, String.valueOf(maxGrade), factor))); - state.setAttribute(GRADE_GREATER_THAN_MAX_ALERT, Boolean.TRUE); - } else { - // remove the alert once user confirms he wants to give student higher grade - state.removeAttribute(GRADE_GREATER_THAN_MAX_ALERT); - } + // check for grade overrides + if (a.getIsGroup()) { + HashMap scaledValues = new HashMap(); + Set submitters = submission.getSubmitters(); + for (AssignmentSubmissionSubmitter submitter : submitters) { + String ug = StringUtils.trimToNull(params.getCleanString(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter())); + if ("null".equals(ug)) ug = null; + if (!hasChange && typeOfGrade != Assignment.GradeType.UNGRADED_GRADE_TYPE) { + hasChange = valueDiffFromStateAttribute(state, ug, submitter.getGrade()); + } + if (ug == null) { + state.removeAttribute(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter()); + } else { + state.setAttribute(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter(), ug); + } + // for points grading, one have to enter number as the points + String ugrade = (String) state.getAttribute(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter()); + // do grade validation only for Assignment with Grade tool + if (typeOfGrade == Assignment.GradeType.SCORE_GRADE_TYPE) { + if (ugrade != null && !(ugrade.equals("null"))) { + // the preview grade process might already scaled up the grade by "factor" + if (!((String) state.getAttribute(STATE_MODE)).equals(MODE_INSTRUCTOR_PREVIEW_GRADE_SUBMISSION)) { + validPointGrade(state, ugrade, factor); + if (state.getAttribute(STATE_MESSAGE) == null) { + int maxGrade = a.getMaxGradePoint(); + try { + if (Integer.parseInt(scalePointGrade(state, ugrade, factor)) > maxGrade) { + if (state.getAttribute(GRADE_GREATER_THAN_MAX_ALERT) == null) { + // alert user first when he enters grade bigger than max scale + addAlert(state, rb.getFormattedMessage("grad2", ugrade, displayGrade(state, String.valueOf(maxGrade), factor))); + state.setAttribute(GRADE_GREATER_THAN_MAX_ALERT, Boolean.TRUE); + } else { + // remove the alert once user confirms he wants to give student higher grade + state.removeAttribute(GRADE_GREATER_THAN_MAX_ALERT); } - } catch (NumberFormatException e) { - alertInvalidPoint(state, ugrade, factor); - log.warn(this + ":readGradeForm User " + e.getMessage()); } + } catch (NumberFormatException e) { + alertInvalidPoint(state, ugrade, factor); + log.warn(this + ":readGradeForm User " + e.getMessage()); } - scaledValues.put(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter(), scalePointGrade(state, ugrade, factor)); } + scaledValues.put(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter(), scalePointGrade(state, ugrade, factor)); } } } - // SAK-28182 If all grades are right place scaled values in state - if (state.getAttribute(STATE_MESSAGE) == null) { - for (Map.Entry entry : scaledValues.entrySet()) { - state.setAttribute(entry.getKey(), entry.getValue()); - } + } + // SAK-28182 If all grades are right place scaled values in state + if (state.getAttribute(STATE_MESSAGE) == null) { + for (Map.Entry entry : scaledValues.entrySet()) { + state.setAttribute(entry.getKey(), entry.getValue()); } } - } // allow resubmit number and due time @@ -11922,8 +11896,7 @@ public boolean readGradeForm(RunData data, SessionState state, String gradeOptio hasChange = hasChange || change_resubmit_option(state, submission.getProperties()); hasChange = hasChange || propertyValueChanged(state, submission.getProperties(), AssignmentConstants.ALLOW_EXTENSION_CLOSETIME); //same for Extension. if (state.getAttribute(STATE_MESSAGE) == null) { - String grade = (String) state.getAttribute(GRADE_SUBMISSION_GRADE); - grade = (typeOfGrade == SCORE_GRADE_TYPE) ? scalePointGrade(state, grade, factor) : grade; + grade = (typeOfGrade == Assignment.GradeType.SCORE_GRADE_TYPE) ? scalePointGrade(state, grade, factor) : grade; state.setAttribute(GRADE_SUBMISSION_GRADE, grade); } } @@ -12229,15 +12202,6 @@ protected void initState(SessionState state, VelocityPortlet portlet, JetspeedRu state.setAttribute(STATE_TOP_PAGE_MESSAGE, 0); } - if (state.getAttribute(WITH_GRADES) == null) { - PortletConfig config = portlet.getPortletConfig(); - String withGrades = StringUtils.trimToNull(config.getInitParameter("withGrades")); - if (withGrades == null) { - withGrades = Boolean.FALSE.toString(); - } - state.setAttribute(WITH_GRADES, Boolean.valueOf(withGrades)); - } - // whether to display the number of submission/ungraded submission column // default to show if (state.getAttribute(SHOW_NUMBER_SUBMISSION_COLUMN) == null) { @@ -12418,8 +12382,7 @@ private void initializeAssignment(SessionState state) { state.setAttribute(NEW_ASSIGNMENT_SUBMISSION_TYPE, Assignment.SubmissionType.TEXT_AND_ATTACHMENT_ASSIGNMENT_SUBMISSION.ordinal()); Boolean withGradesConfig = serverConfigurationService.getBoolean("assignment.grade.default", Boolean.TRUE); if (withGradesConfig) { - state.setAttribute(WITH_GRADES, Boolean.TRUE); - state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE, SCORE_GRADE_TYPE.ordinal()); + state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE, Assignment.GradeType.SCORE_GRADE_TYPE.ordinal()); String defaultPointsConfig = serverConfigurationService.getString("assignment.points.default", ""); if (NumberUtils.isParsable(defaultPointsConfig)) { float defaultPoints = NumberUtils.createFloat(defaultPointsConfig); @@ -12428,7 +12391,7 @@ private void initializeAssignment(SessionState state) { state.setAttribute(NEW_ASSIGNMENT_GRADE_POINTS, ""); } } else { - state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE, UNGRADED_GRADE_TYPE.ordinal()); + state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE, Assignment.GradeType.UNGRADED_GRADE_TYPE.ordinal()); state.setAttribute(NEW_ASSIGNMENT_GRADE_POINTS, ""); } state.setAttribute(NEW_ASSIGNMENT_CONTENT_ID, null); @@ -13555,7 +13518,7 @@ public void doSet_defaultNotGradedNonElectronicScore(RunData data) { String assignmentId = (String) state.getAttribute(EXPORT_ASSIGNMENT_REF); Assignment a = getAssignment(assignmentId, "doSet_defaultNotGradedNonElectronicScore", state); if (a != null) { - if (a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { //for point-based grades if (a.getScaleFactor() == null) a.setScaleFactor(assignmentService.getScaleFactor()); validPointGrade(state, grade, a.getScaleFactor()); @@ -13594,7 +13557,7 @@ public void doSet_defaultNotGradedNonElectronicScore(RunData data) { if (grade != null && state.getAttribute(STATE_MESSAGE) == null) { - if (a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { grade = scalePointGrade(state, grade, a.getScaleFactor()); } @@ -13641,7 +13604,7 @@ public void doSet_defaultNoSubmissionScore(RunData data) { String assignmentId = (String) state.getAttribute(EXPORT_ASSIGNMENT_REF); Assignment a = getAssignment(assignmentId, "doSet_defaultNoSubmissionScore", state); if (a != null) { - if (a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { //for point-based grades if (a.getScaleFactor() == null) a.setScaleFactor(assignmentService.getScaleFactor()); validPointGrade(state, grade, a.getScaleFactor()); @@ -13679,7 +13642,7 @@ public void doSet_defaultNoSubmissionScore(RunData data) { if (grade != null && state.getAttribute(STATE_MESSAGE) == null) { - if (a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { grade = scalePointGrade(state, grade, a.getScaleFactor()); } @@ -13952,16 +13915,16 @@ private Map uploadAll_parseZipFile(SessionState stat if (w != null) { String itemString = assignment.getIsGroup() ? items[3] : items[4]; Assignment.GradeType gradeType = assignment.getTypeOfGrade(); - if (gradeType == SCORE_GRADE_TYPE) { + if (gradeType == Assignment.GradeType.SCORE_GRADE_TYPE) { validPointGrade(state, itemString, assignment.getScaleFactor()); } // SAK-24199 - Applied patch provided with a few additional modifications. - else if (gradeType == PASS_FAIL_GRADE_TYPE) { + else if (gradeType == Assignment.GradeType.PASS_FAIL_GRADE_TYPE) { itemString = validatePassFailGradeValue(state, itemString); } else { validLetterGrade(state, itemString); } if (state.getAttribute(STATE_MESSAGE) == null) { - w.setGrade(gradeType == SCORE_GRADE_TYPE ? scalePointGrade(state, itemString, assignment.getScaleFactor()) : itemString); + w.setGrade(gradeType == Assignment.GradeType.SCORE_GRADE_TYPE ? scalePointGrade(state, itemString, assignment.getScaleFactor()) : itemString); submissionTable.put(eid, w); } } @@ -14008,7 +13971,7 @@ else if (gradeType == PASS_FAIL_GRADE_TYPE) { if (w != null) { itemString = assignment.getIsGroup() ? hssfRow.getCell(3).toString() : hssfRow.getCell(4).toString(); Assignment.GradeType gradeType = assignment.getTypeOfGrade(); - if (gradeType == SCORE_GRADE_TYPE) { + if (gradeType == Assignment.GradeType.SCORE_GRADE_TYPE) { //Parse the string to double using the locale format try { itemString = assignment.getIsGroup() ? hssfRow.getCell(3).getStringCellValue() : hssfRow.getCell(4).getStringCellValue(); @@ -14032,13 +13995,13 @@ else if (gradeType == PASS_FAIL_GRADE_TYPE) { } validPointGrade(state, itemString, assignment.getScaleFactor()); - } else if (gradeType == PASS_FAIL_GRADE_TYPE) { + } else if (gradeType == Assignment.GradeType.PASS_FAIL_GRADE_TYPE) { itemString = validatePassFailGradeValue(state, itemString); } else { validLetterGrade(state, itemString); } if (state.getAttribute(STATE_MESSAGE) == null) { - w.setGrade(gradeType == SCORE_GRADE_TYPE ? scalePointGrade(state, itemString, assignment.getScaleFactor()) : itemString); + w.setGrade(gradeType == Assignment.GradeType.SCORE_GRADE_TYPE ? scalePointGrade(state, itemString, assignment.getScaleFactor()) : itemString); submissionTable.put(eid, w); } } @@ -14355,12 +14318,17 @@ private void uploadAll_updateSubmissions(SessionState state, } // the feedback comment - if (hasComment) { + if (hasComment && StringUtils.isNotBlank(w.getComment())) { submission.setFeedbackComment(w.getComment()); + // ungraded assignments are considered graded when a comment is entered + if (assignment.getTypeOfGrade() == Assignment.GradeType.UNGRADED_GRADE_TYPE) { + submission.setGrade(null); + submission.setGraded(true); + } } // the grade file - if (hasGradeFile) { + if (hasGradeFile && assignment.getTypeOfGrade() != Assignment.GradeType.UNGRADED_GRADE_TYPE) { // set grade String grade = StringUtils.trimToNull(w.getGrade()); submission.setGrade(grade); @@ -14370,8 +14338,8 @@ private void uploadAll_updateSubmissions(SessionState state, } } - // release or not - If it's graded or if there were feedback comments provided - if (submission.getGraded() || (submission.getFeedbackComment() != null && !"".equals(submission.getFeedbackComment()))) { + // release or not depending on if it's graded + if (submission.getGraded()) { submission.setGradeReleased(releaseGrades); submission.setReturned(releaseGrades); } else { @@ -14885,6 +14853,10 @@ public void doSave_send_feedback(RunData data) { newFeedbackComment = ( submission.getFeedbackComment() == null ? "" : submission.getFeedbackComment() ) + comment + "
"; } submission.setFeedbackComment(newFeedbackComment); + if (assignment.getTypeOfGrade() == Assignment.GradeType.UNGRADED_GRADE_TYPE) { + submission.setGrade(null); + submission.setGraded(true); + } if (returnToStudents != null) { submission.setReturned(true); submission.setDateReturned(Instant.now()); @@ -15359,7 +15331,7 @@ private String getAssignmentStatus(String assignmentId, SessionState state) { */ protected void setScoringAgentProperties(Context context, Assignment assignment, AssignmentSubmission submission, boolean gradeView) { String associatedGbItem = assignment.getProperties().get(PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT); - if (!assignment.getIsGroup() && submission != null && StringUtils.isNotBlank(associatedGbItem) && assignment.getTypeOfGrade() == SCORE_GRADE_TYPE) { + if (!assignment.getIsGroup() && submission != null && StringUtils.isNotBlank(associatedGbItem) && assignment.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { ScoringService scoringService = (ScoringService) ComponentManager.get("org.sakaiproject.scoringservice.api.ScoringService"); ScoringAgent scoringAgent = scoringService.getDefaultScoringAgent(); @@ -15965,8 +15937,8 @@ else if (m_criteria.equals(SORTED_GRADE_SUBMISSION_CONTENTREVIEW)) { } // if scale is points - if ((s1.getAssignment().getTypeOfGrade() == SCORE_GRADE_TYPE) - && ((s2.getAssignment().getTypeOfGrade() == SCORE_GRADE_TYPE))) { + if ((s1.getAssignment().getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) + && ((s2.getAssignment().getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE))) { if ("".equals(grade1)) { result = -1; } else if ("".equals(grade2)) { @@ -16070,8 +16042,8 @@ else if (m_criteria.equals(SORTED_SUBMISSION_BY_LASTNAME)) { } // if scale is points - if ((((AssignmentSubmission) o1).getAssignment().getTypeOfGrade() == SCORE_GRADE_TYPE) - && ((((AssignmentSubmission) o2).getAssignment().getTypeOfGrade() == SCORE_GRADE_TYPE))) { + if ((((AssignmentSubmission) o1).getAssignment().getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) + && ((((AssignmentSubmission) o2).getAssignment().getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE))) { if ("".equals(grade1)) { result = -1; } else if ("".equals(grade2)) { @@ -16094,8 +16066,8 @@ else if (m_criteria.equals(SORTED_SUBMISSION_BY_LASTNAME)) { } // if scale is points - if ((((AssignmentSubmission) o1).getAssignment().getTypeOfGrade() == SCORE_GRADE_TYPE) - && ((((AssignmentSubmission) o2).getAssignment().getTypeOfGrade() == SCORE_GRADE_TYPE))) { + if ((((AssignmentSubmission) o1).getAssignment().getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) + && ((((AssignmentSubmission) o2).getAssignment().getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE))) { if ("".equals(grade1)) { result = -1; } else if ("".equals(grade2)) { @@ -16276,22 +16248,22 @@ private int compareInstant(Instant t1, Instant t2) { private String maxGrade(Assignment.GradeType gradeType, Assignment a) { String maxGrade = ""; - if (gradeType == GRADE_TYPE_NONE) { + if (gradeType == Assignment.GradeType.GRADE_TYPE_NONE) { // Grade type not set maxGrade = rb.getString("granotset"); - } else if (gradeType == UNGRADED_GRADE_TYPE) { + } else if (gradeType == Assignment.GradeType.UNGRADED_GRADE_TYPE) { // Ungraded grade type maxGrade = rb.getString("gen.nograd"); - } else if (gradeType == LETTER_GRADE_TYPE) { + } else if (gradeType == Assignment.GradeType.LETTER_GRADE_TYPE) { // Letter grade type maxGrade = "A"; - } else if (gradeType == SCORE_GRADE_TYPE) { + } else if (gradeType == Assignment.GradeType.SCORE_GRADE_TYPE) { // Score based grade type maxGrade = Integer.toString(a.getMaxGradePoint()); - } else if (gradeType == PASS_FAIL_GRADE_TYPE) { + } else if (gradeType == Assignment.GradeType.PASS_FAIL_GRADE_TYPE) { // Pass/fail grade type maxGrade = rb.getString("pass"); - } else if (gradeType == CHECK_GRADE_TYPE) { + } else if (gradeType == Assignment.GradeType.CHECK_GRADE_TYPE) { // Grade type that only requires a check maxGrade = rb.getString("check"); } diff --git a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentToolUtils.java b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentToolUtils.java index b20864511391..63947a960cc7 100644 --- a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentToolUtils.java +++ b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentToolUtils.java @@ -16,7 +16,6 @@ package org.sakaiproject.assignment.tool; import static org.sakaiproject.assignment.api.AssignmentConstants.*; -import static org.sakaiproject.assignment.api.model.Assignment.GradeType.*; import java.text.DecimalFormat; import java.text.NumberFormat; @@ -38,6 +37,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.sakaiproject.assignment.api.AssignmentReferenceReckoner; import org.sakaiproject.assignment.api.AssignmentService; @@ -275,32 +275,46 @@ public List alertInvalidPoint(String grade, int factor) { public void gradeSubmission(AssignmentSubmission submission, String gradeOption, Map options, List alerts) { if (submission != null) { - boolean withGrade = options.get(WITH_GRADES) != null && (Boolean) options.get(WITH_GRADES); - String grade = (String) options.get(GRADE_SUBMISSION_GRADE); - boolean gradeChanged = false; - if (!StringUtils.equals(StringUtils.trimToNull(submission.getGrade()), StringUtils.trimToNull(grade))) { - //one is null the other isn't - gradeChanged = true; - } Assignment a = submission.getAssignment(); - if (!withGrade) { - // no grade input needed for the without-grade version of assignment tool - submission.setGraded(true); - if (gradeChanged) { - submission.setGradedBy(userDirectoryService.getCurrentUser() == null ? null : userDirectoryService.getCurrentUser().getId()); + String grade = (String) options.get(GRADE_SUBMISSION_GRADE); + + boolean gradeChanged = !StringUtils.equals(StringUtils.trimToNull(submission.getGrade()), StringUtils.trimToNull(grade)); + + // the instructor feedback comment + String submittedfeedbackComment = StringUtils.trimToNull((String) options.get(GRADE_SUBMISSION_FEEDBACK_COMMENT)); + submission.setFeedbackComment(submittedfeedbackComment); + + // the instructor inline feedback + submission.setFeedbackText(StringUtils.trimToNull((String) options.get(GRADE_SUBMISSION_FEEDBACK_TEXT))); + + List submittedfeedbackAttachments = (List) options.get(GRADE_SUBMISSION_FEEDBACK_ATTACHMENT); + if (submittedfeedbackAttachments != null) { + // clear the old attachments first + Set feedbackAttachments = submission.getFeedbackAttachments(); + if (BooleanUtils.isFalse((Boolean) options.get(GRADE_SUBMISSION_DONT_CLEAR_CURRENT_ATTACHMENTS))) { + feedbackAttachments.clear(); } - if (SUBMISSION_OPTION_RETURN.equals(gradeOption) || SUBMISSION_OPTION_RELEASE.equals(gradeOption)) { - submission.setGradeReleased(true); + for (Reference attachment : submittedfeedbackAttachments) { + feedbackAttachments.add(attachment.getReference()); } + } + + submission.setPrivateNotes(StringUtils.trimToNull((String) options.get(GRADE_SUBMISSION_PRIVATE_NOTES))); + + // determine if the submission is graded + if (a.getTypeOfGrade().equals(Assignment.GradeType.UNGRADED_GRADE_TYPE)) { + submission.setGrade(null); + submission.setGraded(submittedfeedbackComment != null); } else { - //If the grade is not blank if (StringUtils.isNotBlank(grade)) { - submission.setGrade(grade); + // if there is a grade then the submission is graded submission.setGraded(true); + submission.setGrade(grade); if (gradeChanged) { submission.setGradedBy(userDirectoryService.getCurrentUser() == null ? null : userDirectoryService.getCurrentUser().getId()); } } else { + // if no grade or feedback left then it is not graded submission.setGrade(null); submission.setGraded(false); if (gradeChanged) { @@ -309,29 +323,22 @@ public void gradeSubmission(AssignmentSubmission submission, String gradeOption, } } - // iterate through submitters and look for grade overrides... - if (withGrade && a.getIsGroup()) { + if (a.getIsGroup()) { + // group project only set a grade override for submitters for (AssignmentSubmissionSubmitter submitter : submission.getSubmitters()) { - String g = (String) options.get(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter()); - if (g != submitter.getGrade()) submitter.setGrade(g); + String submitterGradeOverride = StringUtils.trimToNull((String) options.get(GRADE_SUBMISSION_GRADE + "_" + submitter.getSubmitter())); + if (!StringUtils.equals(submitterGradeOverride, submitter.getGrade())) { + submitter.setGrade(submitterGradeOverride); + } } } if (SUBMISSION_OPTION_RELEASE.equals(gradeOption)) { submission.setGradeReleased(true); - submission.setGraded(true); - if (gradeChanged) { - submission.setGradedBy(userDirectoryService.getCurrentUser() == null ? null : userDirectoryService.getCurrentUser().getId()); - } - // clear the returned flag submission.setReturned(false); submission.setDateReturned(null); } else if (SUBMISSION_OPTION_RETURN.equals(gradeOption)) { submission.setGradeReleased(true); - submission.setGraded(true); - if (gradeChanged) { - submission.setGradedBy(userDirectoryService.getCurrentUser() == null ? null : userDirectoryService.getCurrentUser().getId()); - } submission.setReturned(true); submission.setDateReturned(Instant.now()); } else if (SUBMISSION_OPTION_RETRACT.equals(gradeOption)) { @@ -369,41 +376,6 @@ public void gradeSubmission(AssignmentSubmission submission, String gradeOption, properties.remove(ALLOW_EXTENSION_CLOSETIME); } - // the instructor comment - String feedbackCommentString = StringUtils.trimToNull((String) options.get(GRADE_SUBMISSION_FEEDBACK_COMMENT)); - if (feedbackCommentString != null) { - submission.setFeedbackComment(feedbackCommentString); - } else { - submission.setFeedbackComment(""); - } - - // the instructor inline feedback - String feedbackTextString = (String) options.get(GRADE_SUBMISSION_FEEDBACK_TEXT); - if (feedbackTextString != null) { - submission.setFeedbackText(feedbackTextString); - } - - List v = (List) options.get(GRADE_SUBMISSION_FEEDBACK_ATTACHMENT); - if (v != null) { - - // clear the old attachments first - Set feedbackAttachments = submission.getFeedbackAttachments(); - - boolean clear = !(options.get(GRADE_SUBMISSION_DONT_CLEAR_CURRENT_ATTACHMENTS) != null - && (Boolean) options.get(GRADE_SUBMISSION_DONT_CLEAR_CURRENT_ATTACHMENTS)); - if (clear) { - feedbackAttachments.clear(); - } - - for (Reference aV : v) { - feedbackAttachments.add(aV.getReference()); - } - } - - if (options.get(GRADE_SUBMISSION_PRIVATE_NOTES) != null) { - submission.setPrivateNotes((String) options.get(GRADE_SUBMISSION_PRIVATE_NOTES)); - } - String sReference = AssignmentReferenceReckoner.reckoner().submission(submission).reckon().getReference(); // save a timestamp for this grading process @@ -545,7 +517,7 @@ else if ("remove".equals(addUpdateRemoveAssignment)) { if ("update".equals(updateRemoveSubmission) && (StringUtils.equals(propAddToGradebook, GRADEBOOK_INTEGRATION_ADD) || StringUtils.equals(propAddToGradebook, GRADEBOOK_INTEGRATION_ASSOCIATE)) - && a.getTypeOfGrade() == SCORE_GRADE_TYPE) { + && a.getTypeOfGrade() == Assignment.GradeType.SCORE_GRADE_TYPE) { if (submissionRef == null) { //Assignment scores map @@ -799,7 +771,7 @@ public boolean isDraftSubmission(AssignmentSubmission s) { } private String displayGrade(String grade, Integer factor) { - return assignmentService.getGradeDisplay(grade, SCORE_GRADE_TYPE, factor); + return assignmentService.getGradeDisplay(grade, Assignment.GradeType.SCORE_GRADE_TYPE, factor); } private void removeNonAssociatedExternalGradebookEntry(String context, String assignmentReference, String associateGradebookAssignment, String gradebookUid) { diff --git a/assignment/tool/src/webapp/WEB-INF/tools/sakai.assignment.grades.xml b/assignment/tool/src/webapp/WEB-INF/tools/sakai.assignment.grades.xml index baf820a107ac..168a7097f945 100644 --- a/assignment/tool/src/webapp/WEB-INF/tools/sakai.assignment.grades.xml +++ b/assignment/tool/src/webapp/WEB-INF/tools/sakai.assignment.grades.xml @@ -12,7 +12,6 @@ - diff --git a/assignment/tool/src/webapp/js/assignments.js b/assignment/tool/src/webapp/js/assignments.js index c34097b3d89d..fc5478365100 100755 --- a/assignment/tool/src/webapp/js/assignments.js +++ b/assignment/tool/src/webapp/js/assignments.js @@ -1078,6 +1078,11 @@ $(document).ready(() => { [...document.getElementsByTagName("sakai-rubric-student-button")].forEach(b => promises.push(b.releaseEvaluation())); Promise.all(promises).then(() => ASN.submitForm('viewForm', 'releaseGrades', null, null)); }); + + const releaseCommented = document.getElementById("releaseCommented"); + releaseCommented && releaseCommented.addEventListener("click", ev => + ASN.submitForm('viewForm', 'releaseCommented', null, null)); + const confirmButton = document.getElementById("confirm"); confirmButton && confirmButton.addEventListener("click", saveRubric); const postButton = document.getElementById("post"); diff --git a/assignment/tool/src/webapp/vm/assignment/assignment_macros.vm b/assignment/tool/src/webapp/vm/assignment/assignment_macros.vm index eb276b9d5786..092b1efac840 100644 --- a/assignment/tool/src/webapp/vm/assignment/assignment_macros.vm +++ b/assignment/tool/src/webapp/vm/assignment/assignment_macros.vm @@ -92,7 +92,7 @@ #end ## Macro for the top nav bar HREF and #toolLink/#toolLinkParam -#macro( navBarHREF $allowAddAssignment $withGrade $allowGradeSubmission $allowAddAssignment $allowRecoverAssignment $allowAllGroups $assignmentscheck $allowUpdateSite $enableViewOption $view $current ) +#macro( navBarHREF $allowAddAssignment $allowGradeSubmission $allowAddAssignment $allowRecoverAssignment $allowAllGroups $assignmentscheck $allowUpdateSite $enableViewOption $view $current )