Search in sources :

Example 16 with StatusMessage

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

the class InstructorFeedbackResultsDownloadAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    String section = getRequestParamValue(Const.ParamsNames.SECTION_NAME);
    boolean isMissingResponsesShown = getRequestParamAsBoolean(Const.ParamsNames.FEEDBACK_RESULTS_INDICATE_MISSING_RESPONSES);
    boolean isStatsShown = getRequestParamAsBoolean(Const.ParamsNames.FEEDBACK_RESULTS_SHOWSTATS);
    String questionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID);
    String questionNumber = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER);
    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 = true;
    gateKeeper.verifyAccessible(instructor, session, !isCreatorOnly);
    String fileContent;
    String fileName;
    try {
        String questionName = "";
        if (questionNumber != null) {
            questionName = "_question" + questionNumber;
        }
        if (section == null || "All".equals(section)) {
            fileContent = logic.getFeedbackSessionResultSummaryAsCsv(courseId, feedbackSessionName, instructor.email, isMissingResponsesShown, isStatsShown, questionId);
            fileName = courseId + "_" + feedbackSessionName + questionName;
            statusToAdmin = "Summary data for Feedback Session " + feedbackSessionName + " in Course " + courseId + " was downloaded";
        } else {
            fileContent = logic.getFeedbackSessionResultSummaryInSectionAsCsv(courseId, feedbackSessionName, instructor.email, section, questionId, isMissingResponsesShown, isStatsShown);
            fileName = courseId + "_" + feedbackSessionName + "_" + section + questionName;
            statusToAdmin = "Summary data for Feedback Session " + feedbackSessionName + " in Course " + courseId + " within " + section + " was downloaded";
        }
    } catch (ExceedingRangeException e) {
        // not tested as the test file is not large enough to reach this catch block
        statusToUser.add(new StatusMessage("This session has more responses than that can be downloaded in one go. " + "Please download responses for " + (questionNumber == null ? "one question at a time instead. " + "To download responses for a specific question, click on the corresponding question number." : "section instead."), StatusMessageColor.DANGER));
        isError = true;
        RedirectResult result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACK_RESULTS_PAGE);
        result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
        result.addResponseParam(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
        return result;
    }
    return createFileDownloadResult(fileName, fileContent);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ExceedingRangeException(teammates.common.exception.ExceedingRangeException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 17 with StatusMessage

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

the class InstructorFeedbackResultsPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    String showStats = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_SHOWSTATS);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    statusToAdmin = "Show instructor feedback result page<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
    boolean isCreatorOnly = true;
    gateKeeper.verifyAccessible(instructor, session, !isCreatorOnly);
    InstructorFeedbackResultsPageData data = new InstructorFeedbackResultsPageData(account, sessionToken);
    String selectedSection = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION);
    if (selectedSection == null) {
        selectedSection = ALL_SECTION_OPTION;
    }
    boolean isMissingResponsesShown = getRequestParamAsBoolean(Const.ParamsNames.FEEDBACK_RESULTS_INDICATE_MISSING_RESPONSES);
    // this is for ajax loading of the html table in the modal
    // "(Non-English characters not displayed properly in the downloaded file? click here)"
    // TODO move into another action and another page data class
    boolean isLoadingCsvResultsAsHtml = getRequestParamAsBoolean(Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED);
    if (isLoadingCsvResultsAsHtml) {
        return createAjaxResultForCsvTableLoadedInHtml(courseId, feedbackSessionName, instructor, data, selectedSection, isMissingResponsesShown, Boolean.valueOf(showStats));
    }
    data.setSessionResultsHtmlTableAsString("");
    data.setAjaxStatus("");
    String groupByTeam = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYTEAM);
    String sortType = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE);
    String startIndex = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_MAIN_INDEX);
    if (startIndex != null) {
        data.setStartIndex(Integer.parseInt(startIndex));
    }
    if (sortType == null) {
        // default view: sort by question, statistics shown, grouped by team.
        showStats = "on";
        groupByTeam = "on";
        sortType = Const.FeedbackSessionResults.QUESTION_SORT_TYPE;
        isMissingResponsesShown = true;
    }
    String questionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID);
    String isTestingAjax = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_NEED_AJAX);
    if (ALL_SECTION_OPTION.equals(selectedSection) && questionId == null && !Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType)) {
        // bundle for all questions and all sections
        data.setBundle(logic.getFeedbackSessionResultsForInstructorWithinRangeFromView(feedbackSessionName, courseId, instructor.email, DEFAULT_SECTION_QUERY_RANGE, sortType));
    } else if (Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType)) {
        data.setBundle(getBundleForQuestionView(isTestingAjax, courseId, feedbackSessionName, instructor, data, selectedSection, sortType, questionId));
    } else if (Const.FeedbackSessionResults.GQR_SORT_TYPE.equals(sortType) || Const.FeedbackSessionResults.GRQ_SORT_TYPE.equals(sortType)) {
        data.setBundle(logic.getFeedbackSessionResultsForInstructorFromSectionWithinRange(feedbackSessionName, courseId, instructor.email, selectedSection, DEFAULT_SECTION_QUERY_RANGE));
    } else if (Const.FeedbackSessionResults.RQG_SORT_TYPE.equals(sortType) || Const.FeedbackSessionResults.RGQ_SORT_TYPE.equals(sortType)) {
        data.setBundle(logic.getFeedbackSessionResultsForInstructorToSectionWithinRange(feedbackSessionName, courseId, instructor.email, selectedSection, DEFAULT_SECTION_QUERY_RANGE));
    }
    if (data.getBundle() == null) {
        throw new EntityDoesNotExistException("Feedback session " + feedbackSessionName + " does not exist in " + courseId + ".");
    }
    // Warning for section wise viewing in case of many responses.
    boolean isShowSectionWarningForQuestionView = data.isLargeNumberOfRespondents() && Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType);
    boolean isShowSectionWarningForParticipantView = !data.getBundle().isComplete && !Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType);
    // Warning for section wise does not make sense if there are no multiple sections.
    boolean isMultipleSectionAvailable = data.getBundle().getRosterSectionTeamNameTable().size() > 1;
    if (selectedSection.equals(ALL_SECTION_OPTION) && (isShowSectionWarningForParticipantView || isShowSectionWarningForQuestionView)) {
        if (isMultipleSectionAvailable) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_SECTIONVIEWWARNING, StatusMessageColor.WARNING));
        } else {
            statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_QUESTIONVIEWWARNING, StatusMessageColor.WARNING));
        }
        isError = true;
    }
    switch(sortType) {
        case Const.FeedbackSessionResults.QUESTION_SORT_TYPE:
            data.initForViewByQuestion(instructor, selectedSection, showStats, groupByTeam, isMissingResponsesShown);
            return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, data);
        case Const.FeedbackSessionResults.RGQ_SORT_TYPE:
            data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_GIVER_QUESTION, isMissingResponsesShown);
            return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, data);
        case Const.FeedbackSessionResults.GRQ_SORT_TYPE:
            data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.GIVER_RECIPIENT_QUESTION, isMissingResponsesShown);
            return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_RECIPIENT_QUESTION, data);
        case Const.FeedbackSessionResults.RQG_SORT_TYPE:
            data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_QUESTION_GIVER, isMissingResponsesShown);
            return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_QUESTION_GIVER, data);
        case Const.FeedbackSessionResults.GQR_SORT_TYPE:
            data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.GIVER_QUESTION_RECIPIENT, isMissingResponsesShown);
            return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_QUESTION_RECIPIENT, data);
        default:
            sortType = Const.FeedbackSessionResults.RGQ_SORT_TYPE;
            data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_GIVER_QUESTION, isMissingResponsesShown);
            return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, data);
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackResultsPageData(teammates.ui.pagedata.InstructorFeedbackResultsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) StatusMessage(teammates.common.util.StatusMessage)

Example 18 with StatusMessage

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

the class InstructorFeedbackSessionsPageAction method execute.

@Override
protected ActionResult execute() {
    // This can be null. Non-null value indicates the page is being loaded
    // to add a feedback to the specified course
    String courseIdForNewSession = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionToHighlight = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    String isUsingAjax = getRequestParamValue(Const.ParamsNames.IS_USING_AJAX);
    gateKeeper.verifyInstructorPrivileges(account);
    if (courseIdForNewSession != null) {
        gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseIdForNewSession, account.googleId), logic.getCourse(courseIdForNewSession), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    }
    InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(account, sessionToken);
    data.setUsingAjax(isUsingAjax != null);
    // TODO: implement as a request parameter
    boolean shouldOmitArchived = true;
    // HashMap with courseId as key and InstructorAttributes as value
    Map<String, InstructorAttributes> instructors = loadCourseInstructorMap(shouldOmitArchived);
    List<InstructorAttributes> instructorList = new ArrayList<>(instructors.values());
    List<CourseAttributes> courses = loadCoursesList(instructorList);
    List<FeedbackSessionAttributes> existingFeedbackSessions;
    if (courses.isEmpty() || !data.isUsingAjax()) {
        existingFeedbackSessions = new ArrayList<>();
    } else {
        existingFeedbackSessions = loadFeedbackSessionsList(instructorList);
        if (existingFeedbackSessions.isEmpty()) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_EMPTY, StatusMessageColor.WARNING));
        }
    }
    if (courses.isEmpty()) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_EMPTY_IN_INSTRUCTOR_FEEDBACKS.replace("${user}", "?user=" + account.googleId), StatusMessageColor.WARNING));
    }
    statusToAdmin = "Number of feedback sessions: " + existingFeedbackSessions.size();
    data.initWithoutDefaultFormValues(courses, courseIdForNewSession, existingFeedbackSessions, instructors, feedbackSessionToHighlight);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, data);
}
Also used : ArrayList(java.util.ArrayList) 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 19 with StatusMessage

use of teammates.common.util.StatusMessage 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 20 with StatusMessage

use of teammates.common.util.StatusMessage 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)

Aggregations

StatusMessage (teammates.common.util.StatusMessage)81 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)34 InvalidParametersException (teammates.common.exception.InvalidParametersException)20 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)18 ArrayList (java.util.ArrayList)14 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)9 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)9 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)7 List (java.util.List)6 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)6 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)6 HashMap (java.util.HashMap)4 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)4 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)3 PageData (teammates.ui.pagedata.PageData)3 BlobInfo (com.google.appengine.api.blobstore.BlobInfo)2 BlobKey (com.google.appengine.api.blobstore.BlobKey)2 BlobstoreFailureException (com.google.appengine.api.blobstore.BlobstoreFailureException)2 Text (com.google.appengine.api.datastore.Text)2 AppLogLine (com.google.appengine.api.log.AppLogLine)2