Search in sources :

Example 21 with StatusMessage

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

the class InstructorFeedbackQuestionAddAction 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);
    FeedbackQuestionAttributes feedbackQuestion = extractFeedbackQuestionData(instructorDetailForCourse.email);
    List<String> questionDetailsErrors = feedbackQuestion.getQuestionDetails().validateQuestionDetails();
    List<StatusMessage> questionDetailsErrorsMessages = new ArrayList<>();
    for (String error : questionDetailsErrors) {
        questionDetailsErrorsMessages.add(new StatusMessage(error, StatusMessageColor.DANGER));
    }
    RedirectResult redirectResult = createRedirectResult(new PageData(account, sessionToken).getInstructorFeedbackEditLink(courseId, feedbackSessionName));
    if (!questionDetailsErrors.isEmpty()) {
        statusToUser.addAll(questionDetailsErrorsMessages);
        isError = true;
        return redirectResult;
    }
    String err = validateQuestionGiverRecipientVisibility(feedbackQuestion);
    if (!err.isEmpty()) {
        statusToUser.add(new StatusMessage(err, StatusMessageColor.DANGER));
        isError = true;
    }
    try {
        logic.createFeedbackQuestion(feedbackQuestion);
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, StatusMessageColor.SUCCESS));
        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());
    } catch (InvalidParametersException e) {
        statusToUser.add(new StatusMessage(e.getMessage(), StatusMessageColor.DANGER));
        statusToAdmin = e.getMessage();
        isError = true;
    }
    return redirectResult;
}
Also used : PageData(teammates.ui.pagedata.PageData) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InvalidParametersException(teammates.common.exception.InvalidParametersException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 22 with StatusMessage

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

the class InstructorFeedbackQuestionEditAction method deleteQuestion.

private void deleteQuestion() {
    String questionId = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID);
    String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionName = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    String questionNumber = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER);
    logic.deleteFeedbackQuestion(questionId);
    statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_QUESTION_DELETED, StatusMessageColor.SUCCESS));
    statusToAdmin = "Feedback Question " + questionNumber + " for session:<span class=\"bold\">(" + feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + courseId + "]</span> deleted.<br>";
}
Also used : StatusMessage(teammates.common.util.StatusMessage)

Example 23 with StatusMessage

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

the class InstructorCourseInstructorEditSaveAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    String instructorId = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_ID);
    String instructorName = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_NAME, instructorName);
    String instructorEmail = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL);
    Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_EMAIL, instructorEmail);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR);
    InstructorAttributes instructorToEdit = extractUpdatedInstructor(courseId, instructorId, instructorName, instructorEmail);
    updateToEnsureValidityOfInstructorsForTheCourse(courseId, instructorToEdit);
    try {
        if (instructorId == null) {
            logic.updateInstructorByEmail(instructorEmail, instructorToEdit);
        } else {
            logic.updateInstructorByGoogleId(instructorId, instructorToEdit);
        }
        statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.COURSE_INSTRUCTOR_EDITED, instructorName), StatusMessageColor.SUCCESS));
        statusToAdmin = "Instructor <span class=\"bold\"> " + instructorName + "</span>" + " for Course <span class=\"bold\">[" + courseId + "]</span> edited.<br>" + "New Name: " + instructorName + "<br>New Email: " + instructorEmail;
    } catch (InvalidParametersException e) {
        setStatusForException(e);
    }
    /* Create redirection to 'Edit' page with corresponding course id */
    RedirectResult result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE);
    result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
    return result;
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 24 with StatusMessage

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

the class InstructorCourseRemindAction method execute.

@Override
public ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    CourseAttributes course = logic.getCourse(courseId);
    if (course == null) {
        throw new EntityDoesNotExistException("Course with ID " + courseId + " does not exist!");
    }
    String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
    String instructorEmail = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    boolean isSendingToStudent = studentEmail != null;
    boolean isSendingToInstructor = instructorEmail != null;
    if (isSendingToStudent) {
        gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
    } else if (isSendingToInstructor) {
        gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR);
    } else {
        // this is sending registration emails to all students in the course and we will check if the instructor
        // canmodifystudent for course level since for modifystudent privilege there is only course level setting for now
        gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
    }
    /* Process sending emails and setup status to be shown to user and admin */
    Map<String, JoinEmailData> emailDataMap = new TreeMap<>();
    String redirectUrl = "";
    if (isSendingToStudent) {
        taskQueuer.scheduleCourseRegistrationInviteToStudent(courseId, studentEmail, false);
        StudentAttributes studentData = logic.getStudentForEmail(courseId, studentEmail);
        if (studentData == null) {
            throw new EntityDoesNotExistException("Student with email " + studentEmail + " does not exist " + "in course " + courseId + "!");
        }
        emailDataMap.put(studentEmail, new JoinEmailData(studentData.getName(), extractStudentRegistrationKey(studentData)));
        statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDER_SENT_TO + studentEmail, StatusMessageColor.SUCCESS));
        redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE;
    } else if (isSendingToInstructor) {
        taskQueuer.scheduleCourseRegistrationInviteToInstructor(loggedInUser.googleId, instructorEmail, courseId);
        InstructorAttributes instructorData = logic.getInstructorForEmail(courseId, instructorEmail);
        if (instructorData == null) {
            throw new EntityDoesNotExistException("Instructor with email " + instructorEmail + " does not exist " + "in course " + courseId + "!");
        }
        emailDataMap.put(instructorEmail, new JoinEmailData(instructorData.getName(), StringHelper.encrypt(instructorData.key)));
        statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDER_SENT_TO + instructorEmail, StatusMessageColor.SUCCESS));
        redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE;
    } else {
        List<StudentAttributes> studentDataList = logic.getUnregisteredStudentsForCourse(courseId);
        for (StudentAttributes student : studentDataList) {
            taskQueuer.scheduleCourseRegistrationInviteToStudent(course.getId(), student.getEmail(), false);
            emailDataMap.put(student.getEmail(), new JoinEmailData(student.getName(), extractStudentRegistrationKey(student)));
        }
        statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDERS_SENT, StatusMessageColor.SUCCESS));
        redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE;
    }
    statusToAdmin = generateStatusToAdmin(emailDataMap, courseId);
    /* Create redirection with URL based on type of sending email */
    RedirectResult response = createRedirectResult(redirectUrl);
    response.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
    return response;
}
Also used : List(java.util.List) TreeMap(java.util.TreeMap) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 25 with StatusMessage

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

the class InstructorCourseStudentDeleteAllAction method execute.

@Override
public ActionResult execute() {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
    logic.deleteAllStudentsInCourse(courseId);
    statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENTS_DELETED, StatusMessageColor.SUCCESS));
    statusToAdmin = "All the Students " + "in Course <span class=\"bold\">[" + courseId + "]</span> are 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)

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