Search in sources :

Example 46 with FeedbackSessionAttributes

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

the class FeedbackSessionStatsPageAction 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);
    FeedbackSessionStatsPageData data = new FeedbackSessionStatsPageData(account, sessionToken);
    FeedbackSessionAttributes fsa = logic.getFeedbackSession(feedbackSessionName, courseId);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, fsa, false);
    data.sessionDetails = logic.getFeedbackSessionDetails(feedbackSessionName, courseId);
    return createAjaxResult(data);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSessionStatsPageData(teammates.ui.pagedata.FeedbackSessionStatsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 47 with FeedbackSessionAttributes

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

the class FeedbackSubmissionEditPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    if (!isSpecificUserJoinedCourse()) {
        return createPleaseJoinCourseResponse(courseId);
    }
    FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(feedbackSessionName, courseId);
    if (feedbackSession == null) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_DELETED_NO_ACCESS, StatusMessageColor.WARNING));
        return createSpecificRedirectResult();
    }
    verifyAccessibleForSpecificUser(feedbackSession);
    String regKey = getRequestParamValue(Const.ParamsNames.REGKEY);
    String email = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
    String userEmailForCourse = getUserEmailForCourse();
    data = new FeedbackSubmissionEditPageData(account, student, sessionToken);
    data.bundle = getDataBundle(userEmailForCourse);
    data.setSessionOpenForSubmission(isSessionOpenForSpecificUser(data.bundle.feedbackSession));
    data.init(regKey, email, courseId);
    setStatusToAdmin();
    // TODO: implement this in another way so there is no dependence on status messages from another page
    addFeedbackSubmissionStatusMessageIfNotRedirected();
    return createSpecificShowPageResult();
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSubmissionEditPageData(teammates.ui.pagedata.FeedbackSubmissionEditPageData) StatusMessage(teammates.common.util.StatusMessage)

Example 48 with FeedbackSessionAttributes

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

the class InstructorFeedbackAddAction method execute.

@Override
protected ActionResult execute() {
    String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertNotEmpty(courseId);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    String feedbackSessionName = SanitizationHelper.sanitizeTitle(getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME));
    FeedbackSessionAttributes fs = extractFeedbackSessionData(feedbackSessionName, courseId, instructor.email);
    String feedbackSessionType = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_TYPE);
    InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(account, sessionToken);
    try {
        validateTimeData(fs);
        logic.createFeedbackSession(fs);
        try {
            createTemplateFeedbackQuestions(fs.getCourseId(), fs.getFeedbackSessionName(), fs.getCreatorEmail(), feedbackSessionType);
        } catch (InvalidParametersException e) {
            // Failed to create feedback questions for specified template/feedback session type.
            // TODO: let the user know an error has occurred? delete the feedback session?
            log.severe(TeammatesException.toStringWithStackTrace(e));
        }
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_ADDED, StatusMessageColor.SUCCESS));
        statusToAdmin = "New Feedback Session <span class=\"bold\">(" + fs.getFeedbackSessionName() + ")</span> for Course " + "<span class=\"bold\">[" + fs.getCourseId() + "]</span> created.<br>" + "<span class=\"bold\">From:</span> " + fs.getStartTime() + "<span class=\"bold\"> to</span> " + fs.getEndTime() + "<br>" + "<span class=\"bold\">Session visible from:</span> " + fs.getSessionVisibleFromTime() + "<br>" + "<span class=\"bold\">Results visible from:</span> " + fs.getResultsVisibleFromTime() + "<br><br>" + "<span class=\"bold\">Instructions:</span> " + fs.getInstructions();
        // (similar to the one below)
        return createRedirectResult(data.getInstructorFeedbackEditLink(fs.getCourseId(), fs.getFeedbackSessionName()));
    } catch (EntityAlreadyExistsException e) {
        setStatusForException(e, Const.StatusMessages.FEEDBACK_SESSION_EXISTS);
    } catch (InvalidParametersException e) {
        setStatusForException(e);
    }
    // isError == true if an exception occurred above
    boolean shouldOmitArchived = true;
    Map<String, InstructorAttributes> instructors = loadCourseInstructorMap(shouldOmitArchived);
    List<InstructorAttributes> instructorList = new ArrayList<>(instructors.values());
    List<CourseAttributes> courses = loadCoursesList(instructorList);
    List<FeedbackSessionAttributes> feedbackSessions = loadFeedbackSessionsList(instructorList);
    FeedbackSessionAttributes.sortFeedbackSessionsByCreationTimeDescending(feedbackSessions);
    if (feedbackSessions.isEmpty()) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_ADD_DB_INCONSISTENCY, StatusMessageColor.WARNING));
    }
    data.initWithoutHighlightedRow(courses, courseId, feedbackSessions, instructors, fs, feedbackSessionType);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, data);
}
Also used : EntityAlreadyExistsException(teammates.common.exception.EntityAlreadyExistsException) ArrayList(java.util.ArrayList) InvalidParametersException(teammates.common.exception.InvalidParametersException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackSessionsPageData(teammates.ui.pagedata.InstructorFeedbackSessionsPageData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 49 with FeedbackSessionAttributes

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

the class InstructorFeedbackCopyAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String copiedFeedbackSessionName = getRequestParamValue(Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME);
    String copiedCourseId = getRequestParamValue(Const.ParamsNames.COPIED_COURSE_ID);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, copiedFeedbackSessionName);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COPIED_COURSE_ID, copiedCourseId);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    try {
        FeedbackSessionAttributes fs = logic.copyFeedbackSession(copiedFeedbackSessionName.trim(), copiedCourseId, feedbackSessionName, courseId, instructor.email);
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_COPIED, StatusMessageColor.SUCCESS));
        statusToAdmin = "New Feedback Session <span class=\"bold\">(" + fs.getFeedbackSessionName() + ")</span> " + "for Course <span class=\"bold\">[" + fs.getCourseId() + "]</span> created.<br>" + "<span class=\"bold\">From:</span> " + fs.getStartTime() + "<span class=\"bold\"> to</span> " + fs.getEndTime() + "<br>" + "<span class=\"bold\">Session visible from:</span> " + fs.getSessionVisibleFromTime() + "<br>" + "<span class=\"bold\">Results visible from:</span> " + fs.getResultsVisibleFromTime() + "<br><br>" + "<span class=\"bold\">Instructions:</span> " + fs.getInstructions();
        // (similar to the one below)
        return createRedirectResult(new PageData(account, sessionToken).getInstructorFeedbackEditLink(fs.getCourseId(), fs.getFeedbackSessionName()));
    } catch (EntityAlreadyExistsException e) {
        setStatusForException(e, Const.StatusMessages.FEEDBACK_SESSION_EXISTS);
    } catch (InvalidParametersException e) {
        setStatusForException(e);
    }
    RedirectResult redirectResult = createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE);
    redirectResult.responseParams.put(Const.ParamsNames.USER_ID, account.googleId);
    return redirectResult;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) PageData(teammates.ui.pagedata.PageData) EntityAlreadyExistsException(teammates.common.exception.EntityAlreadyExistsException) InvalidParametersException(teammates.common.exception.InvalidParametersException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 50 with FeedbackSessionAttributes

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

the class InstructorFeedbackEditCopyAction method filterConflictsInCourses.

/**
 * Given an array of Course Ids, return only the Ids of Courses which has
 * an existing feedback session with a name conflicting with feedbackSessionName.
 */
private List<String> filterConflictsInCourses(String feedbackSessionName, String[] coursesIdToCopyTo) {
    List<String> courses = new ArrayList<>();
    for (String courseIdToCopy : coursesIdToCopyTo) {
        FeedbackSessionAttributes existingFs = logic.getFeedbackSession(feedbackSessionName, courseIdToCopy);
        boolean hasExistingFs = existingFs != null;
        if (hasExistingFs) {
            courses.add(existingFs.getCourseId());
        }
    }
    return courses;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList)

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