use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionAddAction method extractFeedbackQuestionData.
private FeedbackQuestionAttributes extractFeedbackQuestionData(String creatorEmail) {
FeedbackQuestionAttributes newQuestion = new FeedbackQuestionAttributes();
newQuestion.creatorEmail = creatorEmail;
newQuestion.courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, newQuestion.courseId);
newQuestion.feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, newQuestion.feedbackSessionName);
String feedbackQuestionGiverType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, feedbackQuestionGiverType);
newQuestion.giverType = FeedbackParticipantType.valueOf(feedbackQuestionGiverType);
String feedbackQuestionRecipientType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, feedbackQuestionRecipientType);
newQuestion.recipientType = FeedbackParticipantType.valueOf(feedbackQuestionRecipientType);
String feedbackQuestionNumber = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, feedbackQuestionNumber);
newQuestion.questionNumber = Integer.parseInt(feedbackQuestionNumber);
Assumption.assertTrue("Invalid question number", newQuestion.questionNumber >= 1);
String numberOfEntityTypes = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, numberOfEntityTypes);
if ("custom".equals(numberOfEntityTypes) && (newQuestion.recipientType == FeedbackParticipantType.STUDENTS || newQuestion.recipientType == FeedbackParticipantType.TEAMS)) {
String numberOfEntities = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, numberOfEntities);
newQuestion.numberOfEntitiesToGiveFeedbackTo = Integer.parseInt(numberOfEntities);
} else {
newQuestion.numberOfEntitiesToGiveFeedbackTo = Const.MAX_POSSIBLE_RECIPIENTS;
}
newQuestion.showResponsesTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO));
newQuestion.showGiverNameTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO));
newQuestion.showRecipientNameTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO));
String questionType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TYPE);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_TYPE, questionType);
questionType = FeedbackQuestionType.standardizeIfConstSum(questionType);
newQuestion.questionType = FeedbackQuestionType.valueOf(questionType);
FeedbackQuestionDetails questionDetails = FeedbackQuestionDetails.createQuestionDetails(requestParameters, newQuestion.questionType);
newQuestion.setQuestionDetails(questionDetails);
String questionDescription = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION);
newQuestion.setQuestionDescription(new Text(questionDescription));
return newQuestion;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes 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;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionCopyPageAction 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);
FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(feedbackSessionName, courseId);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), feedbackSession, false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
List<FeedbackQuestionAttributes> copiableQuestions = null;
copiableQuestions = logic.getCopiableFeedbackQuestionsForInstructor(account.googleId);
InstructorFeedbackQuestionCopyPageData data = new InstructorFeedbackQuestionCopyPageData(account, sessionToken, copiableQuestions);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_QUESTION_COPY_MODAL, data);
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionEditAction method extractFeedbackQuestionData.
private FeedbackQuestionAttributes extractFeedbackQuestionData() {
FeedbackQuestionAttributes newQuestion = new FeedbackQuestionAttributes();
newQuestion.setId(getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID));
newQuestion.courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
newQuestion.feedbackSessionName = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
// TODO thoroughly investigate when and why these parameters can be null
// and check all possibilities in the tests
// should only be null when deleting. might be good to separate the delete action from this class
// When editing, usually the following fields are not null. If they are null somehow(edit from browser),
// Then the field will not update and take on its old value.
// When deleting, the following fields are null.
// numofrecipients
// questiontext
// numofrecipientstype
// recipienttype
// receiverLeaderCheckbox
// givertype
// Can be null
String giverType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE);
if (giverType != null) {
newQuestion.giverType = FeedbackParticipantType.valueOf(giverType);
}
// Can be null
String recipientType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE);
if (recipientType != null) {
newQuestion.recipientType = FeedbackParticipantType.valueOf(recipientType);
}
String questionNumber = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER);
newQuestion.questionNumber = Integer.parseInt(questionNumber);
Assumption.assertTrue("Invalid question number", newQuestion.questionNumber >= 1);
// Can be null
String nEntityTypes = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE);
if (numberOfEntitiesIsUserDefined(newQuestion.recipientType, nEntityTypes)) {
String nEntities = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES);
newQuestion.numberOfEntitiesToGiveFeedbackTo = Integer.parseInt(nEntities);
} else {
newQuestion.numberOfEntitiesToGiveFeedbackTo = Const.MAX_POSSIBLE_RECIPIENTS;
}
newQuestion.showResponsesTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO));
newQuestion.showGiverNameTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO));
newQuestion.showRecipientNameTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO));
String questionType = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TYPE);
newQuestion.questionType = FeedbackQuestionType.valueOf(questionType);
// Can be null
String questionText = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TEXT);
if (questionText != null && !questionText.isEmpty()) {
FeedbackQuestionDetails questionDetails = FeedbackQuestionDetails.createQuestionDetails(requestParameters, newQuestion.questionType);
newQuestion.setQuestionDetails(questionDetails);
}
String questionDescription = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION);
newQuestion.setQuestionDescription(new Text(questionDescription));
return newQuestion;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionVisibilityMessageAction method execute.
@Override
protected ActionResult execute() {
FeedbackQuestionAttributes feedbackQuestion = extractFeedbackQuestionData(account.email);
List<String> message = feedbackQuestion.getVisibilityMessage();
InstructorFeedbackQuestionVisibilityMessagePageData data = new InstructorFeedbackQuestionVisibilityMessagePageData(account, sessionToken);
data.visibilityMessage = message;
return createAjaxResult(data);
}
Aggregations