讲解:COMP 2406、Java、Java、MongoDBPython|Prolog

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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,324评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,356评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,328评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,147评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,160评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,115评论 1 296
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,025评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,867评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,307评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,528评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,688评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,409评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,001评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,657评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,811评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,685评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,573评论 2 353

推荐阅读更多精彩内容