Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
Change method name, method visibility, and method parameter name for getNumOfChoicesForMsq in FeedbackMsqQuestionDetails.
Removed the method getNumOfMsqChoices().
Replaced getRequestParamValue with getNonNullRequestParamValue for editQuestion() method in InstructorFeedbackQuestionEditAction.
  • Loading branch information
Haozhe321 committed Apr 14, 2018
1 parent 3009d01 commit c3f2928
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,22 +328,22 @@ public String getQuestionWithoutExistingResponseSubmissionFormHtml(
isMinSelectableChoicesEnabled ? Integer.toString(minSelectableChoices) : "-1");
}

private int numOfChoicesForMsq(String courseId, FeedbackParticipantType generatedOption) {
if (generatedOption == FeedbackParticipantType.NONE) {
public int getNumOfChoicesForMsq(String courseId, FeedbackParticipantType generateOptionsFor) {
if (generateOptionsFor == FeedbackParticipantType.NONE) {
return msqChoices.size();
} else if (generatedOption == FeedbackParticipantType.STUDENTS
|| generatedOption == FeedbackParticipantType.STUDENTS_EXCLUDING_SELF) {
} else if (generateOptionsFor == FeedbackParticipantType.STUDENTS
|| generateOptionsFor == FeedbackParticipantType.STUDENTS_EXCLUDING_SELF) {
List<StudentAttributes> studentList = StudentsLogic.inst().getStudentsForCourse(courseId);
int sizeOfStudentlist = studentList.size();

return generatedOption == FeedbackParticipantType.STUDENTS ? sizeOfStudentlist : sizeOfStudentlist - 1;
} else if (generatedOption == FeedbackParticipantType.TEAMS
|| generatedOption == FeedbackParticipantType.TEAMS_EXCLUDING_SELF) {
return generateOptionsFor == FeedbackParticipantType.STUDENTS ? sizeOfStudentlist : sizeOfStudentlist - 1;
} else if (generateOptionsFor == FeedbackParticipantType.TEAMS
|| generateOptionsFor == FeedbackParticipantType.TEAMS_EXCLUDING_SELF) {
try {
List<TeamDetailsBundle> teamList = CoursesLogic.inst().getTeamsForCourse(courseId);
int sizeOfTeamlist = teamList.size();

return generatedOption == FeedbackParticipantType.TEAMS ? sizeOfTeamlist : sizeOfTeamlist - 1;
return generateOptionsFor == FeedbackParticipantType.TEAMS ? sizeOfTeamlist : sizeOfTeamlist - 1;
} catch (EntityDoesNotExistException e) {
Assumption.fail("Course disappeared");
}
Expand Down Expand Up @@ -611,7 +611,7 @@ public List<String> validateQuestionDetails(String courseId) {
boolean isMinSelectableChoicesEnabled = minSelectableChoices != Integer.MIN_VALUE;

if (isMaxSelectableChoicesEnabled) {
int numOfMsqChoicesForGeneratedOptions = numOfChoicesForMsq(courseId, generateOptionsFor);
int numOfMsqChoicesForGeneratedOptions = getNumOfChoicesForMsq(courseId, generateOptionsFor);
if (numOfMsqChoicesForGeneratedOptions < maxSelectableChoices) {
errors.add(Const.FeedbackQuestion.MSQ_ERROR_MAX_SELECTABLE_EXCEEDED_TOTAL);
} else if (maxSelectableChoices < 2) {
Expand Down Expand Up @@ -673,10 +673,6 @@ public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedba
return "";
}

public int getNumOfMsqChoices() {
return msqChoices.size();
}

public List<String> getMsqChoices() {
return msqChoices;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void editQuestion(FeedbackQuestionAttributes updatedQuestion) throws Inv
isError = true;
}

String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
FeedbackQuestionDetails updatedQuestionDetails = updatedQuestion.getQuestionDetails();
List<String> questionDetailsErrors = updatedQuestionDetails.validateQuestionDetails(courseId);
List<StatusMessage> questionDetailsErrorsMessages = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ public void testExecuteAndPostProcessMsq() {
Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "MSQ",
Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "What do you like best about the class?",
Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details",
Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, Integer.toString(msqDetails.getNumOfMsqChoices()),
Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED,
Integer.toString(msqDetails.getNumOfChoicesForMsq(fs.getCourseId(), FeedbackParticipantType.NONE)),
Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-0", msqDetails.getMsqChoices().get(0),
Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-1", msqDetails.getMsqChoices().get(1),
Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max",
Expand Down

0 comments on commit c3f2928

Please sign in to comment.