Skip to content

Commit

Permalink
Merge branch 'TEAMMATES:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajdeep1311 committed Jul 23, 2023
2 parents 67d02f7 + f029bb2 commit 5af7433
Show file tree
Hide file tree
Showing 44 changed files with 1,396 additions and 705 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,6 @@ private List<String> getErrors(List<Integer> givenPoints, int totalPoints) {
return errors;
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return false;
}

@Override
public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedbackQuestionAttributes) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,6 @@ public boolean isInstructorCommentsOnResponsesAllowed() {
return false;
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return false;
}

public boolean isZeroSum() {
return isZeroSum;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ public List<String> validateResponsesDetails(List<FeedbackResponseDetails> respo
return errors;
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return true;
}

@Override
public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedbackQuestionAttributes) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,6 @@ public List<String> validateResponsesDetails(List<FeedbackResponseDetails> respo
return errors;
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return true;
}

@Override
public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedbackQuestionAttributes) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ public List<String> validateResponsesDetails(List<FeedbackResponseDetails> respo
return errors;
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return false;
}

@Override
public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedbackQuestionAttributes) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ public boolean isInstructorCommentsOnResponsesAllowed() {
return true;
}

/**
* Checks whether participant comments are allowed for the question.
*/
public abstract boolean isFeedbackParticipantCommentsOnResponsesAllowed();

/**
* Checks whether missing responses should be generated.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ public List<String> validateResponsesDetails(List<FeedbackResponseDetails> respo
return errors;
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return false;
}

@Override
public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedbackQuestionAttributes) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ public List<String> validateResponsesDetails(List<FeedbackResponseDetails> respo
return errors;
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return false;
}

@Override
public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedbackQuestionAttributes) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ public List<String> validateResponsesDetails(List<FeedbackResponseDetails> respo
return errors;
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return false;
}

@Override
public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedbackQuestionAttributes) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public List<String> validateResponsesDetails(List<FeedbackResponseDetails> respo
return new ArrayList<>();
}

@Override
public boolean isFeedbackParticipantCommentsOnResponsesAllowed() {
return false;
}

@Override
public String validateGiverRecipientVisibility(FeedbackQuestionAttributes feedbackQuestionAttributes) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ abstract class BasicCommentSubmissionAction extends BasicFeedbackSubmissionActio

static final String FEEDBACK_RESPONSE_COMMENT_EMPTY = "Comment cannot be empty";

/**
* Validates the questionType of the corresponding question.
*/
void validQuestionForCommentInSubmission(FeedbackQuestionAttributes feedbackQuestion) {
if (!feedbackQuestion.getQuestionDetailsCopy().isFeedbackParticipantCommentsOnResponsesAllowed()) {
throw new InvalidHttpParameterException("Invalid question type for comment in submission");
}
}

/**
* Validates comment doesn't exist of corresponding response.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException {
verifyNotPreview();

checkAccessControlForStudentFeedbackSubmission(studentAttributes, session);

validQuestionForCommentInSubmission(question);
verifyResponseOwnerShipForStudent(studentAttributes, response, question);
break;
case INSTRUCTOR_SUBMISSION:
Expand All @@ -79,8 +77,6 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException {
verifyNotPreview();

checkAccessControlForInstructorFeedbackSubmission(instructorAsFeedbackParticipant, session);

validQuestionForCommentInSubmission(question);
verifyResponseOwnerShipForInstructor(instructorAsFeedbackParticipant, response);
break;
case INSTRUCTOR_RESULT:
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/teammates/ui/webapi/GetFeedbackResponsesAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import teammates.common.datatransfer.attributes.FeedbackSessionAttributes;
import teammates.common.datatransfer.attributes.InstructorAttributes;
import teammates.common.datatransfer.attributes.StudentAttributes;
import teammates.common.datatransfer.questions.FeedbackQuestionType;
import teammates.common.util.Const;
import teammates.ui.output.FeedbackResponseCommentData;
import teammates.ui.output.FeedbackResponseData;
Expand All @@ -33,8 +32,8 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException {
if (feedbackQuestion == null) {
throw new EntityNotFoundException("The feedback question does not exist.");
}
FeedbackSessionAttributes feedbackSession =
getNonNullFeedbackSession(feedbackQuestion.getFeedbackSessionName(), feedbackQuestion.getCourseId());
FeedbackSessionAttributes feedbackSession = getNonNullFeedbackSession(feedbackQuestion.getFeedbackSessionName(),
feedbackQuestion.getCourseId());

verifyInstructorCanSeeQuestionIfInModeration(feedbackQuestion);
verifyNotPreview();
Expand All @@ -48,7 +47,8 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException {
break;
case INSTRUCTOR_SUBMISSION:
gateKeeper.verifyAnswerableForInstructor(feedbackQuestion);
InstructorAttributes instructorAttributes = getInstructorOfCourseFromRequest(feedbackSession.getCourseId());
InstructorAttributes instructorAttributes = getInstructorOfCourseFromRequest(
feedbackSession.getCourseId());
checkAccessControlForInstructorFeedbackSubmission(instructorAttributes, feedbackSession);
break;
default:
Expand All @@ -66,27 +66,27 @@ public JsonResult execute() {
switch (intent) {
case STUDENT_SUBMISSION:
StudentAttributes studentAttributes = getStudentOfCourseFromRequest(questionAttributes.getCourseId());
responses = logic.getFeedbackResponsesFromStudentOrTeamForQuestion(questionAttributes, studentAttributes);
responses = logic.getFeedbackResponsesFromStudentOrTeamForQuestion(questionAttributes,
studentAttributes);
break;
case INSTRUCTOR_SUBMISSION:
InstructorAttributes instructorAttributes = getInstructorOfCourseFromRequest(questionAttributes.getCourseId());
responses = logic.getFeedbackResponsesFromInstructorForQuestion(questionAttributes, instructorAttributes);
InstructorAttributes instructorAttributes = getInstructorOfCourseFromRequest(
questionAttributes.getCourseId());
responses = logic.getFeedbackResponsesFromInstructorForQuestion(questionAttributes,
instructorAttributes);
break;
default:
throw new InvalidHttpParameterException("Unknown intent " + intent);
}

List<FeedbackResponseData> responsesData = new LinkedList<>();

responses.forEach(response -> {
FeedbackResponseData data = new FeedbackResponseData(response);
if (questionAttributes.getQuestionType() == FeedbackQuestionType.MCQ
|| questionAttributes.getQuestionType() == FeedbackQuestionType.MSQ) {
// Only MCQ and MSQ questions can have participant comment
FeedbackResponseCommentAttributes comment =
logic.getFeedbackResponseCommentForResponseFromParticipant(response.getId());
if (comment != null) {
data.setGiverComment(new FeedbackResponseCommentData(comment));
}
FeedbackResponseCommentAttributes comment = logic
.getFeedbackResponseCommentForResponseFromParticipant(response.getId());
if (comment != null) {
data.setGiverComment(new FeedbackResponseCommentData(comment));
}
responsesData.add(data);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,6 @@ public void testShouldChangesRequireResponseDeletion_sameDistributePointsFor_sho
assertFalse(feedbackQuestionDetails.shouldChangesRequireResponseDeletion(newFeedbackQuestionDetails));
}

@Test
public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnTrue() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackConstantSumQuestionDetails();
assertTrue(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackConstantSumQuestionDetails();
assertFalse(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}

@Test
public void testValidateQuestionDetails_invalidMaxMinOptions_errorReturned() {
FeedbackConstantSumQuestionDetails feedbackQuestionDetails =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ public class FeedbackContributionQuestionDetailsTest extends BaseTestCase {
static final List<Integer> INVALID_CONTRIBUTION_RESPONSE_ANSWERS =
new ArrayList<>(Arrays.asList(-983, -1, 1, 4, 19, 51, 101, 199, 201, 1000));

@Test
public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackContributionQuestionDetails();
assertFalse(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackContributionQuestionDetails();
assertFalse(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}

@Test
public void testIsIndividualResponsesShownToStudents_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackContributionQuestionDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnTrue() {
assertTrue(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnTrue() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackMcqQuestionDetails();
assertTrue(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}

@Test
public void testShouldChangesRequireResponseDeletion_differentMqcChoices_shouldReturnTrue() {
FeedbackMcqQuestionDetails mcqDetails = new FeedbackMcqQuestionDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,6 @@ public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnTrue() {
assertTrue(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnTrue() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackMsqQuestionDetails();
assertTrue(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}

@Test
public void testShouldChangesRequireResponseDeletion_differentMsqChoices_shouldReturnTrue() {
FeedbackMsqQuestionDetails msqDetails = new FeedbackMsqQuestionDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnTrue() {
assertTrue(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackNumericalScaleQuestionDetails();
assertFalse(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}

@Test
public void tesValidateResponseDetails() {
FeedbackNumericalScaleQuestionDetails numScaleQuestion = new FeedbackNumericalScaleQuestionDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnTrue() {
assertTrue(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackRankOptionsQuestionDetails();
assertFalse(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}

@Test
public void testValidateQuestionDetails_emptyOption_errorReturned() {
FeedbackRankOptionsQuestionDetails feedbackQuestionDetails = new FeedbackRankOptionsQuestionDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnTrue() {
assertTrue(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackRankRecipientsQuestionDetails();
assertFalse(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}

@Test
public void testValidateGiverRecipientVisibility() {
FeedbackRankRecipientsQuestionDetails feedbackRankRecipientsQuestionDetails =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,4 @@ public void testValidateResponseDetails_invalidAnswer_shouldReturnNonEmptyErrorL
responseDetails.setAnswer(Arrays.asList(0, null, 0));
assertFalse(rubricQuestionDetails.validateResponsesDetails(Collections.singletonList(responseDetails), 0).isEmpty());
}

@Test
public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnTrue() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackRubricQuestionDetails();
assertTrue(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackRubricQuestionDetails();
assertFalse(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,6 @@ public void testValidateGiverRecipientVisibility_shouldReturnEmptyString() {
assertEquals("", feedbackTextQuestionDetails.validateGiverRecipientVisibility(feedbackQuestionAttributes));
}

@Test
public void testIsInstructorCommentsOnResponsesAllowed_shouldReturnTrue() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackTextQuestionDetails();
assertTrue(feedbackQuestionDetails.isInstructorCommentsOnResponsesAllowed());
}

@Test
public void testIsFeedbackParticipantCommentsOnResponsesAllowed_shouldReturnFalse() {
FeedbackQuestionDetails feedbackQuestionDetails = new FeedbackTextQuestionDetails();
assertFalse(feedbackQuestionDetails.isFeedbackParticipantCommentsOnResponsesAllowed());
}

@Test
public void testIsRichTextOptionTrueByDefault_shouldReturnTrue() {
FeedbackTextQuestionDetails feedbackQuestionDetails = new FeedbackTextQuestionDetails();
Expand Down
Loading

0 comments on commit 5af7433

Please sign in to comment.