Search in sources :

Example 56 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackEditSaveAction 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);
    InstructorFeedbackEditPageData data = new InstructorFeedbackEditPageData(account, sessionToken);
    // This is only for validation to pass; it will be overridden with its existing value at the logic layer
    String dummyCreatorEmail = "dummy@example.com";
    FeedbackSessionAttributes feedbackSession = extractFeedbackSessionData(feedbackSessionName, courseId, dummyCreatorEmail);
    try {
        validateTimeData(feedbackSession);
        addResolvedTimeFieldsToDataIfRequired(feedbackSession, data);
        logic.updateFeedbackSession(feedbackSession);
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS));
        statusToAdmin = "Updated Feedback Session " + "<span class=\"bold\">(" + feedbackSession.getFeedbackSessionName() + ")</span> for Course " + "<span class=\"bold\">[" + feedbackSession.getCourseId() + "]</span> created.<br>" + "<span class=\"bold\">From:</span> " + feedbackSession.getStartTime() + "<span class=\"bold\"> to</span> " + feedbackSession.getEndTime() + "<br><span class=\"bold\">Session visible from:</span> " + feedbackSession.getSessionVisibleFromTime() + "<br><span class=\"bold\">Results visible from:</span> " + feedbackSession.getResultsVisibleFromTime() + "<br><br><span class=\"bold\">Instructions:</span> " + feedbackSession.getInstructions();
        data.setHasError(false);
    } catch (InvalidParametersException e) {
        setStatusForException(e);
        data.setHasError(true);
    }
    data.setStatusMessagesToUser(statusToUser);
    return createAjaxResult(data);
}
Also used : InstructorFeedbackEditPageData(teammates.ui.pagedata.InstructorFeedbackEditPageData) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InvalidParametersException(teammates.common.exception.InvalidParametersException) StatusMessage(teammates.common.util.StatusMessage)

Example 57 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackPublishAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    String nextUrl = getRequestParamValue(Const.ParamsNames.NEXT_URL);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
    boolean isCreatorOnly = false;
    gateKeeper.verifyAccessible(instructor, session, isCreatorOnly, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    try {
        logic.publishFeedbackSession(session);
        if (session.isPublishedEmailEnabled()) {
            taskQueuer.scheduleFeedbackSessionPublishedEmail(session.getCourseId(), session.getFeedbackSessionName());
        }
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_PUBLISHED, StatusMessageColor.SUCCESS));
        statusToAdmin = "Feedback Session <span class=\"bold\">(" + feedbackSessionName + ")</span> " + "for Course <span class=\"bold\">[" + courseId + "]</span> published.";
    } catch (InvalidParametersException e) {
        setStatusForException(e);
    }
    if (nextUrl == null) {
        nextUrl = Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE;
    }
    return createRedirectResult(nextUrl);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InvalidParametersException(teammates.common.exception.InvalidParametersException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 58 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackQuestionCopyPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(feedbackSessionName, courseId);
    gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), feedbackSession, false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    List<FeedbackQuestionAttributes> copiableQuestions = null;
    copiableQuestions = logic.getCopiableFeedbackQuestionsForInstructor(account.googleId);
    InstructorFeedbackQuestionCopyPageData data = new InstructorFeedbackQuestionCopyPageData(account, sessionToken, copiableQuestions);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_QUESTION_COPY_MODAL, data);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackQuestionCopyPageData(teammates.ui.pagedata.InstructorFeedbackQuestionCopyPageData) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 59 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackUnpublishAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    String nextUrl = getRequestParamValue(Const.ParamsNames.NEXT_URL);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
    boolean isCreatorOnly = false;
    gateKeeper.verifyAccessible(instructor, session, isCreatorOnly, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    try {
        logic.unpublishFeedbackSession(session);
        if (session.isPublishedEmailEnabled()) {
            taskQueuer.scheduleFeedbackSessionUnpublishedEmail(session.getCourseId(), session.getFeedbackSessionName());
        }
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_UNPUBLISHED, StatusMessageColor.SUCCESS));
        statusToAdmin = "Feedback Session <span class=\"bold\">(" + feedbackSessionName + ")</span> " + "for Course <span class=\"bold\">[" + courseId + "]</span> unpublished.";
    } catch (InvalidParametersException e) {
        setStatusForException(e);
    }
    if (nextUrl == null) {
        nextUrl = Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE;
    }
    return createRedirectResult(nextUrl);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InvalidParametersException(teammates.common.exception.InvalidParametersException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 60 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class InstructorStudentRecordsAjaxPageAction method execute.

@Override
public ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
    Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENT_EMAIL, studentEmail);
    String targetSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, targetSessionName);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId));
    StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
    if (student == null) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_RECORDS, StatusMessageColor.DANGER));
        isError = true;
        return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
    }
    List<FeedbackSessionAttributes> feedbacks = logic.getFeedbackSessionsListForInstructor(account.googleId, false);
    filterFeedbackSessions(courseId, feedbacks, instructor, student);
    List<SessionAttributes> sessions = new ArrayList<>();
    sessions.addAll(feedbacks);
    sessions.sort(SessionAttributes.DESCENDING_ORDER);
    List<FeedbackSessionResultsBundle> results = new ArrayList<>();
    for (SessionAttributes session : sessions) {
        if (session instanceof FeedbackSessionAttributes) {
            if (!targetSessionName.isEmpty() && targetSessionName.equals(session.getSessionName())) {
                FeedbackSessionResultsBundle result = logic.getFeedbackSessionResultsForInstructor(session.getSessionName(), courseId, instructor.email);
                results.add(result);
            }
        } else {
            Assumption.fail("Unknown session type");
        }
    }
    statusToAdmin = "instructorStudentRecords Ajax Page Load<br>" + "Viewing <span class=\"bold\">" + studentEmail + "'s</span> records " + "for session <span class=\"bold\">[" + targetSessionName + "]</span> " + "in course <span class=\"bold\">[" + courseId + "]</span>";
    InstructorStudentRecordsAjaxPageData data = new InstructorStudentRecordsAjaxPageData(account, student, sessionToken, results);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS_AJAX, data);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorStudentRecordsAjaxPageData(teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData) SessionAttributes(teammates.common.datatransfer.attributes.SessionAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle)

Aggregations

FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)205 Test (org.testng.annotations.Test)85 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)78 ArrayList (java.util.ArrayList)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)35 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)32 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)30 RedirectResult (teammates.ui.controller.RedirectResult)27 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)21 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)19 StatusMessage (teammates.common.util.StatusMessage)19 HashMap (java.util.HashMap)17 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)13 EmailWrapper (teammates.common.util.EmailWrapper)12 Text (com.google.appengine.api.datastore.Text)11 DataBundle (teammates.common.datatransfer.DataBundle)11 EmailGenerator (teammates.logic.api.EmailGenerator)10 List (java.util.List)9 TaskWrapper (teammates.common.util.TaskWrapper)9