{"id":1300,"date":"2016-12-29T13:44:08","date_gmt":"2016-12-29T13:44:08","guid":{"rendered":"http:\/\/myprojects.advchaweb.com\/?p=1300"},"modified":"2017-01-03T04:51:57","modified_gmt":"2017-01-03T04:51:57","slug":"laravel-quiz","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2016\/12\/29\/laravel-quiz\/","title":{"rendered":"Laravel Quiz"},"content":{"rendered":"<p>source: <a href=\"https:\/\/github.com\/SAIBA0011\/laravel-quiz\" target=\"_blank\">https:\/\/github.com\/SAIBA0011\/laravel-quiz<\/a><\/p>\n<p>Description:<\/p>\n<p>Laravel-Quiz functionality<\/p>\n<p>Create a new quiz<br \/>\nCreate quiz questions &#8212; single &amp; multi Select<br \/>\nshow quiz questions<br \/>\nCreate quiz question options &#8212; Pending..<br \/>\nTo be implemented<\/p>\n<p>Finish quiz question options.<br \/>\nChange question position.<br \/>\nChange question option position.<br \/>\nRandomize question order on display page.<br \/>\nTrack user attempts per quiz.<br \/>\nAllow user to take quiz.<br \/>\nallow user to complete quiz.<br \/>\nshow quiz results on complete.<\/p>\n<p>Installation:<\/p>\n<ol>\n<li>Create a new laravel project:\n<pre class=\"lang:default decode:true\">composer create-project --prefer-dist laravel\/laravel laravel-quiz<\/pre>\n<p>&nbsp;<\/li>\n<li>Download the app from <a href=\"https:\/\/github.com\/SAIBA0011\/laravel-quiz\" target=\"_blank\">https:\/\/github.com\/SAIBA0011\/laravel-quiz<\/a>. It&#8217;s better to donwload in zip file then extract the content in \/works\/laravel\/quiz\/ directory. Overwrite the existing files and directories.<\/li>\n<li>Install the laravel component required:\n<pre class=\"lang:default decode:true\">composer install<\/pre>\n<p>&nbsp;<\/li>\n<li>Create a new database &#8216;laravel_quiz&#8217; by phpmyadmin<\/li>\n<li>Use &#8216;php artisan migrate&#8217; to create the tables.<br \/>\nNOTE: I got this error when trying to do &#8216;migrate&#8217;<br \/>\n&#8220;teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/laravel-quiz$ php artisan migrate<br \/>\nMigration table created successfully.[Illuminate\\Database\\QueryException]<br \/>\nSQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i<br \/>\nn your SQL syntax; check the manual that corresponds to your MySQL server v<br \/>\nersion for the right syntax to use near &#8216;) on delete cascade&#8217; at line 1 (SQ<br \/>\nL: alter table `quiz_results` add constraint `quiz_results_user_id_foreign`<br \/>\nforeign key (`user_id`) references `users` () on delete cascade)<br \/>\n[PDOException]<br \/>\nSQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i<br \/>\nn your SQL syntax; check the manual that corresponds to your MySQL server v<br \/>\nersion for the right syntax to use near &#8216;) on delete cascade&#8217; at line 1 &#8221;<br \/>\nSOLUTION: At first, I did like in the articles <a href=\"http:\/\/stackoverflow.com\/questions\/26820788\/add-on-delete-cascade-to-existing-column-in-laravel\">http:\/\/stackoverflow.com\/questions\/26820788\/add-on-delete-cascade-to-existing-column-in-laravel<\/a> and <a href=\"http:\/\/stackoverflow.com\/questions\/28167329\/laravel-migration-remove-ondeletecascade-from-existing-foreign-key\">http:\/\/stackoverflow.com\/questions\/28167329\/laravel-migration-remove-ondeletecascade-from-existing-foreign-key<\/a> on &#8216;2016_10_24_101046_create_quiz_results_table.php&#8217; in \/database\/migrations\/ directory BUT SOMEHOW IT DIDN&#8217;T WORK<\/p>\n<pre class=\"lang:default decode:true \">$table-&gt;dropForeign('quiz_results_user_id_foreign');\r\n$table-&gt;foreign('user_id')-&gt;reference('id')-&gt;on('users')-&gt;onDelete('cascade');\r\n\/\/$table-&gt;foreign('user_id')-&gt;reference('id')-&gt;on('users');\r\n\r\n$table-&gt;dropForeign('quiz_results_quiz_id_foreign');\r\n$table-&gt;foreign('quiz_id')-&gt;reference('id')-&gt;on('quiz')-&gt;onDelete('cascade');\r\n\/\/$table-&gt;foreign('quiz_id')-&gt;reference('id')-&gt;on('quiz');\r\n<\/pre>\n<p>SO I JUST COMMENT THE &#8216;onDelete&#8217; COMMAND<\/p>\n<pre class=\"lang:default decode:true \">\/\/$table-&gt;foreign('user_id')-&gt;reference('id')-&gt;on('users')-&gt;onDelete('cascade');\r\n\/\/$table-&gt;foreign('quiz_id')-&gt;reference('id')-&gt;on('quiz')-&gt;onDelete('cascade');<\/pre>\n<p>THEN THE MIGRATIONS RUN WELL.<\/li>\n<li>generate the new key\n<pre class=\"lang:default decode:true \">php artisan key:generate<\/pre>\n<\/li>\n<li>Install npm modules and gulp\n<pre class=\"lang:default decode:true \">npm install<\/pre>\n<p>BUT SOMEHOW I GOT THIS ERROR ON &#8216;gulp&#8217;<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/laravel-quiz$ gulp\r\n[20:44:18] Using gulpfile ~\/Documents\/works\/laravel\/laravel-quiz\/gulpfile.js\r\n[20:44:18] Starting 'all'...\r\n[20:44:18] Starting 'sass'...\r\n[20:44:20] Finished 'sass' after 1.6 s\r\n[20:44:20] Starting 'webpack'...\r\n{ [Error: Entry module not found: Error: Can't resolve 'buble' in '\/home\/teddy\/Documents\/works\/laravel\/laravel-quiz'\r\nresolve 'buble' in '\/home\/teddy\/Documents\/works\/laravel\/laravel-quiz'\r\n  Parsed request is a module\r\n  using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .)\r\n  after using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .)\r\n    resolve as module\r\n      module variation buble-loader\r\n        \/home\/teddy\/Documents\/works\/laravel\/node_modules doesn't exist or is not a directory\r\n        \/home\/teddy\/Documents\/node_modules doesn't exist or is not a directory\r\n        \/home\/teddy\/Documents\/works\/node_modules doesn't exist or is not a directory\r\n        \/home\/teddy\/node_modules doesn't exist or is not a directory\r\n        \/home\/node_modules doesn't exist or is not a directory\r\n        \/node_modules doesn't exist or is not a directory\r\n        looking for modules in \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\r\n          using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules)\r\n          after using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules)\r\n            using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules\/buble-loader)\r\n              as directory\r\n                \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble-loader doesn't exist\r\n              no extension\r\n                \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble-loader doesn't exist\r\n              .js\r\n                \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble-loader.js doesn't exist\r\n              .json\r\n                \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble-loader.json doesn't exist\r\n      \/home\/teddy\/Documents\/works\/laravel\/node_modules doesn't exist or is not a directory\r\n      \/home\/teddy\/Documents\/node_modules doesn't exist or is not a directory\r\n      \/home\/teddy\/Documents\/works\/node_modules doesn't exist or is not a directory\r\n      \/home\/teddy\/node_modules doesn't exist or is not a directory\r\n      \/home\/node_modules doesn't exist or is not a directory\r\n      \/node_modules doesn't exist or is not a directory\r\n      looking for modules in \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\r\n        using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules)\r\n        after using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules)\r\n          using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules\/buble)\r\n            as directory\r\n              \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble doesn't exist\r\n            no extension\r\n              \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble doesn't exist\r\n            .js\r\n              \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble.js doesn't exist\r\n            .json\r\n              \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble.json doesn't exist]\r\n  message: 'Entry module not found: Error: Can\\'t resolve \\'buble\\' in \\'\/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\\'\\nresolve \\'buble\\' in \\'\/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\\'\\n  Parsed request is a module\\n  using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .)\\n  after using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .)\\n    resolve as module\\n      module variation buble-loader\\n        \/home\/teddy\/Documents\/works\/laravel\/node_modules doesn\\'t exist or is not a directory\\n        \/home\/teddy\/Documents\/node_modules doesn\\'t exist or is not a directory\\n        \/home\/teddy\/Documents\/works\/node_modules doesn\\'t exist or is not a directory\\n        \/home\/teddy\/node_modules doesn\\'t exist or is not a directory\\n        \/home\/node_modules doesn\\'t exist or is not a directory\\n        \/node_modules doesn\\'t exist or is not a directory\\n        looking for modules in \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\\n          using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules)\\n          after using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules)\\n            using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules\/buble-loader)\\n              as directory\\n                \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble-loader doesn\\'t exist\\n              no extension\\n                \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble-loader doesn\\'t exist\\n              .js\\n                \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble-loader.js doesn\\'t exist\\n              .json\\n                \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble-loader.json doesn\\'t exist\\n      \/home\/teddy\/Documents\/works\/laravel\/node_modules doesn\\'t exist or is not a directory\\n      \/home\/teddy\/Documents\/node_modules doesn\\'t exist or is not a directory\\n      \/home\/teddy\/Documents\/works\/node_modules doesn\\'t exist or is not a directory\\n      \/home\/teddy\/node_modules doesn\\'t exist or is not a directory\\n      \/home\/node_modules doesn\\'t exist or is not a directory\\n      \/node_modules doesn\\'t exist or is not a directory\\n      looking for modules in \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\\n        using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules)\\n        after using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules)\\n          using description file: \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/package.json (relative path: .\/node_modules\/buble)\\n            as directory\\n              \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble doesn\\'t exist\\n            no extension\\n              \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble doesn\\'t exist\\n            .js\\n              \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble.js doesn\\'t exist\\n            .json\\n              \/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble.json doesn\\'t exist',\r\n  showStack: false,\r\n  showProperties: true,\r\n  plugin: 'webpack-stream',\r\n  __safety: { toString: [Function: bound ] } }<\/pre>\n<p>NO SOLUTION YET:<br \/>\nI&#8217;VE TRIED FROM https:\/\/laracasts.com\/discuss\/channels\/elixir\/laravel-53-error-on-gulp-execution?page=1<\/p>\n<pre class=\"lang:default decode:true \">npm install buble --save-dev\r\nnpm install vue-loader --save-dev<\/pre>\n<p>BUT FAILED AND GOT THIS ERROR<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/laravel-quiz$ gulp\r\n[22:04:55] Using gulpfile ~\/Documents\/works\/laravel\/laravel-quiz\/gulpfile.js\r\n[22:04:55] Starting 'all'...\r\n[22:04:55] Starting 'sass'...\r\n[22:04:56] Finished 'sass' after 1.59 s\r\n[22:04:56] Starting 'webpack'...\r\n\/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/laravel-elixir-webpack-official\/node_modules\/webpack\/node_modules\/loader-runner\/lib\/loadLoader.js:35\r\n\t\t\tthrow new Error(\"Module '\" + loader.path + \"' is not a loader (must have normal or pitch function)\");\r\n\t\t\t^\r\n\r\nError: Module '\/home\/teddy\/Documents\/works\/laravel\/laravel-quiz\/node_modules\/buble\/dist\/buble.umd.js' is not a loader (must have normal or pitch function)<\/pre>\n<p>I ALSO TRIED (DONT DO THIS BECAUSE I BROKE THE ENVIRONMENT BINDING!)<\/p>\n<pre class=\"lang:default decode:true \">sudo npm cache clean -f\r\nsudo npm install -g n\r\nsudo n stable<\/pre>\n<p>BECAUSE OF THIS I GOT A HARDTIME AND SPENT MANY ERRORS TO FIX IT (http:\/\/stackoverflow.com\/questions\/37324519\/node-sass-does-not-yet-support-your-current-environment-linux-64-bit-with-false) THROUGH THIS:<\/p>\n<pre class=\"lang:default decode:true \">sudo npm rebuild node-sass<\/pre>\n<p>BUT THE ERROR STILL PERSIST (ON GULP)! DONT KNOW HOW TO FIX IT!!!<br \/>\nI READ gulpfile.js IN &#8216;laravel-quiz&#8217; PROJECT DIFFERENT WITH IN &#8216;quiz&#8217; PROJECT. THEREFORE &#8216;laravel-quiz&#8217; PROJECT USE VUE!!!<\/li>\n<li>Test it live (http:\/\/localhost:8000)<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-home.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1303\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-home-1024x250.png\" alt=\"laravel-quiz-home\" width=\"840\" height=\"205\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-home-1024x250.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-home-300x73.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-home-768x187.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-home-1200x293.png 1200w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-home.png 1213w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>IT RUN WELL<\/li>\n<li>Errors &amp; Solutions:<br \/>\nWhen I want to see the quiz result by submitting the answer (http:\/\/localhost:8000\/second-quiz\/submit), I got this error:<br \/>\n&#8220;ErrorException in QuizResultsController.php line 25:<br \/>\nTrying to get property of non-object&#8221;<br \/>\nSOLUTION: This is because I didn&#8217;t login first. Use http:\/\/localhost:8000\/home to login\/register (I&#8217;ve registered with email: &#8216;advcha@yahoo.com&#8217; and password: &#8216;satria&#8217;) then take the quiz again and answer the above question. Then the result would be showed up like this:<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-result.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1335\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-result.png\" alt=\"laravel-quiz-result\" width=\"583\" height=\"454\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-result.png 583w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2016\/12\/laravel-quiz-result-300x234.png 300w\" sizes=\"auto, (max-width: 583px) 85vw, 583px\" \/><\/a><\/li>\n<li>Others samples for online quiz:<br \/>\n<a href=\"http:\/\/practice.cappassessments.com\/Nrt\/NrtPage.html\">http:\/\/practice.cappassessments.com\/Nrt\/NrtPage.html<\/a> (Shows time to answer question, can drag up or down the answer options, not only can pick the answer, but also can type the answer). There is a job application in upwork for this kind of online quiz: <a href=\"https:\/\/www.upwork.com\/jobs\/_~01d2316bc1f3c2cb84\/\">https:\/\/www.upwork.com\/jobs\/_~01d2316bc1f3c2cb84\/<\/a>.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>source: https:\/\/github.com\/SAIBA0011\/laravel-quiz Description: Laravel-Quiz functionality Create a new quiz Create quiz questions &#8212; single &amp; multi Select show quiz questions Create quiz question options &#8212; Pending.. To be implemented Finish quiz question options. Change question position. Change question option position. Randomize question order on display page. Track user attempts per quiz. Allow user to take &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2016\/12\/29\/laravel-quiz\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Laravel Quiz&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,13],"tags":[],"class_list":["post-1300","post","type-post","status-publish","format-standard","hentry","category-laravel","category-tutorial"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=1300"}],"version-history":[{"count":7,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1300\/revisions"}],"predecessor-version":[{"id":1337,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1300\/revisions\/1337"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=1300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=1300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=1300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}