ShanghaitechGeekPie/oj-backend

Add new API for users to claim that they are instructors (students)

Closed this issue · 1 comments

Since the employee data given by GAuth only contain faculty members, backend could only create new instructor in database for faculty members, not student TAs. In practice, the homework/programming part of many courses is managed purely by student TAs. When their account are created, they could not create new course/assignment which is a problem that needs the intervention of admins.

A new API for claiming "I'm TA" is proposed as follow.

Location: /user/<str:user_id>/instructor

Supported method:

  • GET: get the instructor associated with this user. The format is the same as what /course/<str:course_id>/instructor/<str:user_id> gives. It will return null with status code 404 when the user has not instructor associated with;
  • POST: claim "I'm TA". Post the enroll_email(same as email) and name of this user into this interface will make the backend create a new instructor object in database for this user.
{
    "uid": "2080083a-382c-11e9-ac7b-029eb86a7f02", // do not need when POST
    "name": "Wei DaTa",
    "enroll_email": "huashuita@shanghaitech.edu.cn"
}

A similar API will also be provided as a fallback for students at /user/<str:user_id>/student in case the data from GAuth is faulty.

The format is the same as what /course/<str:course_id>/students/<str:user_id> gives.

{
    "uid": "2080083a-382c-11e9-ac7b-029eb86a7f02", // do not need when POST
    "name": "Wang Dachui",
    "enroll_email": "wangdch@shanghaitech.edu.cn",
    "nickname": "hammerWang"
}

The newly added student/instructor is linked with no existing courses.

Implemented in 380b541. Close.