Search in sources :

Example 6 with PageData

use of teammates.ui.pagedata.PageData in project teammates by TEAMMATES.

the class InstructorFeedbackQuestionEditAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionName = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    String editType = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE);
    try {
        if ("edit".equals(editType)) {
            String questionText = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TEXT);
            Assumption.assertNotEmpty("Empty question text", questionText);
            FeedbackQuestionAttributes updatedQuestion = extractFeedbackQuestionData();
            editQuestion(updatedQuestion);
        } else if ("delete".equals(editType)) {
            // branch not tested because if it's not edit or delete, Assumption.fail will cause test failure
            deleteQuestion();
        } else {
            // Assumption.fails are not tested
            Assumption.fail("Invalid editType");
        }
    } catch (InvalidParametersException e) {
        // This part is not tested because GateKeeper handles if this happens, would be
        // extremely difficult to replicate a situation whereby it gets past GateKeeper
        setStatusForException(e);
    }
    return createRedirectResult(new PageData(account, sessionToken).getInstructorFeedbackEditLink(courseId, feedbackSessionName));
}
Also used : PageData(teammates.ui.pagedata.PageData) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InvalidParametersException(teammates.common.exception.InvalidParametersException)

Aggregations

PageData (teammates.ui.pagedata.PageData)6 InvalidParametersException (teammates.common.exception.InvalidParametersException)4 StatusMessage (teammates.common.util.StatusMessage)4 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)3 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)3 ArrayList (java.util.ArrayList)1 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)1 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)1