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
Conversation
664ddda
to
87410f0
Compare
8964556
to
d1b7c95
Compare
bcf8c24
to
9d6d0f8
Compare
There was a problem hiding this 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.
src/main/java/teammates/ui/webapi/action/EnrollStudentsAction.java
Outdated
Show resolved
Hide resolved
src/main/java/teammates/ui/webapi/request/StudentsEnrollRequest.java
Outdated
Show resolved
Hide resolved
src/main/java/teammates/ui/webapi/request/StudentsEnrollRequest.java
Outdated
Show resolved
Hide resolved
}); | ||
} | ||
|
||
private propagateEnrollResultPanelList(existingStudents: Student[], enrolledStudents: Student[], |
There was a problem hiding this comment.
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.
This comment was marked as outdated.
Sorry, something went wrong.
|
||
private propagateEnrollResultPanelList(existingStudents: Student[], enrolledStudents: Student[], | ||
enrollRequests: StudentEnrollRequest[]): EnrollResultPanel[] { | ||
const updateStatus: { [key: string]: number } = { |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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.
...pp/pages-instructor/instructor-course-enroll-page/instructor-course-enroll-page.component.ts
Outdated
Show resolved
Hide resolved
66fe3da
to
541bbd4
Compare
@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 |
There was a problem hiding this 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 😄
@Adoby7 Reminder to fix the lint error :) |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
86c558e
to
39d3de7
Compare
There was a problem hiding this 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!
# Conflicts: # src/e2e/java/teammates/e2e/cases/lnp/InstructorStudentEnrollmentLNPTest.java
Hi @wkurniawan07, could you look at this PR again, as there were some conflicts after your approval. Thank you |
@Adoby7 If you're referring to the conflicts in commit 7318cd9, the changes look fine to me |
* rename the old endpoint to /students * rewrite the old endpoint * remove deprecated stuffs * add testing on new endpoint
Part of #9564
Outline of Solution
PUT /students