CSC/ECE 517 Spring 2023 E2318: Reimplement Participants Controller: Difference between revisions
No edit summary |
No edit summary |
||
Line 154: | Line 154: | ||
'''API method''': POST | '''API method''': POST | ||
'''Parameters''': | '''Parameters''': | ||
{| class="wikitable" style="width: 100%; | {| class="wikitable" style="width: 100%; | ||
Line 169: | Line 168: | ||
'''Response''': | '''Response''': | ||
* '''Success | * '''Success responses''' | ||
When handle change was successful | When handle change was successful | ||
<pre> | <pre> | ||
Line 186: | Line 185: | ||
</pre> | </pre> | ||
* '''Failure | * '''Failure response''' | ||
<pre> | <pre> | ||
{ | { | ||
Line 200: | Line 199: | ||
'''Purpose''': Updates the participant's permissions for an assignment or a course depending on the role | '''Purpose''': Updates the participant's permissions for an assignment or a course depending on the role | ||
'''Description''': | '''Description''': This endpoint allows the user to change the permissions for a given <code>Participant</code>. The appropriate permissions for any participant are <code>[can_submit, can_review, can_take_quiz]</code>. A <code>Participant</code> is one who is already enrolled in an assignment or a course. A success response renders a JSON with the updated participant details and permissions. | ||
'''Path''': <code>/participants/update_authorizations/:id/:authorization</code> | '''Path''': <code>/participants/update_authorizations/:id/:authorization</code> | ||
Line 207: | Line 206: | ||
'''Parameters''': | '''Parameters''': | ||
{| class="wikitable" style="width: 100%; | |||
! # !! Parameter !! Expected Value | |||
|- | |||
|1 | |||
|<code>id</code> | |||
|The unique identifier for a <code>Participant</code> | |||
|- | |||
|2 | |||
|<code>authorization</code> | |||
|A list of permissions being requested for the participant | |||
|- | |||
|3 | |||
|<code>can_submit</code> | |||
|A value for whether the participant can make submissions or not. | |||
|- | |||
|4 | |||
|<code>can_review</code> | |||
|A value for whether the participant can create reviews or not. | |||
|- | |||
|5 | |||
|<code>can_take_quiz</code> | |||
|A value for whether the participant can take quizzes or not. | |||
|} | |||
'''Response''': | '''Response''': | ||
* '''Success response''' | |||
<pre> | |||
{ | |||
"participant": participant, | |||
} | |||
status: :ok | |||
</pre> | |||
* '''Failure response''' | |||
<pre> | |||
{ | |||
error: participant.errors | |||
} | |||
status: :unprocessable_entity | |||
</pre> | |||
'''Changes''': | '''Changes''': | ||
Line 216: | Line 252: | ||
'''Purpose''': Deletes a participant from an assignment or a course | '''Purpose''': Deletes a participant from an assignment or a course | ||
'''Description''': | '''Description''': This endpoint allows the user to delete an existing participant from an assignment or a course. The user is expected to provide the valid participant ID. The participant is only deleted if they are not part of another team for a different assignment/course. This is to ensure that a participant enrolled in two different teams is not deleted from the list of participants. Deletion is only possible if the participant is only enrolled in only one team. A success response renders a JSON with a confirmation of the deletion. | ||
'''Path''': <code>/participants/:id</code> | '''Path''': <code>/participants/:id</code> | ||
Line 224: | Line 259: | ||
'''Parameters''': | '''Parameters''': | ||
{| class="wikitable" style="width: 100%; | |||
! # !! Parameter !! Expected Value | |||
|- | |||
|1 | |||
|<code>id</code> | |||
|The unique identifier for a <code>Participant</code> | |||
|} | |||
'''Response''': | '''Response''': | ||
* '''Success response''' | |||
<pre> | |||
{ | |||
message: "#{participant.user.name} was successfully removed as a participant" | |||
} | |||
status: :ok | |||
</pre> | |||
* '''Failure responses''' | |||
When the participant is on another team | |||
<pre> | |||
{ | |||
error: "This participant is on a team" | |||
} | |||
status: :unprocessable_entity | |||
</pre> | |||
<pre> | |||
{ | |||
error: "Failed to remove participant" | |||
} | |||
status: :unprocessable_entity | |||
</pre> | |||
'''Changes''': | '''Changes''': | ||
Line 240: | Line 305: | ||
'''Parameters''': | '''Parameters''': | ||
{| class="wikitable" style="width: 100%; | |||
! # !! Parameter !! Expected Value | |||
|- | |||
|1 | |||
|<code>id</code> | |||
|The unique identifier for an <code>Assignment</code> | |||
|} | |||
'''Response''': | '''Response''': | ||
Line 256: | Line 328: | ||
'''Parameters''': | '''Parameters''': | ||
{| class="wikitable" style="width: 100%; | |||
! # !! Parameter !! Expected Value | |||
|- | |||
|1 | |||
|<code>id</code> | |||
|The unique identifier for an <code>Assignment</code> | |||
|} | |||
'''Response''': | '''Response''': |
Revision as of 02:49, 23 March 2023
Introduction
Expertiza is an Open Source Rails application which is used by instructors and students for creating assignments and submitting peer reviews. Expertiza allows the instructor to create and customize assignments, create a list of topics the students can sign up for, have students work on teams and also review each other's assignments. Expertiza supports submissions across various document types, including URLs and wiki pages. The Source code of the application can be cloned from Github.
Background
In expertiza, there are three different types of users - normal users (typically students), administrators, super administrators. A normal user can participate in a course or an assignment or both. Courses and assignments are different entities in the system which allow enrollment of users. While a course is an independent entity, an assignment is part of a course.
The participants controller manages the participants across these courses and assignments by providing functionalities like listing all participants, adding a participant to a course or an assignment, updating the authorizations of a participant (can_submit, can_review, can_take_quiz), deleting a participant, inheriting participants from a course to an assignment, bequeath assignment participants to the corresponding course, changing the handle name of a participant in an assignment, and deleting a participant from an assignment.
Implementation
As part of the re-implementation, the objective is to employ an API-first approach while maintaining all the existing functionality in an efficient, robust and simple manner. Specifically for the participants controller, we've added seven different API endpoints to extend the current functionalities while modifying the code to support these APIs. The details for these endpoints can be found below.
# | Endpoint | Description |
---|---|---|
1 | GET /participants/index/:model/:id
|
Returns a list of participants of an assignment or a course |
2 | POST /participants/:model/:id/:authorization
|
Creates a participant in an assignment or a course |
3 | POST /participants/change_handle/:id
|
Updates the participant's handle for an assignment |
4 | POST /participants/update_authorizations/:id/:authorization
|
Updates the participant's permissions for an assignment or a course depending on the role |
5 | DELETE /participants/:id
|
Deletes a participant from an assignment or a course |
6 | GET /participants/inherit/:id
|
Copies existing participants from a course down to its assignment |
7 | GET /participants/bequeath/:id
|
Copies existing participants from an assignment up to its course |
Index
Purpose: Returns a list of participants of an assignment or a course
Description: This endpoint allows the user to request a list of all participants for the provided assignment ID or course ID. A success response renders a JSON with a list of participants that can be parsed by the front-end.
Path: /participants/index/:model/:id
API method: GET
Parameters:
# | Parameter | Expected Value |
---|---|---|
1 | model
|
One of these two strings: ['Assignment', 'Course']
|
2 | id
|
The unique identifier for an assignment or a course depending on the value of :model
|
- Success response
{ "model_object": model_object, "participants": participants, } status: :ok
- Failure response
{ error: "Missing or invalid required parameters" } status: :unprocessable_entity
Changes: <TBD>
Create
Purpose: Creates a participant in an assignment or a course
Description: This endpoint allows the user to create a new participant for the provided assignment ID or course ID. A success response renders a JSON with the participant details. The user is required to provide a valid username as well as the appropriate permissions for the new participant. These permissions are [can_submit, can_review, can_take_quiz]
. Depending on whether the request is for an Assignment
or a Course
, a participant type is determined between an AssignmentParticipant
or a CourseParticipant
and an entry is made into the database accordingly.
Path: /participants/:model/:id/:authorization
API method: POST
Parameters:
# | Parameter | Expected Value |
---|---|---|
1 | model
|
One of these two strings: ['Assignment', 'Course']
|
2 | id
|
The unique identifier for an assignment or a course depending on the value of :model
|
3 | username
|
The unique username of the new participant being requested |
4 | authorization
|
A list of required permissions for the requested new particpant |
Response:
- Success response
{ "participant": participant, } status: :created
- Failure responses
When user does not exist
{ error: "User #{params[:user][:name]} does not exist" } status: :not_found
When participant already exists in the assignment/course
{ error: "Participant #{params[:user][:name]} already exists for this #{params[:model]}" } status: :unprocessable_entity
Changes: <TBD>
Update Handle
Purpose: Updates the participant's handle for an assignment
Description: This endpoint allows the user to change their handle name for a given AssignmentParticipant
. An AssignmentParticipant
is one who is already enrolled in the assignment. A success response renders a JSON with the updated participant details. The user is required to provide a valid and available handle name.
Path: /participants/change_handle/:id
API method: POST
Parameters:
# | Parameter | Expected Value |
---|---|---|
1 | id
|
The unique identifier for an AssignmentParticipant
|
2 | handle
|
A valid, available handle name for the participant |
Response:
- Success responses
When handle change was successful
{ "participant": participant, } status: :ok
When handle is already in use
{ note: "Handle already in use" } status: :ok
- Failure response
{ error: participant.errors } status: :unprocessable_entity
Changes: <TBD>
Update authorizations
Purpose: Updates the participant's permissions for an assignment or a course depending on the role
Description: This endpoint allows the user to change the permissions for a given Participant
. The appropriate permissions for any participant are [can_submit, can_review, can_take_quiz]
. A Participant
is one who is already enrolled in an assignment or a course. A success response renders a JSON with the updated participant details and permissions.
Path: /participants/update_authorizations/:id/:authorization
API method: POST
Parameters:
# | Parameter | Expected Value |
---|---|---|
1 | id
|
The unique identifier for a Participant
|
2 | authorization
|
A list of permissions being requested for the participant |
3 | can_submit
|
A value for whether the participant can make submissions or not. |
4 | can_review
|
A value for whether the participant can create reviews or not. |
5 | can_take_quiz
|
A value for whether the participant can take quizzes or not. |
Response:
- Success response
{ "participant": participant, } status: :ok
- Failure response
{ error: participant.errors } status: :unprocessable_entity
Changes: <TBD>
Delete
Purpose: Deletes a participant from an assignment or a course
Description: This endpoint allows the user to delete an existing participant from an assignment or a course. The user is expected to provide the valid participant ID. The participant is only deleted if they are not part of another team for a different assignment/course. This is to ensure that a participant enrolled in two different teams is not deleted from the list of participants. Deletion is only possible if the participant is only enrolled in only one team. A success response renders a JSON with a confirmation of the deletion.
Path: /participants/:id
API method: DELETE
Parameters:
# | Parameter | Expected Value |
---|---|---|
1 | id
|
The unique identifier for a Participant
|
Response:
- Success response
{ message: "#{participant.user.name} was successfully removed as a participant" } status: :ok
- Failure responses
When the participant is on another team
{ error: "This participant is on a team" } status: :unprocessable_entity
{ error: "Failed to remove participant" } status: :unprocessable_entity
Changes: <TBD>
Inherit
Purpose: Copies existing participants from a course down to its assignment
Description:
Path: /participants/inherit/:id
API method: GET
Parameters:
# | Parameter | Expected Value |
---|---|---|
1 | id
|
The unique identifier for an Assignment
|
Response:
Changes: <TBD>
Bequeath
Purpose: Copies existing participants from an assignment up to its course
Description:
Path: /participants/bequeath/:id
API method: GET
Parameters:
# | Parameter | Expected Value |
---|---|---|
1 | id
|
The unique identifier for an Assignment
|
Response:
Changes: <TBD>
Test Plan
<TBD>
Contributors
- Saksham Pandey (spandey5@ncsu.edu)
- Devashish Vachhani (dvachha@ncsu.edu)
- Karthik K Jayakumar (kkunnum@ncsu.edu)
Mentor: Rucha Kolekar (rbkoleka@ncsu.edu)
Relevant Links
<TBD>