Skip to content

Commit

Permalink
[#12048] Fix getSessionResultAction bugs (#13023)
Browse files Browse the repository at this point in the history
* [#12048] Config prod settings and convenience scripts  for non course migration (#12959)

* Add fields

* Change based on feedback

* Add changes

* Add reverse data migration script for account (#12962)

* Add changes (#12965)

* V9 non course migration fix to check extra SQL accounts (#12966)

* Add changes

* Add isMarked script

* Add patch data migration script for usage stats (#12970)

* Add patch data migration script for usage stats

* Fix hibernate batch query

* Revert log

* Initial commit

* Revert "[#12048] Config prod settings and convenience scripts  for non course migration (#12959)"

This reverts commit 6df39c1.

* Revert "Add reverse data migration script for account (#12962)"

This reverts commit 0509982.

* Revert "V9 non course migration fix to check extra SQL accounts (#12966)"

This reverts commit 611b2cc.

* Revert "Add patch data migration script for usage stats (#12970)"

This reverts commit 239ae85.

* Revert "Add changes (#12965)"

This reverts commit 1292dbe.

* Fix lint

* Retry lint

---------

Co-authored-by: FergusMok <FergusMok1@gmail.com>
Co-authored-by: Zhang Ziqing <69516975+ziqing26@users.noreply.github.com>
Co-authored-by: Wei Qing <48304907+weiquu@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 17, 2024
1 parent 735afbd commit f852286
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
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

0 comments on commit f852286

Please sign in to comment.