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

[#9494] Consolidate GET course RESTFul API #9512

Merged
merged 12 commits into from Mar 21, 2019

Conversation

ChooJeremy
Copy link
Contributor

@ChooJeremy ChooJeremy commented Feb 27, 2019

Part of #9494

PR Checklist

Outline of Solution

GET /course will only serve the course related portions of the other APIs, and no other parts. To eliminate extra data, I've taken a look at what the UI shows for student and instructor and came up with the following:
GET /course.
If instructor: input courseID, return CourseData for that course.

Ready for peer review.

@ChooJeremy ChooJeremy self-assigned this Feb 27, 2019
@ChooJeremy ChooJeremy force-pushed the course-get branch 4 times, most recently from cb767a1 to 1208a26 Compare February 27, 2019 17:19
Copy link
Contributor

@Adoby7 Adoby7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits

}, (resp: ErrorMessageOutput) => {
this.statusMessageService.showErrorMessage(resp.error.message);
});
this.courseService.getCourse(this.courseId).subscribe((course: Course) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Response DTO here for Course?

assertEquals(courseAttributes.getId(), response.getCourseId());
assertEquals(courseAttributes.getName(), response.getCourseName());
assertEquals(courseAttributes.getTimeZone().getId(), response.getTimeZone());
assertEquals(courseAttributes.getId(), courseData.getCourseId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to change courseAttributes to be expectedCourse

Copy link
Contributor

@rrtheonlyone rrtheonlyone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor stuff 👍

@ChooJeremy
Copy link
Contributor Author

Ready for review

@ChooJeremy ChooJeremy added the s.ToReview The PR is waiting for review(s) label Feb 28, 2019
@junming403
Copy link
Member

If student: no input. output array of CourseData (only ID, name and timeZone provided) - this is based off functionality from GetStudentCourseAction

Where is this part reflected?

Copy link
Member

@junming403 junming403 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, some nits.


loginAsInstructor(instructor1OfCourse1.googleId);

______TS("Not enough parameters");

verifyHttpParameterFailure();

______TS("typical success case");
______TS("typical success case for instructor");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using ____TS(). It's better to separate tests into different sub tests and annotate them with @Test. Since you already did it for one of the function, let's do it for all of them?

@ChooJeremy
Copy link
Contributor Author

If student: no input. output array of CourseData (only ID, name and timeZone provided) - this is based off functionality from GetStudentCourseAction

Where is this part reflected?

That part's functionality has been moved to get /courses, as this API should only return a single course object (instead of multiple, like an array)

@xpdavid xpdavid requested review from junming403 and removed request for xpdavid March 11, 2019 06:34
Copy link
Contributor

@Adoby7 Adoby7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@junming403 junming403 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ChooJeremy
Copy link
Contributor Author

Sorry, it turns out that student support is required in this endpoint after all, from STUDENT_COURSE (GET). It has been updated to support students. The latest 2 commits contains all the changes since the last LGTM, please take a look :)

@ChooJeremy ChooJeremy requested review from junming403 and Adoby7 and removed request for xpdavid March 15, 2019 16:30
Copy link
Contributor

@Adoby7 Adoby7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a note to let you know.


submissionParams = new String[] {
Const.ParamsNames.COURSE_ID, courseAttributes.getId(),
};

verifyOnlyInstructorsOfTheSameCourseCanAccess(submissionParams);
verifyInaccessibleWithoutLogin(submissionParams);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are advised to put this change in "Updated tests to support students" for a better practice of organizing commit messages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it? I kind of disagree... this change is relevant to the change in access control for GetCourseAction, so the test should be updated in the same commit that contains that change?

@ChooJeremy
Copy link
Contributor Author

The build passes, but does not appear to be correctly being reported in the UI here.

@ChooJeremy ChooJeremy requested a review from xpdavid March 18, 2019 07:21
}

if (userInfo.isStudent) {
if (!hasStudentJoinedCourse(courseId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if check is not necessary I think. gateKeeper.verifyAccessible(logic.getStudentForGoogleId(courseId, userInfo.id), course); will do null check.

@ChooJeremy ChooJeremy requested a review from xpdavid March 20, 2019 16:46
Copy link
Contributor

@xpdavid xpdavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/web/services/course.service.ts Outdated Show resolved Hide resolved
Co-Authored-By: ChooJeremy <ChooJeremy@Ymail.com>
@ChooJeremy ChooJeremy added s.FinalReview The PR is ready for final review and removed s.ToReview The PR is waiting for review(s) labels Mar 21, 2019
statusMessageService: StatusMessageService,
navigationService: NavigationService,
feedbackSessionsService: FeedbackSessionsService,
feedbackQuestionsService: FeedbackQuestionsService,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not your fault, but all of the above fields should be private. Let's fix it while we have the chance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... making this change causes:

ERROR in src/web/app/pages-instructor/instructor-session-edit-page/instructor-session-edit-page.component.ts(60,14): error TS2415: Class 'InstructorSessionEditPageComponent' incorrectly extends base class 'InstructorSessionBasePageComponent'.
  Property 'feedbackQuestionsService' is private in type 'InstructorSessionEditPageComponent' but not in type 'InstructorSessionBasePageComponent'.

for each of the properties changing to private. If we change the access modifier of the base class, we'll need to modify the access modifier for all the other classes that extend from it as well (instructor sessions page component etc.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps. Merged but not seen this comment :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's protected; still not the default which is public

@wkurniawan07 wkurniawan07 added s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging and removed s.FinalReview The PR is ready for final review labels Mar 21, 2019
@xpdavid xpdavid merged commit dad85f3 into TEAMMATES:master Mar 21, 2019
@xpdavid xpdavid added this to Ongoing in Front-end and RESTful back-end Migration via automation Mar 21, 2019
@wkurniawan07 wkurniawan07 added this to the V7.0.0-beta.0 milestone Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants