List of usage examples for java.util GregorianCalendar before
public boolean before(Object when)
Calendar
represents a time before the time represented by the specified Object
. From source file:v800_trainer.JCicloTronic.java
private void Datenliste_ZeitabschnittActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Datenliste_ZeitabschnittActionPerformed // Add your handling code here: if (Update == false) { return;//from w w w . j av a 2 s.com } int Tag, Monat, Jahr; int i, Zeitdifferenz = 0; String dummy; java.util.GregorianCalendar Kalendera; java.util.GregorianCalendar Kalenderb; SelectionChanged = true; Update = false; Datenliste_Monat.setEnabled(false); if (Datenliste_Monat.getItemCount() != 0) Datenliste_Monat.setSelectedIndex(0); if (Datenliste_Jahr.getItemCount() != 0) Datenliste_Jahr.setSelectedIndex(0); Update = true; Datentabelle.clearSelection(); if (Datenliste_Zeitabschnitt.getSelectedIndex() == 0) { // jTable1.addRowSelectionInterval(0,0); return; } if (Datenliste_Zeitabschnitt.getSelectedIndex() == 1) { Zeitdifferenz = 8; } if (Datenliste_Zeitabschnitt.getSelectedIndex() == 2) { Zeitdifferenz = 31; } if (Datenliste_Zeitabschnitt.getSelectedIndex() == 3) { Zeitdifferenz = 366; } if (Datenliste_Zeitabschnitt.getSelectedIndex() == 4) { Zeitdifferenz = -1; } Kalendera = (java.util.GregorianCalendar) java.util.GregorianCalendar.getInstance(); Kalenderb = (java.util.GregorianCalendar) java.util.GregorianCalendar.getInstance(); if (Zeitdifferenz != -1) { Kalendera.add(Calendar.DATE, -Zeitdifferenz); } for (i = 0; i < Datentabelle.getRowCount(); i++) { dummy = (String) (Datentabelle.getValueAt(i, 0)); Jahr = Integer.parseInt(dummy.substring(8)); Monat = Integer.parseInt(dummy.substring(5, 7)); Tag = Integer.parseInt(dummy.substring(2, 4)); Kalenderb.set(Jahr, Monat - 1, Tag - 1); if ((Kalendera.before(Kalenderb) || Zeitdifferenz == -1) & (Datenliste_TourTyp.getSelectedItem().toString().equals(sorter.getValueAt(i, 6).toString()) || Datenliste_TourTyp.getSelectedIndex() == 0)) { Datentabelle.addRowSelectionInterval(i, i); } jLabel69_Selektiert.setText(Datentabelle.getSelectedRowCount() + " / " + Datentabelle.getRowCount()); } }
From source file:org.sakaiproject.assignment.tool.AssignmentAction.java
/** * Action is to save the input infos for assignment fields * * @param validify/* ww w .java 2s. c om*/ * Need to validify the inputs or not */ protected void setNewAssignmentParameters(RunData data, boolean validify) { // read the form inputs SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid()); ParameterParser params = data.getParameters(); String assignmentRef = params.getString("assignmentId"); // put the input value into the state attributes String title = params.getString(NEW_ASSIGNMENT_TITLE); state.setAttribute(NEW_ASSIGNMENT_TITLE, title); String order = params.getString(NEW_ASSIGNMENT_ORDER); state.setAttribute(NEW_ASSIGNMENT_ORDER, order); String additionalOptions = params.getString(NEW_ASSIGNMENT_ADDITIONAL_OPTIONS); boolean groupAssignment = false; if ("group".equals(additionalOptions)) { state.setAttribute(NEW_ASSIGNMENT_GROUP_SUBMIT, "1"); groupAssignment = true; } else { state.setAttribute(NEW_ASSIGNMENT_GROUP_SUBMIT, "0"); } if (title == null || title.length() == 0) { // empty assignment title addAlert(state, rb.getString("plespethe1")); } else if (sameAssignmentTitleInContext(assignmentRef, title, (String) state.getAttribute(STATE_CONTEXT_STRING))) { // assignment title already exist addAlert(state, rb.getFormattedMessage("same_assignment_title", new Object[] { title })); } // open time Time openTime = putTimeInputInState(params, state, NEW_ASSIGNMENT_OPENMONTH, NEW_ASSIGNMENT_OPENDAY, NEW_ASSIGNMENT_OPENYEAR, NEW_ASSIGNMENT_OPENHOUR, NEW_ASSIGNMENT_OPENMIN, "newassig.opedat"); // visible time if (Boolean.valueOf(ServerConfigurationService.getBoolean("assignment.visible.date.enabled", false))) { if (params.get("allowVisibleDateToggle") == null) { state.setAttribute(NEW_ASSIGNMENT_VISIBLETOGGLE, false); } else { Time visibleTime = putTimeInputInState(params, state, NEW_ASSIGNMENT_VISIBLEMONTH, NEW_ASSIGNMENT_VISIBLEDAY, NEW_ASSIGNMENT_VISIBLEYEAR, NEW_ASSIGNMENT_VISIBLEHOUR, NEW_ASSIGNMENT_VISIBLEMIN, "newassig.visdat"); state.setAttribute(NEW_ASSIGNMENT_VISIBLETOGGLE, true); } } // due time Time dueTime = putTimeInputInState(params, state, NEW_ASSIGNMENT_DUEMONTH, NEW_ASSIGNMENT_DUEDAY, NEW_ASSIGNMENT_DUEYEAR, NEW_ASSIGNMENT_DUEHOUR, NEW_ASSIGNMENT_DUEMIN, "gen.duedat"); // show alert message when due date is in past. Remove it after user confirms the choice. if (dueTime != null && dueTime.before(TimeService.newTime()) && state.getAttribute(NEW_ASSIGNMENT_PAST_DUE_DATE) == null) { state.setAttribute(NEW_ASSIGNMENT_PAST_DUE_DATE, Boolean.TRUE); } else { // clean the attribute after user confirm state.removeAttribute(NEW_ASSIGNMENT_PAST_DUE_DATE); } if (state.getAttribute(NEW_ASSIGNMENT_PAST_DUE_DATE) != null && validify) { addAlert(state, rb.getString("assig4")); } if (openTime != null && dueTime != null && !dueTime.after(openTime)) { addAlert(state, rb.getString("assig3")); } state.setAttribute(NEW_ASSIGNMENT_ENABLECLOSEDATE, Boolean.valueOf(true)); // close time Time closeTime = putTimeInputInState(params, state, NEW_ASSIGNMENT_CLOSEMONTH, NEW_ASSIGNMENT_CLOSEDAY, NEW_ASSIGNMENT_CLOSEYEAR, NEW_ASSIGNMENT_CLOSEHOUR, NEW_ASSIGNMENT_CLOSEMIN, "date.closedate"); if (openTime != null && closeTime != null && !closeTime.after(openTime)) { addAlert(state, rb.getString("acesubdea3")); } if (dueTime != null && closeTime != null && closeTime.before(dueTime)) { addAlert(state, rb.getString("acesubdea2")); } // SECTION MOD String sections_string = ""; String mode = (String) state.getAttribute(STATE_MODE); if (mode == null) mode = ""; state.setAttribute(NEW_ASSIGNMENT_SECTION, sections_string); Integer submissionType = Integer.valueOf(params.getString(NEW_ASSIGNMENT_SUBMISSION_TYPE)); state.setAttribute(NEW_ASSIGNMENT_SUBMISSION_TYPE, submissionType); // Skip category if it was never set. Long catInt = Long.valueOf(-1); if (params.getString(NEW_ASSIGNMENT_CATEGORY) != null) catInt = Long.valueOf(params.getString(NEW_ASSIGNMENT_CATEGORY)); state.setAttribute(NEW_ASSIGNMENT_CATEGORY, catInt); int gradeType = -1; // grade type and grade points if (state.getAttribute(WITH_GRADES) != null && ((Boolean) state.getAttribute(WITH_GRADES)).booleanValue()) { gradeType = Integer.parseInt(params.getString(NEW_ASSIGNMENT_GRADE_TYPE)); state.setAttribute(NEW_ASSIGNMENT_GRADE_TYPE, Integer.valueOf(gradeType)); } //Peer Assessment boolean peerAssessment = false; if ("peerreview".equals(additionalOptions)) { state.setAttribute(NEW_ASSIGNMENT_USE_PEER_ASSESSMENT, Boolean.TRUE.toString()); peerAssessment = true; } else { state.setAttribute(NEW_ASSIGNMENT_USE_PEER_ASSESSMENT, Boolean.FALSE.toString()); } if (peerAssessment) { //not allowed for group assignments: if (groupAssignment) { addAlert(state, rb.getString("peerassessment.invliadGroupAssignment")); } //do not allow non-electronic assignments if (Assignment.NON_ELECTRONIC_ASSIGNMENT_SUBMISSION == submissionType) { addAlert(state, rb.getString("peerassessment.invliadSubmissionTypeAssignment")); } if (gradeType != Assignment.SCORE_GRADE_TYPE) { addAlert(state, rb.getString("peerassessment.invliadGradeTypeAssignment")); } Time peerPeriodTime = putTimeInputInState(params, state, NEW_ASSIGNMENT_PEERPERIODMONTH, NEW_ASSIGNMENT_PEERPERIODDAY, NEW_ASSIGNMENT_PEERPERIODYEAR, NEW_ASSIGNMENT_PEERPERIODHOUR, NEW_ASSIGNMENT_PEERPERIODMIN, "newassig.opedat"); GregorianCalendar peerPeriodMinTimeCal = new GregorianCalendar(); peerPeriodMinTimeCal.setTimeInMillis(closeTime.getTime()); peerPeriodMinTimeCal.add(GregorianCalendar.MINUTE, 10); GregorianCalendar peerPeriodTimeCal = new GregorianCalendar(); peerPeriodTimeCal.setTimeInMillis(peerPeriodTime.getTime()); //peer assessment must complete at a minimum of 10 mins after close time if (peerPeriodTimeCal.before(peerPeriodMinTimeCal)) { addAlert(state, rb.getString("peerassessment.invliadPeriodTime")); } } String b, r; r = params.getString(NEW_ASSIGNMENT_PEER_ASSESSMENT_ANON_EVAL); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_PEER_ASSESSMENT_ANON_EVAL, b); r = params.getString(NEW_ASSIGNMENT_PEER_ASSESSMENT_STUDENT_VIEW_REVIEWS); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_PEER_ASSESSMENT_STUDENT_VIEW_REVIEWS, b); if (peerAssessment) { if (params.get(NEW_ASSIGNMENT_PEER_ASSESSMENT_NUM_REVIEWS) != null && !"".equals(params.get(NEW_ASSIGNMENT_PEER_ASSESSMENT_NUM_REVIEWS))) { try { int peerAssessmentNumOfReviews = Integer .parseInt(params.getString(NEW_ASSIGNMENT_PEER_ASSESSMENT_NUM_REVIEWS)); if (peerAssessmentNumOfReviews > 0) { state.setAttribute(NEW_ASSIGNMENT_PEER_ASSESSMENT_NUM_REVIEWS, Integer.valueOf(peerAssessmentNumOfReviews)); } else { addAlert(state, rb.getString("peerassessment.invalidNumReview")); } } catch (Exception e) { addAlert(state, rb.getString("peerassessment.invalidNumReview")); } } else { addAlert(state, rb.getString("peerassessment.specifyNumReview")); } } String peerAssessmentInstructions = processFormattedTextFromBrowser(state, params.getString(NEW_ASSIGNMENT_PEER_ASSESSMENT_INSTRUCTIONS), true); state.setAttribute(NEW_ASSIGNMENT_PEER_ASSESSMENT_INSTRUCTIONS, peerAssessmentInstructions); //REVIEW SERVICE r = params.getString(NEW_ASSIGNMENT_USE_REVIEW_SERVICE); // set whether we use the review service or not if (r == null) b = Boolean.FALSE.toString(); else { b = Boolean.TRUE.toString(); if (state.getAttribute(NEW_ASSIGNMENT_SUBMISSION_TYPE) .equals(Assignment.NON_ELECTRONIC_ASSIGNMENT_SUBMISSION)) { //can't use content-review with non-electronic submissions addAlert(state, rb.getFormattedMessage("review.switch.ne.1", contentReviewService.getServiceName())); } } state.setAttribute(NEW_ASSIGNMENT_USE_REVIEW_SERVICE, b); //set whether students can view the review service results r = params.getString(NEW_ASSIGNMENT_ALLOW_STUDENT_VIEW); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_ALLOW_STUDENT_VIEW, b); //set submit options r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_SUBMIT_RADIO); if (r == null || (!NEW_ASSIGNMENT_REVIEW_SERVICE_SUBMIT_STANDARD.equals(r) && !NEW_ASSIGNMENT_REVIEW_SERVICE_SUBMIT_INSITUTION.equals(r))) r = NEW_ASSIGNMENT_REVIEW_SERVICE_SUBMIT_NONE; state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_SUBMIT_RADIO, r); //set originality report options r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_REPORT_RADIO); if (r == null || !NEW_ASSIGNMENT_REVIEW_SERVICE_REPORT_DUE.equals(r)) r = NEW_ASSIGNMENT_REVIEW_SERVICE_REPORT_IMMEDIATELY; state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_REPORT_RADIO, r); //set check repository options: r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_CHECK_TURNITIN); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_CHECK_TURNITIN, b); r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_CHECK_INTERNET); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_CHECK_INTERNET, b); r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_CHECK_PUB); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_CHECK_PUB, b); r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_CHECK_INSTITUTION); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_CHECK_INSTITUTION, b); //exclude bibliographic materials: r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_BIBLIOGRAPHIC); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_BIBLIOGRAPHIC, b); //exclude quoted materials: r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_QUOTED); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_QUOTED, b); //exclude small matches r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_SMALL_MATCHES); if (r == null) b = Boolean.FALSE.toString(); else b = Boolean.TRUE.toString(); state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_SMALL_MATCHES, b); //exclude type: //only options are 0=none, 1=words, 2=percentages r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_TYPE); if (!"0".equals(r) && !"1".equals(r) && !"2".equals(r)) { //this really shouldn't ever happen (unless someone's messing with the parameters) r = "0"; } state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_TYPE, r); //exclude value if (!"0".equals(r)) { r = params.getString(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_VALUE); try { int rInt = Integer.parseInt(r); if (rInt < 0 || rInt > 100) { addAlert(state, rb.getString("review.exclude.matches.value_error")); } } catch (Exception e) { addAlert(state, rb.getString("review.exclude.matches.value_error")); } state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_VALUE, r); } else { state.setAttribute(NEW_ASSIGNMENT_REVIEW_SERVICE_EXCLUDE_VALUE, "1"); } // treat the new assignment description as formatted text boolean checkForFormattingErrors = true; // instructor is creating a new assignment - so check for errors String description = processFormattedTextFromBrowser(state, params.getCleanString(NEW_ASSIGNMENT_DESCRIPTION), checkForFormattingErrors); state.setAttribute(NEW_ASSIGNMENT_DESCRIPTION, description); if (state.getAttribute(CALENDAR) != null || state.getAttribute(ADDITIONAL_CALENDAR) != null) { // calendar enabled for the site if (params.getString(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE) != null && params.getString(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE) .equalsIgnoreCase(Boolean.TRUE.toString())) { state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE, Boolean.TRUE.toString()); } else { state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE, Boolean.FALSE.toString()); } } else { // no calendar yet for the site state.removeAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE); } if (params.getString(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE) != null && params.getString(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE) .equalsIgnoreCase(Boolean.TRUE.toString())) { state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE, Boolean.TRUE.toString()); } else { state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE, Boolean.FALSE.toString()); } if (params.getString(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION) != null) { if (params.getString(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION) .equalsIgnoreCase(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_NONE)) { state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_NONE); } else if (params.getString(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION) .equalsIgnoreCase(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW)) { state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW); } else if (params.getString(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION) .equalsIgnoreCase(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH)) { state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH); } } if (params.getString(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE) != null && params.getString(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE).equalsIgnoreCase(Boolean.TRUE.toString())) { state.setAttribute(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE, Boolean.TRUE.toString()); } else { state.setAttribute(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE, Boolean.FALSE.toString()); } String s = params.getString(NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE); // set the honor pledge to be "no honor pledge" if (s == null) s = "1"; state.setAttribute(NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE, s); String grading = params.getString(NEW_ASSIGNMENT_ADD_TO_GRADEBOOK); state.setAttribute(NEW_ASSIGNMENT_ADD_TO_GRADEBOOK, grading); // SAK-17606 state.setAttribute(NEW_ASSIGNMENT_CHECK_ANONYMOUS_GRADING, params.getString(NEW_ASSIGNMENT_CHECK_ANONYMOUS_GRADING)); // only when choose to associate with assignment in Gradebook String associateAssignment = params .getString(AssignmentService.PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT); if (grading != null) { if (grading.equals(AssignmentService.GRADEBOOK_INTEGRATION_ASSOCIATE)) { state.setAttribute(AssignmentService.PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT, associateAssignment); } else { state.setAttribute(AssignmentService.PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT, ""); } if (!grading.equals(AssignmentService.GRADEBOOK_INTEGRATION_NO)) { // gradebook integration only available to point-grade assignment if (gradeType != Assignment.SCORE_GRADE_TYPE) { addAlert(state, rb.getString("addtogradebook.wrongGradeScale")); } // if chosen as "associate", have to choose one assignment from Gradebook if (grading.equals(AssignmentService.GRADEBOOK_INTEGRATION_ASSOCIATE) && StringUtils.trimToNull(associateAssignment) == null) { addAlert(state, rb.getString("grading.associate.alert")); } } } List attachments = (List) state.getAttribute(ATTACHMENTS); if (attachments == null || attachments.isEmpty()) { // read from vm file String[] attachmentIds = data.getParameters().getStrings("attachments"); if (attachmentIds != null && attachmentIds.length != 0) { attachments = new ArrayList(); for (int i = 0; i < attachmentIds.length; i++) { attachments.add(EntityManager.newReference(attachmentIds[i])); } } } state.setAttribute(NEW_ASSIGNMENT_ATTACHMENT, attachments); if (validify) { if ((description == null) || (description.length() == 0) || ("<br/>".equals(description)) && ((attachments == null || attachments.size() == 0))) { // if there is no description nor an attachment, show the following alert message. // One could ignore the message and still post the assignment if (state.getAttribute(NEW_ASSIGNMENT_DESCRIPTION_EMPTY) == null) { state.setAttribute(NEW_ASSIGNMENT_DESCRIPTION_EMPTY, Boolean.TRUE.toString()); } else { state.removeAttribute(NEW_ASSIGNMENT_DESCRIPTION_EMPTY); } } else { state.removeAttribute(NEW_ASSIGNMENT_DESCRIPTION_EMPTY); } } if (validify && state.getAttribute(NEW_ASSIGNMENT_DESCRIPTION_EMPTY) != null) { addAlert(state, rb.getString("thiasshas")); } // assignment range? String range = data.getParameters().getString("range"); state.setAttribute(NEW_ASSIGNMENT_RANGE, range); if ("groups".equals(range)) { String[] groupChoice = data.getParameters().getStrings("selectedGroups"); if (groupChoice != null && groupChoice.length != 0) { state.setAttribute(NEW_ASSIGNMENT_GROUPS, new ArrayList(Arrays.asList(groupChoice))); } else { state.setAttribute(NEW_ASSIGNMENT_GROUPS, null); addAlert(state, rb.getString("java.alert.youchoosegroup")); } } else { state.removeAttribute(NEW_ASSIGNMENT_GROUPS); } // check groups for duplicate members here if (groupAssignment) { Collection<String> _dupUsers = usersInMultipleGroups(state, "groups".equals(range), ("groups".equals(range) ? data.getParameters().getStrings("selectedGroups") : null), false, null); if (_dupUsers.size() > 0) { StringBuilder _sb = new StringBuilder(rb.getString("group.user.multiple.warning") + " "); Iterator<String> _it = _dupUsers.iterator(); if (_it.hasNext()) _sb.append(_it.next()); while (_it.hasNext()) _sb.append(", " + _it.next()); addAlert(state, _sb.toString()); M_log.warn(this + ":post_save_assignment at least one user in multiple groups."); } } // allow resubmission numbers if (params.getString("allowResToggle") != null && params.getString(AssignmentSubmission.ALLOW_RESUBMIT_NUMBER) != null) { // read in allowResubmit params Time resubmitCloseTime = readAllowResubmitParams(params, state, null); if (resubmitCloseTime != null) { // check the date is valid if (openTime != null && !resubmitCloseTime.after(openTime)) { addAlert(state, rb.getString("acesubdea6")); } } } else if (!Integer.valueOf(Assignment.NON_ELECTRONIC_ASSIGNMENT_SUBMISSION) .equals(state.getAttribute(NEW_ASSIGNMENT_SUBMISSION_TYPE))) { /* * SAK-26640: If the instructor switches to non-electronic by mistake, the resubmissions settings should persist so they can be easily retrieved. * So we only reset resubmit params for electronic assignments. */ resetAllowResubmitParams(state); } // assignment notification option String notiOption = params.getString(ASSIGNMENT_INSTRUCTOR_NOTIFICATIONS); if (notiOption != null) { state.setAttribute(Assignment.ASSIGNMENT_INSTRUCTOR_NOTIFICATIONS_VALUE, notiOption); } // release grade notification option String releaseGradeOption = params.getString(ASSIGNMENT_RELEASEGRADE_NOTIFICATION); if (releaseGradeOption != null) { state.setAttribute(Assignment.ASSIGNMENT_RELEASEGRADE_NOTIFICATION_VALUE, releaseGradeOption); } // release resubmission notification option String releaseResubmissionOption = params.getString(ASSIGNMENT_RELEASERESUBMISSION_NOTIFICATION); if (releaseResubmissionOption != null) { state.setAttribute(Assignment.ASSIGNMENT_RELEASERESUBMISSION_NOTIFICATION_VALUE, releaseResubmissionOption); } // read inputs for supplement items setNewAssignmentParametersSupplementItems(validify, state, params); if (state.getAttribute(WITH_GRADES) != null && ((Boolean) state.getAttribute(WITH_GRADES)).booleanValue()) { // the grade point String gradePoints = params.getString(NEW_ASSIGNMENT_GRADE_POINTS); state.setAttribute(NEW_ASSIGNMENT_GRADE_POINTS, gradePoints); if (gradePoints != null) { if (gradeType == 3) { if ((gradePoints.length() == 0)) { // in case of point grade assignment, user must specify maximum grade point addAlert(state, rb.getString("plespethe3")); } else { Integer scaleFactor = AssignmentService.getScaleFactor(); try { if (StringUtils.isNotEmpty(assignmentRef)) { Assignment assignment = AssignmentService.getAssignment(assignmentRef); if (assignment != null && assignment.getContent() != null) { scaleFactor = assignment.getContent().getFactor(); } } } catch (IdUnusedException | PermissionException e) { M_log.error(e); } validPointGrade(state, gradePoints, scaleFactor); // when scale is points, grade must be integer and less than maximum value if (state.getAttribute(STATE_MESSAGE) == null) { gradePoints = scalePointGrade(state, gradePoints, scaleFactor); } if (state.getAttribute(STATE_MESSAGE) == null) { state.setAttribute(NEW_ASSIGNMENT_GRADE_POINTS, gradePoints); } } } } } }