cyntaria/UniPal-Backend

[GET] All Classes

arafaysaleem opened this issue · 0 comments

Summary

As a student, I should be able to get all possible classes, so that I can choose one for my timetable.

Acceptance Criteria

GIVEN an student is requesting all possible classes in the app
WHEN the app hits the /classes endpoint with a valid GET request
THEN the app should receive a status 200
AND in the response, the following information should be returned:

  • headers
  • list of classes

Sample Request/Sample Response

headers: {
    error: 0,
    message: "..."
}
body: [
    {
        class_erp: 14892,
  	semester: CS-4,
        term_id: 1,
  	classroom: {
		classroom_id: 1,
		classroom: "MTC-21",
		campus: {
			campus_id: 1,
			campus: "MAIN"
		},
	},
  	subject: {
		subject_code: CSE104,
		subject: "Data Structures"
	}
  	teacher: {
		teacher_id: 1,
		full_name: "Shakeel Khoja",
		average_rating: 4.5,
		total_reviews: 10
	}
  	parent_class_erp: null, // this is not a lab class
  	timeslot_1: {
		timeslot_id: 1,
		start_time: 8:30,
		end_time: 9:45,
		slot_number: 1
	},
  	timeslot_2: {
		timeslot_id: 1,
		start_time: 8:30,
		end_time: 9:45,
		slot_number: 1
	},
  	day_1: monday,
  	day_2: wednesday
    },
    {
        class_erp: 14893,
  	semester: CS-4,
        term_id: 1,
  	classroom: {
		classroom_id: 11,
		classroom: "MTL-4",
		campus: {
			campus_id: 1,
			campus: "MAIN"
		},
	},
  	subject: {
		subject_code: CSE104,
		subject: "Data Structures"
	}
  	teacher: {
		teacher_id: 1,
		full_name: "Shakeel Khoja",
		average_rating: 4.5,
		total_reviews: 10
	}
  	parent_class_erp: 14892, // this is not a lab class
  	timeslot_1: {
		timeslot_id: 2,
		start_time: 10:00,
		end_time: 11:15,
		slot_number: 2
	},
  	timeslot_2: {
		timeslot_id: 2,
		start_time: 10:00,
		end_time: 11:15,
		slot_number: 2
	},
  	day_1: monday,
  	day_2: wednesday
    },
    ....
]

Resources

  • Development URL: {Here goes a URL to the feature on development API}
  • Production URL: {Here goes a URL to the feature on production API}

Dev Notes

None.

Testing Notes

Scenario 1: GET request is successful

GIVEN a student is requesting all possible classes in the app
WHEN the app hits the /classes endpoint with a valid GET request
THEN the app should receive a status 200
AND the body should be an array
AND the first item of the array should be an object containing the following fields:

  • class_erp
  • semester
  • classroom
  • subject
  • teacher
  • parent_class_erp
  • timeslot_1
  • timeslot_2
  • day_1
  • day_2
  • term_id
    AND the key classroom should be an object containing the following fields:
  • classroom_id
  • classroom
  • campus
    AND the key campus should be an object containing the following fields:
  • campus_id
  • campus
    AND the key subject should be an object containing the following fields:
  • subject_code
  • subject
    AND the key teacher should be an object containing the following fields:
  • teacher_id
  • full_name
  • average_rating
  • total_reviews
    AND the keys timeslot_1 and timeslot_2 should be objects containing the following fields:
  • timeslot_id
  • start_time
  • end_time
  • slot_number

Scenario 2: GET request with query parameters is successful

GIVEN a student is requesting all classes in the app
WHEN the app hits the /classes endpoint with a valid GET request
AND the query parameter contains subject_code="MKT201"
THEN the app should receive a status 200
AND the body should be an array
AND the first item of the array should be an object containing the following fields:

  • class_erp
  • term_id
  • semester
  • classroom
  • subject
  • teacher
  • parent_class_erp
  • timeslot_1
  • timeslot_2
  • day_1
  • day_2
    AND the key subject_code should be equal to MKT201

Scenario 3: GET request is unsuccessful due to no classes

GIVEN a student is requesting all possible classes in the app
WHEN the app hits the /classes endpoint with a valid GET request
THEN the app should receive a status 404
AND the response headers' code parameter should contain "NotFoundException"

Scenario 4: GET request is incorrect due to unknown query parameters

GIVEN a student is requesting all possible reviews of a teacher in the app
WHEN the app hits the /classes endpoint with a valid GET request
AND contains unknown query parameters
THEN the app should receive a status 422
AND the response headers' code parameter should contain "InvalidPropertiesException"
AND the response headers' data parameter should contain the name of the invalid parameters

Scenario 5: GET request is unauthorized

GIVEN a student is requesting all possible classes in the app
WHEN the app hits the /classes endpoint with a valid GET request
AND the request contains no authorization token
THEN the app should receive a status 401
AND the response headers' code parameter should contain "TokenMissingException"