Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#12048] Fix getSessionResultAction bugs #13023

Merged
merged 15 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/it/java/teammates/it/ui/webapi/GetSessionResultsActionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import teammates.common.util.HibernateUtil;
import teammates.common.util.JsonUtils;
import teammates.storage.sqlentity.Course;
import teammates.storage.sqlentity.FeedbackQuestion;
import teammates.storage.sqlentity.FeedbackSession;
import teammates.storage.sqlentity.Instructor;
import teammates.storage.sqlentity.Section;
Expand Down Expand Up @@ -153,6 +154,32 @@ protected void testExecute() {
student);

assertTrue(isSessionResultsDataEqual(expectedResults, output));

______TS("Typical: Student accesses results of their course by questionId");

loginAsStudent(student.getGoogleId());

FeedbackQuestion question = typicalBundle.feedbackQuestions.get("qn1InSession1InCourse1");

submissionParams = new String[] {
Const.ParamsNames.FEEDBACK_SESSION_NAME, accessibleFeedbackSession.getName(),
Const.ParamsNames.COURSE_ID, accessibleFeedbackSession.getCourse().getId(),
Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId().toString(),
Const.ParamsNames.INTENT, Intent.STUDENT_RESULT.name(),
};

a = getAction(submissionParams);
r = getJsonResult(a);

output = (SessionResultsData) r.getOutput();
expectedResults = SessionResultsData.initForStudent(
logic.getSessionResultsForUser(accessibleFeedbackSession,
accessibleFeedbackSession.getCourse().getId(),
student.getEmail(),
false, question.getId(), false),
student);

assertTrue(isSessionResultsDataEqual(expectedResults, output));
}

@Override
Expand Down Expand Up @@ -231,7 +258,7 @@ private boolean isSessionResultsDataEqual(SessionResultsData self, SessionResult
}

private boolean isQuestionOutputEqual(SessionResultsData.QuestionOutput self,
SessionResultsData.QuestionOutput other) {
SessionResultsData.QuestionOutput other) {
if (!JsonUtils.toJson(self.getFeedbackQuestion()).equals(JsonUtils.toJson(other.getFeedbackQuestion()))
|| !self.getQuestionStatistics().equals(other.getQuestionStatistics())
|| self.getHasResponseButNotVisibleForPreview() != other.getHasResponseButNotVisibleForPreview()
Expand All @@ -254,7 +281,7 @@ private boolean isQuestionOutputEqual(SessionResultsData.QuestionOutput self,
}

private boolean isResponseOutputEqual(SessionResultsData.ResponseOutput self,
SessionResultsData.ResponseOutput other) {
SessionResultsData.ResponseOutput other) {
return self.getGiver().equals(other.getGiver())
&& self.getGiverTeam().equals(other.getGiverTeam())
&& self.getGiverSection().equals(other.getGiverSection())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import teammates.storage.sqlentity.FeedbackSession;
import teammates.storage.sqlentity.Instructor;
import teammates.storage.sqlentity.Student;
import teammates.storage.sqlentity.Team;
import teammates.ui.output.SessionResultsData;
import teammates.ui.request.Intent;

Expand Down Expand Up @@ -126,7 +127,7 @@ public JsonResult execute() {
if (isCourseMigrated(courseId)) {
if (questionId != null) {
UUID questionUuid = getUuidRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID);
executeWithSql(courseId, feedbackSessionName, questionUuid,
return executeWithSql(courseId, feedbackSessionName, questionUuid,
selectedSection, fetchType, intent, isPreviewResults);
}
return executeWithSql(courseId, feedbackSessionName, null, selectedSection,
Expand Down Expand Up @@ -195,14 +196,14 @@ private JsonResult executeWithSql(
return new JsonResult(SessionResultsData.initForInstructor(bundle));
case INSTRUCTOR_RESULT:
// Section name filter is not applicable here
instructor = getPossiblyUnregisteredSqlInstructor(courseId);
instructor = getSqlInstructorOfCourseFromRequest(courseId);

bundle = sqlLogic.getSessionResultsForUser(feedbackSession, courseId, instructor.getEmail(),
true, questionUuid, isPreviewResults);

// Build a fake student object, as the results will be displayed as if they are displayed to a student
student = new Student(instructor.getCourse(), instructor.getName(), instructor.getEmail(), "");
student.setTeam(instructor.getTeam());
student.setTeam(new Team(null, Const.USER_TEAM_FOR_INSTRUCTOR));

return new JsonResult(SessionResultsData.initForStudent(bundle, student));
case STUDENT_RESULT:
Expand Down
Loading