Search in sources :

Example 16 with FieldValidator

use of teammates.common.util.FieldValidator in project teammates by TEAMMATES.

the class FeedbackResponseAttributes method getInvalidityInfo.

@Override
public List<String> getInvalidityInfo() {
    FieldValidator validator = new FieldValidator();
    List<String> errors = new ArrayList<>();
    addNonEmptyError(validator.getInvalidityInfoForFeedbackSessionName(feedbackSessionName), errors);
    addNonEmptyError(validator.getInvalidityInfoForCourseId(courseId), errors);
    return errors;
}
Also used : FieldValidator(teammates.common.util.FieldValidator) ArrayList(java.util.ArrayList)

Example 17 with FieldValidator

use of teammates.common.util.FieldValidator in project teammates by TEAMMATES.

the class FeedbackSessionAttributes method getInvalidityInfo.

@Override
public List<String> getInvalidityInfo() {
    FieldValidator validator = new FieldValidator();
    List<String> errors = new ArrayList<>();
    // Check for null fields.
    addNonEmptyError(validator.getValidityInfoForNonNullField(FieldValidator.FEEDBACK_SESSION_NAME_FIELD_NAME, feedbackSessionName), errors);
    addNonEmptyError(validator.getValidityInfoForNonNullField(FieldValidator.COURSE_ID_FIELD_NAME, courseId), errors);
    addNonEmptyError(validator.getValidityInfoForNonNullField("instructions to students", instructions), errors);
    addNonEmptyError(validator.getValidityInfoForNonNullField("time for the session to become visible", sessionVisibleFromTime), errors);
    addNonEmptyError(validator.getValidityInfoForNonNullField("session time zone", timeZone), errors);
    addNonEmptyError(validator.getValidityInfoForNonNullField("creator's email", creatorEmail), errors);
    addNonEmptyError(validator.getValidityInfoForNonNullField("session creation time", createdTime), errors);
    // Early return if any null fields
    if (!errors.isEmpty()) {
        return errors;
    }
    addNonEmptyError(validator.getInvalidityInfoForFeedbackSessionName(feedbackSessionName), errors);
    addNonEmptyError(validator.getInvalidityInfoForCourseId(courseId), errors);
    addNonEmptyError(validator.getInvalidityInfoForEmail(creatorEmail), errors);
    addNonEmptyError(validator.getInvalidityInfoForGracePeriod(gracePeriod), errors);
    // Skip time frame checks if session type is private.
    if (this.isPrivateSession()) {
        return errors;
    }
    addNonEmptyError(validator.getValidityInfoForNonNullField("submission opening time", startTime), errors);
    addNonEmptyError(validator.getValidityInfoForNonNullField("submission closing time", endTime), errors);
    addNonEmptyError(validator.getValidityInfoForNonNullField("time for the responses to become visible", resultsVisibleFromTime), errors);
    // Early return if any null fields
    if (!errors.isEmpty()) {
        return errors;
    }
    addNonEmptyError(validator.getInvalidityInfoForTimeForSessionStartAndEnd(startTime, endTime), errors);
    addNonEmptyError(validator.getInvalidityInfoForTimeForVisibilityStartAndSessionStart(sessionVisibleFromTime, startTime), errors);
    Instant actualSessionVisibleFromTime = sessionVisibleFromTime;
    if (actualSessionVisibleFromTime.equals(Const.TIME_REPRESENTS_FOLLOW_OPENING)) {
        actualSessionVisibleFromTime = startTime;
    }
    addNonEmptyError(validator.getInvalidityInfoForTimeForVisibilityStartAndResultsPublish(actualSessionVisibleFromTime, resultsVisibleFromTime), errors);
    return errors;
}
Also used : Instant(java.time.Instant) FieldValidator(teammates.common.util.FieldValidator) ArrayList(java.util.ArrayList)

Aggregations

FieldValidator (teammates.common.util.FieldValidator)17 ArrayList (java.util.ArrayList)12 InvalidParametersException (teammates.common.exception.InvalidParametersException)3 Instant (java.time.Instant)1 ZoneId (java.time.ZoneId)1 Test (org.testng.annotations.Test)1 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)1 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)1 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)1 NullPostParameterException (teammates.common.exception.NullPostParameterException)1 AppUrl (teammates.common.util.AppUrl)1 StatusMessage (teammates.common.util.StatusMessage)1 InstructorCourseDetailsPage (teammates.test.pageobjects.InstructorCourseDetailsPage)1 InstructorCourseInstructorEditSaveAction (teammates.ui.controller.InstructorCourseInstructorEditSaveAction)1 RedirectResult (teammates.ui.controller.RedirectResult)1