Search in sources :

Example 56 with StatusMessage

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

the class InstructorFeedbackQuestionCopyAction method execute.

@Override
protected ActionResult execute() {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    InstructorAttributes instructorDetailForCourse = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructorDetailForCourse, logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    String instructorEmail = instructorDetailForCourse.email;
    try {
        int index = 0;
        String feedbackQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + index);
        statusToAdmin = "";
        while (feedbackQuestionId != null) {
            FeedbackQuestionAttributes feedbackQuestion = logic.copyFeedbackQuestion(feedbackQuestionId, feedbackSessionName, courseId, instructorEmail);
            index++;
            feedbackQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + index);
            statusToAdmin += "Created Feedback Question for Feedback Session:<span class=\"bold\">(" + feedbackQuestion.feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + feedbackQuestion.courseId + "]</span> created.<br>" + "<span class=\"bold\">" + feedbackQuestion.getQuestionDetails().getQuestionTypeDisplayName() + ":</span> " + SanitizationHelper.sanitizeForHtml(feedbackQuestion.getQuestionDetails().getQuestionText());
        }
        if (index > 0) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, StatusMessageColor.SUCCESS));
        } else {
            statusToUser.add(new StatusMessage("No questions are indicated to be copied", StatusMessageColor.DANGER));
            isError = true;
        }
    } 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
        statusToUser.add(new StatusMessage(e.getMessage(), StatusMessageColor.DANGER));
        statusToAdmin = e.getMessage();
        isError = true;
    }
    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) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 57 with StatusMessage

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

the class InstructorFeedbackQuestionEditAction method editQuestion.

private void editQuestion(FeedbackQuestionAttributes updatedQuestion) throws InvalidParametersException, EntityDoesNotExistException {
    String err = validateQuestionGiverRecipientVisibility(updatedQuestion);
    if (!err.isEmpty()) {
        statusToUser.add(new StatusMessage(err, StatusMessageColor.DANGER));
        isError = true;
    }
    FeedbackQuestionDetails updatedQuestionDetails = updatedQuestion.getQuestionDetails();
    List<String> questionDetailsErrors = updatedQuestionDetails.validateQuestionDetails();
    List<StatusMessage> questionDetailsErrorsMessages = new ArrayList<>();
    for (String error : questionDetailsErrors) {
        questionDetailsErrorsMessages.add(new StatusMessage(error, StatusMessageColor.DANGER));
    }
    if (questionDetailsErrors.isEmpty()) {
        logic.updateFeedbackQuestionNumber(updatedQuestion);
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, StatusMessageColor.SUCCESS));
        statusToAdmin = "Feedback Question " + updatedQuestion.questionNumber + " for session:<span class=\"bold\">(" + updatedQuestion.feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + updatedQuestion.courseId + "]</span> edited.<br>" + "<span class=\"bold\">" + updatedQuestionDetails.getQuestionTypeDisplayName() + ":</span> " + SanitizationHelper.sanitizeForHtml(updatedQuestionDetails.getQuestionText());
    } else {
        statusToUser.addAll(questionDetailsErrorsMessages);
        isError = true;
    }
}
Also used : FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) ArrayList(java.util.ArrayList) StatusMessage(teammates.common.util.StatusMessage)

Example 58 with StatusMessage

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

the class AdminSessionsPageAction method createShowPageResultIfParametersInvalid.

private ActionResult createShowPageResultIfParametersInvalid() {
    String startDate = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_STARTDATE);
    String endDate = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_ENDDATE);
    String startHour = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_STARTHOUR);
    String endHour = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_ENDHOUR);
    String startMin = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_STARTMINUTE);
    String endMin = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_ENDMINUTE);
    String timeZone = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_TIMEZONE);
    Date start;
    Date end;
    double zone = 0.0;
    Calendar calStart = TimeHelper.now(zone);
    Calendar calEnd = TimeHelper.now(zone);
    calStart.add(Calendar.DAY_OF_YEAR, -3);
    calEnd.add(Calendar.DAY_OF_YEAR, 4);
    if (checkAllParameters("null")) {
        start = calStart.getTime();
        end = calEnd.getTime();
    } else if (checkAllParameters("notNull")) {
        SanitizationHelper.sanitizeForHtml(startDate);
        SanitizationHelper.sanitizeForHtml(endDate);
        SanitizationHelper.sanitizeForHtml(startHour);
        SanitizationHelper.sanitizeForHtml(endHour);
        SanitizationHelper.sanitizeForHtml(startMin);
        SanitizationHelper.sanitizeForHtml(endMin);
        SanitizationHelper.sanitizeForHtml(timeZone);
        zone = Double.parseDouble(timeZone);
        start = TimeHelper.convertLocalDateTimeToDate(TimeHelper.parseLocalDateTimeForSessionsForm(startDate, startHour, startMin));
        end = TimeHelper.convertLocalDateTimeToDate(TimeHelper.parseLocalDateTimeForSessionsForm(endDate, endHour, endMin));
        if (start.after(end)) {
            isError = true;
            statusToUser.add(new StatusMessage("The filter range is not valid." + " End time should be after start time.", StatusMessageColor.DANGER));
            statusToAdmin = "Admin Sessions Page Load<br>" + "<span class=\"bold\"> Error: invalid filter range</span>";
            prepareDefaultPageData(calStart, calEnd);
            data.init(this.map, this.sessionToInstructorIdMap, this.totalOngoingSessions, this.totalOpenStatusSessions, this.totalClosedStatusSessions, this.totalWaitToOpenStatusSessions, this.totalInstitutes, this.rangeStart, this.rangeEnd, this.zone, this.isShowAll);
            return createShowPageResult(Const.ViewURIs.ADMIN_SESSIONS, data);
        }
    } else {
        isError = true;
        statusToUser.add(new StatusMessage("Error: Missing Parameters", StatusMessageColor.DANGER));
        statusToAdmin = "Admin Sessions Page Load<br>" + "<span class=\"bold\"> Error: Missing Parameters</span>";
        prepareDefaultPageData(calStart, calEnd);
        data.init(this.map, this.sessionToInstructorIdMap, this.totalOngoingSessions, this.totalOpenStatusSessions, this.totalClosedStatusSessions, this.totalWaitToOpenStatusSessions, this.totalInstitutes, this.rangeStart, this.rangeEnd, this.zone, this.isShowAll);
        return createShowPageResult(Const.ViewURIs.ADMIN_SESSIONS, data);
    }
    this.rangeStart = start;
    this.rangeEnd = end;
    this.zone = zone;
    return null;
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) StatusMessage(teammates.common.util.StatusMessage)

Example 59 with StatusMessage

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

the class InstructorCourseStudentDeleteAction method execute.

@Override
public ActionResult execute() {
    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);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
    logic.deleteStudent(courseId, studentEmail);
    statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_DELETED, StatusMessageColor.SUCCESS));
    statusToAdmin = "Student <span class=\"bold\">" + studentEmail + "</span> in Course <span class=\"bold\">[" + courseId + "]</span> deleted.";
    RedirectResult result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE);
    result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
    return result;
}
Also used : InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 60 with StatusMessage

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

the class InstructorCourseStudentDetailsEditPageAction 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);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
    StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
    if (student == null) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT, StatusMessageColor.DANGER));
        isError = true;
        return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
    }
    boolean hasSection = logic.hasIndicatedSections(courseId);
    boolean isOpenOrPublishedEmailSentForTheCourse = logic.isOpenOrPublishedEmailSentForTheCourse(courseId);
    InstructorCourseStudentDetailsEditPageData data = new InstructorCourseStudentDetailsEditPageData(account, sessionToken, student, student.email, hasSection, isOpenOrPublishedEmailSentForTheCourse);
    statusToAdmin = "instructorCourseStudentEdit Page Load<br>" + "Editing Student <span class=\"bold\">" + studentEmail + "'s</span> details " + "in Course <span class=\"bold\">[" + courseId + "]</span>";
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT, data);
}
Also used : InstructorCourseStudentDetailsEditPageData(teammates.ui.pagedata.InstructorCourseStudentDetailsEditPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) 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