******************************************************************************** ********************* REQUEST AND SERVE DOCUMENTATION ************************** ******************************************************************************** This document lays down the pertinent information for requesting and serving data between front-end and server. The structure is styled in a pseudo jquery ajax call format with notes provided. There are 3 categories. Admin only requests are the requests made only the admin, likewise for users. All visitor requests are requests that everyone that visits the website can make. Assume content/data-types are json format (they are omitted). Standard serves for styles/images/script files are omitted. ******************************** ADMIN ONLY ************************************ N/A ********************************* USERS ONLY *********************************** Requests made by logged in users. User credentials required. Note: Look into authenticating users and saving login session data. Probably store session data in database. -------------------------------------------------------------------------------- LOGIN -------------------------------------------------------------------------------- Description: User login Method: 'POST' url: '/login' Data: userData = { username: 'jsmith85', // Consider whether we need to secure this as well password: 'blahblah' // Come back to this for a more secure method* } On Success: Return response such that: response = {type: typeOfUser} // Where typeOfUser takes on 'admin' or 'user' Notes: We'll have to save information to keep this user in a login-state There is probably a way to save credentials securely, and then authenticate from server for other tasks on the web app. -------------------------------------------------------------------------------- USER-PROFILE - Receive info -------------------------------------------------------------------------------- Description: Method: Url: Data: On Success: Notes: -------------------------------------------------------------------------------- USER-PROFILE - Edit info -------------------------------------------------------------------------------- Description: Method: Url: Data: On Success: Notes: -------------------------------------------------------------------------------- SOLUTION UPLOAD -------------------------------------------------------------------------------- Description: Method: Url: Data: On Success: Notes: -------------------------------------------------------------------------------- COMMENT ON SOLUTION -------------------------------------------------------------------------------- Description: Method: Url: Data: On Success: Notes: -------------------------------------------------------------------------------- UP/DOWNVOTE A SOLUTION -------------------------------------------------------------------------------- Description: Method: Url: Data: On Success: Notes: ********************************* ALL VISITORS ********************************* Requests made by any users, no credentials required. -------------------------------------------------------------------------------- SIGN UP -------------------------------------------------------------------------------- Description: Post user information filled out from a form to server. Method: 'POST' Url: '/signUp' Data: userData = { firstName: 'John', lastName: 'Smith', username: 'jsmith85', password: 'blahblah', // Come back to this for a more secure method* University: 'UofT', // optional Department: 'Optional' // optional } On success: - no data required Notes: Might add more fields, will re-visit, design such a way that adding more fields for a user is not difficult to change. -------------------------------------------------------------------------------- EXAM - Page -------------------------------------------------------------------------------- Description: The information sent/served when a user does a specific query for an exam. Method: 'GET' Url: '/exam' Data: examTitle = { courseCode: 'csc148', termOffered: 'Fall', dateOffered: 'June2014', campus: 'St.George', } On Success: Return response such that: response = { courseCode: 'csc148' instructors: 'Paul Grieves and Danny Heap', uploadDate: '2014-01-26' pageCount: 22 questionCount: 10 questions: {question1, question2,...}, path: '/exams/stgeorge/2014/fall/csc148.pdf' } Where each questionN is a question object such that: questionN = { questionNumber: 1, solutionCount: 2, commentCount: 6 } -------------------------------------------------------------------------------- QUESTION - SOLUTIONS - PAGE -------------------------------------------------------------------------------- Description: Page displayed when user queries for a specific exam questions solution. Information displayed includes: each submitted solution, where each solution contains the user uploader details, date uploaded, up/down score, solution plain-text, comments (where each comment contains commenter's info). Method: 'GET' Url: '/solution' Data: examTitle = { courseCode: 'csc148', termOffered: 'Fall', dateOffered: 'June2014', campus: 'St.George', question: 2 } On Success: Return a response such that: response = { solutions: [solution1, solution2, ....] } Where each solutionN is a solution object such that: solutionN = { uploaderUsername: 'jSmith123', uploaderAvatarPath: '/assets/images/avatars/jSmith123.png', uploaderUpvotes: 3, uploaderDownvotes: -1, solution: 'In this solution we solve it by doing x then y and ta-da!', comments: [comment1, comment2, ....] } where each commentN is a comment object such that: commentN = { username: 'janeDoe456', avatarPath: '/assets/images/avatars/janeDoe456.png', comment: 'This is a good answer!' } -------------------------------------------------------------------------------- -------------------------------- SEARCHING ------------------------------------- -------------------------------------------------------------------------------- Search bar requests will be divided into 2 separate types of requests from the server. Each request will be a different ajax call. This is dependent on the the drop-down value on the search bar. 1) Request Users: Serve the users with matching information provided 2) Request Courses: Serve the courses with the matching course code Users can also request exams for a course via the nav menu. This is essentially the same as performing a request for courses through search bar for our purposes so we don't need another call for nav. -------------------------------------------------------------------------------- SEARCH-BAR - Courses -------------------------------------------------------------------------------- Description: Any visitor can do a search by courses, server must respond with all exams that are categorized by the course searched (from front end). Method: 'GET' Url: '/search/courses' Data: search = 'abcxzy' //where abc are letters and xzy are integers On success: return response such that: response = { courses: [course1, course2, course3] } Where each courseN is a course object such that: courseN = { courseName: 'Intro to Computer Science', courseCode: 'CSC148', commentCount: '13', solutionCount: '3' termOffered: 'Fall', dateOffered: 'June/2014' camus: 'St.George' // Other values: 'Mississauga'/'Scarborough' } -------------------------------------------------------------------------------- SEARCH-BAR - Users -------------------------------------------------------------------------------- Description: Any visitor can do a search by users, server must respond with all users with usernames where the provided keyword (from front-end) is a substring of the username. Method: 'GET' Url: '/search/users' Data: search = 'subString' On Success: return response such that: response = { users: [user1, user2, user3] } Where each userN is a user object such that: userN = { username: 'janeDoe456', avatarPath: '/assets/images/avatars/janeDoe456.png', // 'N/A' if it d.n.e. points: 100, commentCount: 13, solutionCount: 3 }