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

[#9564] Consolidate PUT /students RESTFul API #9647

Merged
merged 6 commits into from Apr 21, 2019

Conversation

Adoby7
Copy link
Contributor

@Adoby7 Adoby7 commented Apr 5, 2019

Part of #9564

Outline of Solution

  • Use request DTO
  • Rename the old endpoint to PUT /students
  • Backend only returns a list of successful enrolled students. Logic of classifying new students, modified students, unchanged students are delegated to frontend.

@Adoby7 Adoby7 force-pushed the enroll_student branch 8 times, most recently from 664ddda to 87410f0 Compare April 9, 2019 03:35
@Adoby7 Adoby7 marked this pull request as ready for review April 9, 2019 03:36
@Adoby7 Adoby7 force-pushed the enroll_student branch 2 times, most recently from 8964556 to d1b7c95 Compare April 9, 2019 04:55
@Adoby7 Adoby7 added the s.ToReview The PR is waiting for review(s) label Apr 9, 2019
@Adoby7 Adoby7 requested a review from tanhengyeow April 9, 2019 08:01
@Adoby7 Adoby7 added this to Ongoing in Front-end and RESTful back-end Migration via automation Apr 9, 2019
@Adoby7 Adoby7 force-pushed the enroll_student branch 4 times, most recently from bcf8c24 to 9d6d0f8 Compare April 12, 2019 05:14
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.

Nice job! Let's learn TypeScript in one week.

});
}

private propagateEnrollResultPanelList(existingStudents: Student[], enrolledStudents: Student[],
Copy link
Contributor

Choose a reason for hiding this comment

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

populate is a better word :)

This comment was marked as outdated.


private propagateEnrollResultPanelList(existingStudents: Student[], enrolledStudents: Student[],
enrollRequests: StudentEnrollRequest[]): EnrollResultPanel[] {
const updateStatus: { [key: string]: number } = {
Copy link
Contributor

@xpdavid xpdavid Apr 12, 2019

Choose a reason for hiding this comment

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

Let's define this as an enum above

color: 'danger',
});
const panelClass: { [key: number]: string } = {
0: 'bg-primary',
Copy link
Contributor

Choose a reason for hiding this comment

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

Expose the enum to the HTML file and put the logic of choosing different CSS class in the HTML file.

@Adoby7 Adoby7 force-pushed the enroll_student branch 2 times, most recently from 66fe3da to 541bbd4 Compare April 13, 2019 14:48
@Adoby7
Copy link
Contributor Author

Adoby7 commented Apr 20, 2019

@tanhengyeow I have added some general error message in the prompted window. Probably this would help. If we want the detailed error message, probably it needs a separate PR to do

Copy link
Member

@tanhengyeow tanhengyeow left a comment

Choose a reason for hiding this comment

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

I think this is acceptable for now. Good job on this PR!

My original concern was that the functionalities (e.g. showing which row has specific errors) should be retained from v6 if we don't have a solution now that improves upon it. But yea, I can file a follow up issue for this since this PR is mostly about consolidating the current API to be RESTful.

Logic of classifying new students, modified students, unchanged students are delegated to frontend.

In addition, the API response contains students who are enrolled successfully, and I could not find a way to return both correct response and error response simultaneously.

Yes that's right but the API should still return a format that the frontend is able to do further work on it for example:

Request:

StudentEnrollRequest.studentEnrollRequests: [{
 name: ...
 email: ...
 },
...
]

Response:

[
    { "status": NEW_ENROLL_SUCCESS, "message": "" },
    { "status": UNMODIFIED_SUCCESS, "message": "" },
    { "status": FAILURE, "message": "Missing email" },
]

You are very welcome to work on the follow-up issue even after CS3282 😄

@tanhengyeow
Copy link
Member

@Adoby7 Reminder to fix the lint error :)

@Adoby7 Adoby7 added s.FinalReview The PR is ready for final review and removed s.ToReview The PR is waiting for review(s) labels Apr 20, 2019
@Adoby7 Adoby7 requested a review from damithc April 21, 2019 05:07
Copy link
Contributor

@damithc damithc left a comment

Choose a reason for hiding this comment

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

Just a query. Can merge without further review from me.

@@ -56,7 +56,7 @@

public static final String ACTION_RESULT_FAILURE = "Servlet Action Failure";

public static final int SIZE_LIMIT_PER_ENROLLMENT = 150;
public static final int SIZE_LIMIT_PER_ENROLLMENT = 100;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this changed to 100? I think the 150 was intentional, to allow courses with just over 100 students to be enrolled in one shot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
The enroll pages says maximum 100 students in one enrollment. Do we change it back?

Copy link
Contributor

Choose a reason for hiding this comment

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

It was a hidden feature. The advertised limit remains 100. Change it back to 150 and put a comment to explain why it is 150?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, do we show the users maximum enroll size is 100, but if they try to enroll students slightly more than 100, we still allow it?

Copy link
Member

Choose a reason for hiding this comment

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

@damithc the bigger question is, why does it become a "hidden" feature?

Copy link
Contributor

Choose a reason for hiding this comment

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

100 is a good round number and easy for users too e.g., when dividing a spreadsheet into batches.
However, it turns out that it is fairly common for instructors to have just over 100 students and also fairly common for them to not see the limit and try to enroll all at once. Allowing a buffer of 50 more allow such requests to go through -> reduces annoyance to users and saves us some requests too. This is a bit similar to having a hidden buffer for submission deadlines.
Having said that, I just realized this hidden feature is no longer usable because the spreadsheet limits the number of rows to 100. Which means we can go back to 100. Just make sure there is no off-by-one error. i.e., we support 100, not 99, students at one go (I remember having a bug like that once)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@Adoby7 Adoby7 force-pushed the enroll_student branch 2 times, most recently from 86c558e to 39d3de7 Compare April 21, 2019 05:59
Copy link
Member

@wkurniawan07 wkurniawan07 left a comment

Choose a reason for hiding this comment

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

Excellent job in not just consolidating the API but also improving the enrollment process!

@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 Apr 21, 2019
# Conflicts:
#	src/e2e/java/teammates/e2e/cases/lnp/InstructorStudentEnrollmentLNPTest.java
@Adoby7
Copy link
Contributor Author

Adoby7 commented Apr 21, 2019

Hi @wkurniawan07, could you look at this PR again, as there were some conflicts after your approval. Thank you

@amrut-prabhu
Copy link
Contributor

@Adoby7 If you're referring to the conflicts in commit 7318cd9, the changes look fine to me

@Adoby7 Adoby7 merged commit 5cb6356 into TEAMMATES:master Apr 21, 2019
Front-end and RESTful back-end Migration automation moved this from Ongoing to Done Apr 21, 2019
@Adoby7 Adoby7 deleted the enroll_student branch April 21, 2019 12:43
rrtheonlyone pushed a commit to rrtheonlyone/teammates that referenced this pull request Apr 21, 2019
* rename the old endpoint to /students

* rewrite the old endpoint

* remove deprecated stuffs

* add testing on new endpoint
@wkurniawan07 wkurniawan07 added this to the V7.0.0-beta.0 milestone Mar 15, 2020
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

10 participants