COMP 2406 – F19 – A5 Due Friday, December 6th at 11:59 PM1Assignment 5Sessions and User ProfilesSubmit a single zip file called assignment5.zip. Your submission MUST contain apackage.json file that allows your assignment to be built using npm install. You shouldnot include the node_modules folder or database files in your submission. You mayassume that the TA will have the MongoDB daemon running and that the TA will have rundatabase-initializer.js before running your server.This assignment has 100 marks. Read the marking scheme posted on cuLearn for details.Assignment BackgroundIn this assignment, you will add sessions and user profiles to an existing trivia quiz server. Yourassignment should use the express-sessions module for session data and the connectmongodb-sessionmodule as a session store.To get started, download the A5-BaseCode.zip file from cuLearn. This zip file includes aworking Express-based trivia quiz server. You can install the dependencies by running npminstall in the directory with the package.json file. The zip file also includes a databaseinitializer.jsfile that, when executed, will reset the quiztracker database in the runningMongo instance and re-build the questions and users collection to their default state. Thedatabase uses the two Mongoose schemas that are also included – QuestionModel.js andUserModel.js. The users collection will have 10 users. You can find the user names byquerying the database or looking in the database-initializer.js file. Each users passwordis also the same as their username. Read through the provided code to familiarize yourself withhow the server works. A basic outline of the servers current functionality is described below.GET requests for the /quiz route return an HTML page containing 10 randomly selectedquestions. The answers for the questions are not shuffled, so the first option shown for eachquestion will always be the correct answer. To speed your testing, the client-side Javascriptloaded on this quiz page automatically selects random answers when the page loads.When the user selects Submit at the bottom of the quiz page, the answers are sent to theserver using a POST XMLHttpRequest to the /quiz route. The server calculates the number ofcorrect answers and sends a JSON response back to the client indicating:1. url: the URL the browser should be redirected to2. correct: the number of correct answersCOMP 2406 – F19 – A5 Due Friday, December 6th at 11:59 PM2The client-side Javascript then displays an alert with the number of correct answers andredirects the browser to the URL supplied by the server.The remainder of the assignment will involve adding additional functionality into this code base.You should not need to modify the client-side Javascript or the GET /quiz route, but are free todo so if you want to.Assignment RequirementsEach page on the quiz tracker site should have a header that contains the following:1. A link to the home page (/)2. A like to start a new quiz (/quiz)3. A link to lists all users (/users)4. If the user is currently logged in, a link to their profile (/users/that_users_id)5. If the user is not currently logged in, a log in form where they can enter ausername/password combination before clicking a Login buttonWhen a user tries to log in, the server should validate their username and password bysearching for matching entries in the database. You can assume that usernames will be uniquewithin the database. If the credentials are correct, that user should be logged in COMP 2406代做、代写Java程序语言、代做Java、to the systemand should continue to be classified as logged in until they choose to log out or until the cookieassociated with their session expires (you can decide on the expiry method). Additionally, oncelogged in, the user should be redirected to their profile page. If the credentials are incorrect, theuser should be redirected to the homepage.A GET request for the /users route should return an HTML page containing a list of all users inthe servers database that have their privacy value set to Off or false. The entry for each userin this list should contain a link to that users profile with the link text showing their username.Users who have set their privacy value to On or true should not show up in the search.A GET request to the parameterized route /users/:userID should behave as described below:1. If the requesting user is logged in and requesting their own profile, then the page will:a. Provide a method for the user to toggle their privacy setting (e.g., two radiobuttons or a drop-down list).b. Provide a method for the user to save the changes to their privacy setting,which should send the selected privacy value to the server and update thedatabase. The user should remain on their profile after this is completed.c. List the users total quizzes completed and average quiz scored. Provide a Log Out button that, when clicked, logs the user out of the systemand redirects them to the home page.2. If the requesting user is not logged in or is requesting some other users profile, then:a. If the profile being requested is set to be private, you should respond with anHTTP status code of 403, indicating that the profile cannot be accessed.COMP 2406 – F19 – A5 Due Friday, December 6th at 11:59 PM3b. If the profile being requested is not set to be private, then the page shouldshow the total quizzes and average quiz score of the requested user.When a POST request is made by a logged in user to the /quiz route to complete a quiz, thatusers profile should be updated and saved. The user should then be redirected to their ownprofile. If a user who is not logged in to the system makes a POST request to /quiz, nochanges need to be made to any users and the user should be redirected to the home page.Code Quality and DocumentationYour code should be well-written and easy to understand. This includes providing cleardocumentation explaining the purpose and function of pieces of your code. You should usegood variable/function names that make your code easier to read. You should do your best toavoid unnecessary computation/communication and ensure that your code runs smoothlythroughout operation. You must also include a README.txt file that explains any designdecisions that you made and precise instructions for how to run/use your system.RecapYour zip file should contain all the resources required for your assignment to run. Yoursubmission MUST contain a package.json file that allows your assignment to be built using npminstall. You should not include the node_modules folder or MongoDB database files in yoursubmission. The TA must be able to run your server and use the system by following theinstructions in your README.txt file. You may assume that the TA will have the MongoDBdaemon running and will have run database-initializer.js before running your server.Submit your assignment5.zip file to cuLearn.Make sure you download the zip after submitting, verify the file contents, and verify that yourinstructions are sufficient for installing/running your system.转自:http://www.6daixie.com/contents/9/4471.html
讲解:COMP 2406、Java、Java、MongoDBPython|Prolog
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- The Inner Game of Tennis W Timothy Gallwey Jonathan Cape ...