From f85080abc11119ec6ed69bcdb59e6be858dc1a35 Mon Sep 17 00:00:00 2001 From: mohammadmehrab <108484416+mohammadmehrab@users.noreply.github.com> Date: Mon, 25 Nov 2024 19:43:56 -0600 Subject: [PATCH] Added professors aggregate endpoint to course endpoint --- api/controllers/course.go | 125 ++++++++++++ api/docs/docs.go | 417 ++++++++++++++++++++++++++++++++++++++ api/docs/swagger.json | 417 ++++++++++++++++++++++++++++++++++++++ api/docs/swagger.yaml | 283 ++++++++++++++++++++++++++ api/routes/course.go | 2 + 5 files changed, 1244 insertions(+) diff --git a/api/controllers/course.go b/api/controllers/course.go index 6f9588d9..0c711e08 100644 --- a/api/controllers/course.go +++ b/api/controllers/course.go @@ -254,3 +254,128 @@ func courseSection(flag string, c *gin.Context) { } c.JSON(http.StatusOK, responses.MultiSectionResponse{Status: http.StatusOK, Message: "success", Data: courseSections}) } + +// @Id courseProfessorSearch +// @Router /course/professors [get] +// @Description "Returns all the professors of all the courses matching the query's string-typed key-value pairs" +// @Produce json +// @Param course_number query string false "The course's official number" +// @Param subject_prefix query string false "The course's subject prefix" +// @Param title query string false "The course's title" +// @Param description query string false "The course's description" +// @Param school query string false "The course's school" +// @Param credit_hours query string false "The number of credit hours awarded by successful completion of the course" +// @Param class_level query string false "The level of education that this course course corresponds to" +// @Param activity_type query string false "The type of class this course corresponds to" +// @Param grading query string false "The grading status of this course" +// @Param internal_course_number query string false "The internal (university) number used to reference this course" +// @Param lecture_contact_hours query string false "The weekly contact hours in lecture for a course" +// @Param offering_frequency query string false "The frequency of offering a course" +// @Success 200 {array} schema.Professor "A list of professors" +func CourseProfessorSearch(c *gin.Context) { + courseProfessor("Search", c) +} + +// @Id courseProfessorById +// @Router /course/{id}/professors [get] +// @Description "Returns the all of the professors of the course with given ID" +// @Produce json +// @Param id path string true "ID of the course to get" +// @Success 200 {array} schema.Professor "A list of professors" +func CourseProfessorById(c *gin.Context) { + courseProfessor("ById", c) +} + +// get the professors of the courses, filters depending on the flag +func courseProfessor(flag string, c *gin.Context) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var courseProfessors []schema.Professor // the list of professors of the filtered courses + var courseQuery bson.M // query of the courses (or the single course) + var err error // error + + // determine the course query + if flag == "Search" { // filter courses based on the query parameters + // build the key-value pair of query parameters + courseQuery, err = schema.FilterQuery[schema.Course](c) + if err != nil { + // return the validation error if there's anything wrong + c.JSON(http.StatusBadRequest, responses.ErrorResponse{Status: http.StatusBadRequest, Message: "schema validation error", Data: err.Error()}) + return + } + } else if flag == "ById" { // filter the single course based on it's Id + // convert the id param with the ObjectID + courseId := c.Param("id") + courseObjId, convertIdErr := primitive.ObjectIDFromHex(courseId) + if convertIdErr != nil { + // return the id conversion error if there's error + log.WriteError(convertIdErr) + c.JSON(http.StatusBadRequest, responses.ErrorResponse{Status: http.StatusBadRequest, Message: "error with id", Data: convertIdErr.Error()}) + return + } + courseQuery = bson.M{"_id": courseObjId} + } else { + // otherwise, something that messed up the server + c.JSON(http.StatusInternalServerError, responses.ErrorResponse{Status: http.StatusInternalServerError, Message: "internal error", Data: "broken endpoint"}) + return + } + + // determine the offset and limit for pagination stage + // and delete "offset" field in professorQuery + offset, limit, err := configs.GetAggregateLimit(&courseQuery, c) + if err != nil { + log.WriteErrorWithMsg(err, log.OffsetNotTypeInteger) + c.JSON(http.StatusConflict, responses.ErrorResponse{Status: http.StatusConflict, Message: "Error offset is not type integer", Data: err.Error()}) + return + } + + // pipeline to query the professors from the filtered courses + courseProfessorPipeline := mongo.Pipeline{ + // filter the courses + bson.D{{Key: "$match", Value: courseQuery}}, + + // paginate the courses before pulling the sections from those courses + bson.D{{Key: "$skip", Value: offset}}, // skip to the specified offset + bson.D{{Key: "$limit", Value: limit}}, // limit to the specified number of courses + + // lookup the sections of the courses + bson.D{{Key: "$lookup", Value: bson.D{ + {Key: "from", Value: "sections"}, + {Key: "localField", Value: "sections"}, + {Key: "foreignField", Value: "_id"}, + {Key: "as", Value: "sections"}, + }}}, + + // lookup the professors of the sections + bson.D{{Key: "$lookup", Value: bson.D{ + {Key: "from", Value: "professors"}, + {Key: "localField", Value: "sections.professors"}, + {Key: "foreignField", Value: "_id"}, + {Key: "as", Value: "professors"}, + }}}, + + // unwind the professors of the sections + bson.D{{Key: "$unwind", Value: bson.D{ + {Key: "path", Value: "$professors"}, + {Key: "preserveNullAndEmptyArrays", Value: false}, // avoid course documents that can't be replaced + }}}, + + // replace the courses with professors + bson.D{{Key: "$replaceWith", Value: "$professors"}}, + } + + // perform aggregation on the pipeline + cursor, err := courseCollection.Aggregate(ctx, courseProfessorPipeline) + if err != nil { + // return error for any aggregation problem + log.WriteError(err) + c.JSON(http.StatusInternalServerError, responses.ErrorResponse{Status: http.StatusInternalServerError, Message: "aggregation error", Data: err.Error()}) + return + } + // parse the array of professors of the course + if err = cursor.All(ctx, &courseProfessors); err != nil { + panic(err) + } + c.JSON(http.StatusOK, responses.MultiProfessorResponse{Status: http.StatusOK, Message: "success", Data: courseProfessors}) +} diff --git a/api/docs/docs.go b/api/docs/docs.go index 7b2a3980..c6f79f02 100644 --- a/api/docs/docs.go +++ b/api/docs/docs.go @@ -129,6 +129,194 @@ const docTemplate = `{ } } }, + "/course/professors": { + "get": { + "description": "\"Returns all the professors of all the courses matching the query's string-typed key-value pairs\"", + "produces": [ + "application/json" + ], + "operationId": "courseProfessorSearch", + "parameters": [ + { + "type": "string", + "description": "The course's official number", + "name": "course_number", + "in": "query" + }, + { + "type": "string", + "description": "The course's subject prefix", + "name": "subject_prefix", + "in": "query" + }, + { + "type": "string", + "description": "The course's title", + "name": "title", + "in": "query" + }, + { + "type": "string", + "description": "The course's description", + "name": "description", + "in": "query" + }, + { + "type": "string", + "description": "The course's school", + "name": "school", + "in": "query" + }, + { + "type": "string", + "description": "The number of credit hours awarded by successful completion of the course", + "name": "credit_hours", + "in": "query" + }, + { + "type": "string", + "description": "The level of education that this course course corresponds to", + "name": "class_level", + "in": "query" + }, + { + "type": "string", + "description": "The type of class this course corresponds to", + "name": "activity_type", + "in": "query" + }, + { + "type": "string", + "description": "The grading status of this course", + "name": "grading", + "in": "query" + }, + { + "type": "string", + "description": "The internal (university) number used to reference this course", + "name": "internal_course_number", + "in": "query" + }, + { + "type": "string", + "description": "The weekly contact hours in lecture for a course", + "name": "lecture_contact_hours", + "in": "query" + }, + { + "type": "string", + "description": "The frequency of offering a course", + "name": "offering_frequency", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of professors", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Professor" + } + } + } + } + } + }, + "/course/sections": { + "get": { + "description": "\"Returns all the sections of all the courses matching the query's string-typed key-value pairs\"", + "produces": [ + "application/json" + ], + "operationId": "courseSectionSearch", + "parameters": [ + { + "type": "string", + "description": "The course's official number", + "name": "course_number", + "in": "query" + }, + { + "type": "string", + "description": "The course's subject prefix", + "name": "subject_prefix", + "in": "query" + }, + { + "type": "string", + "description": "The course's title", + "name": "title", + "in": "query" + }, + { + "type": "string", + "description": "The course's description", + "name": "description", + "in": "query" + }, + { + "type": "string", + "description": "The course's school", + "name": "school", + "in": "query" + }, + { + "type": "string", + "description": "The number of credit hours awarded by successful completion of the course", + "name": "credit_hours", + "in": "query" + }, + { + "type": "string", + "description": "The level of education that this course course corresponds to", + "name": "class_level", + "in": "query" + }, + { + "type": "string", + "description": "The type of class this course corresponds to", + "name": "activity_type", + "in": "query" + }, + { + "type": "string", + "description": "The grading status of this course", + "name": "grading", + "in": "query" + }, + { + "type": "string", + "description": "The internal (university) number used to reference this course", + "name": "internal_course_number", + "in": "query" + }, + { + "type": "string", + "description": "The weekly contact hours in lecture for a course", + "name": "lecture_contact_hours", + "in": "query" + }, + { + "type": "string", + "description": "The frequency of offering a course", + "name": "offering_frequency", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of sections", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Section" + } + } + } + } + } + }, "/course/{id}": { "get": { "description": "\"Returns the course with given ID\"", @@ -155,6 +343,64 @@ const docTemplate = `{ } } }, + "/course/{id}/professors": { + "get": { + "description": "\"Returns the all of the professors of the course with given ID\"", + "produces": [ + "application/json" + ], + "operationId": "courseProfessorById", + "parameters": [ + { + "type": "string", + "description": "ID of the course to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A list of professors", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Professor" + } + } + } + } + } + }, + "/course/{id}/sections": { + "get": { + "description": "\"Returns the all of the sections of the course with given ID\"", + "produces": [ + "application/json" + ], + "operationId": "courseSectionById", + "parameters": [ + { + "type": "string", + "description": "ID of the course to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A list of sections", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Section" + } + } + } + } + } + }, "/grades/overall": { "get": { "description": "\"Returns the overall grade distribution\"", @@ -401,6 +647,148 @@ const docTemplate = `{ } } }, + "/professor/courses": { + "get": { + "description": "\"Returns all of the courses of all the professors matching the query's string-typed key-value pairs\"", + "produces": [ + "application/json" + ], + "operationId": "professorCourseSearch", + "parameters": [ + { + "type": "string", + "description": "The professor's first name", + "name": "first_name", + "in": "query" + }, + { + "type": "string", + "description": "The professor's last name", + "name": "last_name", + "in": "query" + }, + { + "type": "string", + "description": "One of the professor's title", + "name": "titles", + "in": "query" + }, + { + "type": "string", + "description": "The professor's email address", + "name": "email", + "in": "query" + }, + { + "type": "string", + "description": "The professor's phone number", + "name": "phone_number", + "in": "query" + }, + { + "type": "string", + "description": "The building of the location of the professor's office", + "name": "office.building", + "in": "query" + }, + { + "type": "string", + "description": "The room of the location of the professor's office", + "name": "office.room", + "in": "query" + }, + { + "type": "string", + "description": "A hyperlink to the UTD room locator of the professor's office", + "name": "office.map_uri", + "in": "query" + }, + { + "type": "string", + "description": "A hyperlink pointing to the professor's official university profile", + "name": "profile_uri", + "in": "query" + }, + { + "type": "string", + "description": "A link to the image used for the professor on the professor's official university profile", + "name": "image_uri", + "in": "query" + }, + { + "type": "string", + "description": "The start date of one of the office hours meetings of the professor", + "name": "office_hours.start_date", + "in": "query" + }, + { + "type": "string", + "description": "The end date of one of the office hours meetings of the professor", + "name": "office_hours.end_date", + "in": "query" + }, + { + "type": "string", + "description": "One of the days that one of the office hours meetings of the professor", + "name": "office_hours.meeting_days", + "in": "query" + }, + { + "type": "string", + "description": "The time one of the office hours meetings of the professor starts", + "name": "office_hours.start_time", + "in": "query" + }, + { + "type": "string", + "description": "The time one of the office hours meetings of the professor ends", + "name": "office_hours.end_time", + "in": "query" + }, + { + "type": "string", + "description": "The modality of one of the office hours meetings of the professor", + "name": "office_hours.modality", + "in": "query" + }, + { + "type": "string", + "description": "The building of one of the office hours meetings of the professor", + "name": "office_hours.location.building", + "in": "query" + }, + { + "type": "string", + "description": "The room of one of the office hours meetings of the professor", + "name": "office_hours.location.room", + "in": "query" + }, + { + "type": "string", + "description": "A hyperlink to the UTD room locator of one of the office hours meetings of the professor", + "name": "office_hours.location.map_uri", + "in": "query" + }, + { + "type": "string", + "description": "The _id of one of the sections the professor teaches", + "name": "sections", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of Courses", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Course" + } + } + } + } + } + }, "/professor/{id}": { "get": { "description": "\"Returns the professor with given ID\"", @@ -427,6 +815,35 @@ const docTemplate = `{ } } }, + "/professor/{id}/courses": { + "get": { + "description": "\"Returns all the courses taught by the professor with given ID\"", + "produces": [ + "application/json" + ], + "operationId": "professorCourseById", + "parameters": [ + { + "type": "string", + "description": "ID of the professor to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A list of courses", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Course" + } + } + } + } + } + }, "/section": { "get": { "description": "\"Returns all courses matching the query's string-typed key-value pairs\"", diff --git a/api/docs/swagger.json b/api/docs/swagger.json index 8d5f08ec..2167299a 100644 --- a/api/docs/swagger.json +++ b/api/docs/swagger.json @@ -125,6 +125,194 @@ } } }, + "/course/professors": { + "get": { + "description": "\"Returns all the professors of all the courses matching the query's string-typed key-value pairs\"", + "produces": [ + "application/json" + ], + "operationId": "courseProfessorSearch", + "parameters": [ + { + "type": "string", + "description": "The course's official number", + "name": "course_number", + "in": "query" + }, + { + "type": "string", + "description": "The course's subject prefix", + "name": "subject_prefix", + "in": "query" + }, + { + "type": "string", + "description": "The course's title", + "name": "title", + "in": "query" + }, + { + "type": "string", + "description": "The course's description", + "name": "description", + "in": "query" + }, + { + "type": "string", + "description": "The course's school", + "name": "school", + "in": "query" + }, + { + "type": "string", + "description": "The number of credit hours awarded by successful completion of the course", + "name": "credit_hours", + "in": "query" + }, + { + "type": "string", + "description": "The level of education that this course course corresponds to", + "name": "class_level", + "in": "query" + }, + { + "type": "string", + "description": "The type of class this course corresponds to", + "name": "activity_type", + "in": "query" + }, + { + "type": "string", + "description": "The grading status of this course", + "name": "grading", + "in": "query" + }, + { + "type": "string", + "description": "The internal (university) number used to reference this course", + "name": "internal_course_number", + "in": "query" + }, + { + "type": "string", + "description": "The weekly contact hours in lecture for a course", + "name": "lecture_contact_hours", + "in": "query" + }, + { + "type": "string", + "description": "The frequency of offering a course", + "name": "offering_frequency", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of professors", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Professor" + } + } + } + } + } + }, + "/course/sections": { + "get": { + "description": "\"Returns all the sections of all the courses matching the query's string-typed key-value pairs\"", + "produces": [ + "application/json" + ], + "operationId": "courseSectionSearch", + "parameters": [ + { + "type": "string", + "description": "The course's official number", + "name": "course_number", + "in": "query" + }, + { + "type": "string", + "description": "The course's subject prefix", + "name": "subject_prefix", + "in": "query" + }, + { + "type": "string", + "description": "The course's title", + "name": "title", + "in": "query" + }, + { + "type": "string", + "description": "The course's description", + "name": "description", + "in": "query" + }, + { + "type": "string", + "description": "The course's school", + "name": "school", + "in": "query" + }, + { + "type": "string", + "description": "The number of credit hours awarded by successful completion of the course", + "name": "credit_hours", + "in": "query" + }, + { + "type": "string", + "description": "The level of education that this course course corresponds to", + "name": "class_level", + "in": "query" + }, + { + "type": "string", + "description": "The type of class this course corresponds to", + "name": "activity_type", + "in": "query" + }, + { + "type": "string", + "description": "The grading status of this course", + "name": "grading", + "in": "query" + }, + { + "type": "string", + "description": "The internal (university) number used to reference this course", + "name": "internal_course_number", + "in": "query" + }, + { + "type": "string", + "description": "The weekly contact hours in lecture for a course", + "name": "lecture_contact_hours", + "in": "query" + }, + { + "type": "string", + "description": "The frequency of offering a course", + "name": "offering_frequency", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of sections", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Section" + } + } + } + } + } + }, "/course/{id}": { "get": { "description": "\"Returns the course with given ID\"", @@ -151,6 +339,64 @@ } } }, + "/course/{id}/professors": { + "get": { + "description": "\"Returns the all of the professors of the course with given ID\"", + "produces": [ + "application/json" + ], + "operationId": "courseProfessorById", + "parameters": [ + { + "type": "string", + "description": "ID of the course to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A list of professors", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Professor" + } + } + } + } + } + }, + "/course/{id}/sections": { + "get": { + "description": "\"Returns the all of the sections of the course with given ID\"", + "produces": [ + "application/json" + ], + "operationId": "courseSectionById", + "parameters": [ + { + "type": "string", + "description": "ID of the course to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A list of sections", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Section" + } + } + } + } + } + }, "/grades/overall": { "get": { "description": "\"Returns the overall grade distribution\"", @@ -397,6 +643,148 @@ } } }, + "/professor/courses": { + "get": { + "description": "\"Returns all of the courses of all the professors matching the query's string-typed key-value pairs\"", + "produces": [ + "application/json" + ], + "operationId": "professorCourseSearch", + "parameters": [ + { + "type": "string", + "description": "The professor's first name", + "name": "first_name", + "in": "query" + }, + { + "type": "string", + "description": "The professor's last name", + "name": "last_name", + "in": "query" + }, + { + "type": "string", + "description": "One of the professor's title", + "name": "titles", + "in": "query" + }, + { + "type": "string", + "description": "The professor's email address", + "name": "email", + "in": "query" + }, + { + "type": "string", + "description": "The professor's phone number", + "name": "phone_number", + "in": "query" + }, + { + "type": "string", + "description": "The building of the location of the professor's office", + "name": "office.building", + "in": "query" + }, + { + "type": "string", + "description": "The room of the location of the professor's office", + "name": "office.room", + "in": "query" + }, + { + "type": "string", + "description": "A hyperlink to the UTD room locator of the professor's office", + "name": "office.map_uri", + "in": "query" + }, + { + "type": "string", + "description": "A hyperlink pointing to the professor's official university profile", + "name": "profile_uri", + "in": "query" + }, + { + "type": "string", + "description": "A link to the image used for the professor on the professor's official university profile", + "name": "image_uri", + "in": "query" + }, + { + "type": "string", + "description": "The start date of one of the office hours meetings of the professor", + "name": "office_hours.start_date", + "in": "query" + }, + { + "type": "string", + "description": "The end date of one of the office hours meetings of the professor", + "name": "office_hours.end_date", + "in": "query" + }, + { + "type": "string", + "description": "One of the days that one of the office hours meetings of the professor", + "name": "office_hours.meeting_days", + "in": "query" + }, + { + "type": "string", + "description": "The time one of the office hours meetings of the professor starts", + "name": "office_hours.start_time", + "in": "query" + }, + { + "type": "string", + "description": "The time one of the office hours meetings of the professor ends", + "name": "office_hours.end_time", + "in": "query" + }, + { + "type": "string", + "description": "The modality of one of the office hours meetings of the professor", + "name": "office_hours.modality", + "in": "query" + }, + { + "type": "string", + "description": "The building of one of the office hours meetings of the professor", + "name": "office_hours.location.building", + "in": "query" + }, + { + "type": "string", + "description": "The room of one of the office hours meetings of the professor", + "name": "office_hours.location.room", + "in": "query" + }, + { + "type": "string", + "description": "A hyperlink to the UTD room locator of one of the office hours meetings of the professor", + "name": "office_hours.location.map_uri", + "in": "query" + }, + { + "type": "string", + "description": "The _id of one of the sections the professor teaches", + "name": "sections", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of Courses", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Course" + } + } + } + } + } + }, "/professor/{id}": { "get": { "description": "\"Returns the professor with given ID\"", @@ -423,6 +811,35 @@ } } }, + "/professor/{id}/courses": { + "get": { + "description": "\"Returns all the courses taught by the professor with given ID\"", + "produces": [ + "application/json" + ], + "operationId": "professorCourseById", + "parameters": [ + { + "type": "string", + "description": "ID of the professor to get", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A list of courses", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.Course" + } + } + } + } + } + }, "/section": { "get": { "description": "\"Returns all courses matching the query's string-typed key-value pairs\"", diff --git a/api/docs/swagger.yaml b/api/docs/swagger.yaml index a9cf01fb..8ba979da 100644 --- a/api/docs/swagger.yaml +++ b/api/docs/swagger.yaml @@ -334,6 +334,172 @@ paths: description: A course schema: $ref: '#/definitions/schema.Course' + /course/{id}/professors: + get: + description: '"Returns the all of the professors of the course with given ID"' + operationId: courseProfessorById + parameters: + - description: ID of the course to get + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: A list of professors + schema: + items: + $ref: '#/definitions/schema.Professor' + type: array + /course/{id}/sections: + get: + description: '"Returns the all of the sections of the course with given ID"' + operationId: courseSectionById + parameters: + - description: ID of the course to get + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: A list of sections + schema: + items: + $ref: '#/definitions/schema.Section' + type: array + /course/professors: + get: + description: '"Returns all the professors of all the courses matching the query''s + string-typed key-value pairs"' + operationId: courseProfessorSearch + parameters: + - description: The course's official number + in: query + name: course_number + type: string + - description: The course's subject prefix + in: query + name: subject_prefix + type: string + - description: The course's title + in: query + name: title + type: string + - description: The course's description + in: query + name: description + type: string + - description: The course's school + in: query + name: school + type: string + - description: The number of credit hours awarded by successful completion of + the course + in: query + name: credit_hours + type: string + - description: The level of education that this course course corresponds to + in: query + name: class_level + type: string + - description: The type of class this course corresponds to + in: query + name: activity_type + type: string + - description: The grading status of this course + in: query + name: grading + type: string + - description: The internal (university) number used to reference this course + in: query + name: internal_course_number + type: string + - description: The weekly contact hours in lecture for a course + in: query + name: lecture_contact_hours + type: string + - description: The frequency of offering a course + in: query + name: offering_frequency + type: string + produces: + - application/json + responses: + "200": + description: A list of professors + schema: + items: + $ref: '#/definitions/schema.Professor' + type: array + /course/sections: + get: + description: '"Returns all the sections of all the courses matching the query''s + string-typed key-value pairs"' + operationId: courseSectionSearch + parameters: + - description: The course's official number + in: query + name: course_number + type: string + - description: The course's subject prefix + in: query + name: subject_prefix + type: string + - description: The course's title + in: query + name: title + type: string + - description: The course's description + in: query + name: description + type: string + - description: The course's school + in: query + name: school + type: string + - description: The number of credit hours awarded by successful completion of + the course + in: query + name: credit_hours + type: string + - description: The level of education that this course course corresponds to + in: query + name: class_level + type: string + - description: The type of class this course corresponds to + in: query + name: activity_type + type: string + - description: The grading status of this course + in: query + name: grading + type: string + - description: The internal (university) number used to reference this course + in: query + name: internal_course_number + type: string + - description: The weekly contact hours in lecture for a course + in: query + name: lecture_contact_hours + type: string + - description: The frequency of offering a course + in: query + name: offering_frequency + type: string + produces: + - application/json + responses: + "200": + description: A list of sections + schema: + items: + $ref: '#/definitions/schema.Section' + type: array /grades/overall: get: description: '"Returns the overall grade distribution"' @@ -517,6 +683,123 @@ paths: description: A professor schema: $ref: '#/definitions/schema.Professor' + /professor/{id}/courses: + get: + description: '"Returns all the courses taught by the professor with given ID"' + operationId: professorCourseById + parameters: + - description: ID of the professor to get + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: A list of courses + schema: + items: + $ref: '#/definitions/schema.Course' + type: array + /professor/courses: + get: + description: '"Returns all of the courses of all the professors matching the + query''s string-typed key-value pairs"' + operationId: professorCourseSearch + parameters: + - description: The professor's first name + in: query + name: first_name + type: string + - description: The professor's last name + in: query + name: last_name + type: string + - description: One of the professor's title + in: query + name: titles + type: string + - description: The professor's email address + in: query + name: email + type: string + - description: The professor's phone number + in: query + name: phone_number + type: string + - description: The building of the location of the professor's office + in: query + name: office.building + type: string + - description: The room of the location of the professor's office + in: query + name: office.room + type: string + - description: A hyperlink to the UTD room locator of the professor's office + in: query + name: office.map_uri + type: string + - description: A hyperlink pointing to the professor's official university profile + in: query + name: profile_uri + type: string + - description: A link to the image used for the professor on the professor's + official university profile + in: query + name: image_uri + type: string + - description: The start date of one of the office hours meetings of the professor + in: query + name: office_hours.start_date + type: string + - description: The end date of one of the office hours meetings of the professor + in: query + name: office_hours.end_date + type: string + - description: One of the days that one of the office hours meetings of the + professor + in: query + name: office_hours.meeting_days + type: string + - description: The time one of the office hours meetings of the professor starts + in: query + name: office_hours.start_time + type: string + - description: The time one of the office hours meetings of the professor ends + in: query + name: office_hours.end_time + type: string + - description: The modality of one of the office hours meetings of the professor + in: query + name: office_hours.modality + type: string + - description: The building of one of the office hours meetings of the professor + in: query + name: office_hours.location.building + type: string + - description: The room of one of the office hours meetings of the professor + in: query + name: office_hours.location.room + type: string + - description: A hyperlink to the UTD room locator of one of the office hours + meetings of the professor + in: query + name: office_hours.location.map_uri + type: string + - description: The _id of one of the sections the professor teaches + in: query + name: sections + type: string + produces: + - application/json + responses: + "200": + description: A list of Courses + schema: + items: + $ref: '#/definitions/schema.Course' + type: array /section: get: description: '"Returns all courses matching the query''s string-typed key-value diff --git a/api/routes/course.go b/api/routes/course.go index 91fc2b2d..eb0a4444 100644 --- a/api/routes/course.go +++ b/api/routes/course.go @@ -18,4 +18,6 @@ func CourseRoute(router *gin.Engine) { // Endpoint to get the list of sections of the queried course, courses courseGroup.GET("/sections", controllers.CourseSectionSearch()) courseGroup.GET("/:id/sections", controllers.CourseSectionById()) + courseGroup.GET("/professors", controllers.CourseProfessorSearch) + courseGroup.GET("/:id/professors", controllers.CourseProfessorById) }