use of teammates.common.datatransfer.attributes.InstructorAttributes 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);
}
use of teammates.common.datatransfer.attributes.InstructorAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackSubmissionEditPageAction method verifyAccessibleForSpecificUser.
@Override
protected void verifyAccessibleForSpecificUser(FeedbackSessionAttributes session) {
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
boolean isCreatorOnly = false;
gateKeeper.verifyAccessible(instructor, session, isCreatorOnly);
boolean shouldEnableSubmit = instructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS);
if (!shouldEnableSubmit && instructor.isAllowedForPrivilegeAnySection(session.getFeedbackSessionName(), Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS)) {
shouldEnableSubmit = true;
}
if (!shouldEnableSubmit) {
throw new UnauthorizedAccessException("Feedback session [" + session.getFeedbackSessionName() + "] is not accessible to instructor [" + instructor.email + "] for this purpose");
}
}
use of teammates.common.datatransfer.attributes.InstructorAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackPreviewAsInstructorAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
String previewInstructorEmail = getRequestParamValue(Const.ParamsNames.PREVIEWAS);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
Assumption.assertPostParamNotNull(Const.ParamsNames.PREVIEWAS, previewInstructorEmail);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
InstructorAttributes previewInstructor = logic.getInstructorForEmail(courseId, previewInstructorEmail);
if (previewInstructor == null) {
throw new EntityDoesNotExistException("Instructor Email " + previewInstructorEmail + " does not exist in " + courseId + ".");
}
FeedbackSubmissionEditPageData data = new FeedbackSubmissionEditPageData(account, student, sessionToken);
data.bundle = logic.getFeedbackSessionQuestionsBundleForInstructor(feedbackSessionName, courseId, previewInstructor.email);
data.setSessionOpenForSubmission(true);
data.setPreview(true);
data.setHeaderHidden(true);
data.setPreviewInstructor(previewInstructor);
data.setSubmitAction(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT_SAVE);
data.bundle.resetAllResponses();
statusToAdmin = "Preview feedback session as instructor (" + previewInstructor.email + ")<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
data.init("", "", courseId);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, data);
}
use of teammates.common.datatransfer.attributes.InstructorAttributes 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);
}
use of teammates.common.datatransfer.attributes.InstructorAttributes 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;
}
Aggregations