source: https://github.com/SAIBA0011/laravel-quiz
Description:
Laravel-Quiz functionality
Create a new quiz
Create quiz questions — single & multi Select
show quiz questions
Create quiz question options — 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 quiz.
allow user to complete quiz.
show quiz results on complete.
Installation:
- Create a new laravel project:
1composer create-project --prefer-dist laravel/laravel laravel-quiz
- Download the app from https://github.com/SAIBA0011/laravel-quiz. It’s better to donwload in zip file then extract the content in /works/laravel/quiz/ directory. Overwrite the existing files and directories.
- Install the laravel component required:
1composer install
- Create a new database ‘laravel_quiz’ by phpmyadmin
- Use ‘php artisan migrate’ to create the tables.
NOTE: I got this error when trying to do ‘migrate’
“teddy@teddy-K43SJ:~/Documents/works/laravel/laravel-quiz$ php artisan migrate
Migration table created successfully.[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i
n your SQL syntax; check the manual that corresponds to your MySQL server v
ersion for the right syntax to use near ‘) on delete cascade’ at line 1 (SQ
L: alter tablequiz_resultsadd constraintquiz_results_user_id_foreign
foreign key (user_id) referencesusers() on delete cascade)
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i
n your SQL syntax; check the manual that corresponds to your MySQL server v
ersion for the right syntax to use near ‘) on delete cascade’ at line 1 ”
SOLUTION: At first, I did like in the articles http://stackoverflow.com/questions/26820788/add-on-delete-cascade-to-existing-column-in-laravel and http://stackoverflow.com/questions/28167329/laravel-migration-remove-ondeletecascade-from-existing-foreign-key on ‘2016_10_24_101046_create_quiz_results_table.php’ in /database/migrations/ directory BUT SOMEHOW IT DIDN’T WORK
1234567$table->dropForeign('quiz_results_user_id_foreign');$table->foreign('user_id')->reference('id')->on('users')->onDelete('cascade');//$table->foreign('user_id')->reference('id')->on('users');$table->dropForeign('quiz_results_quiz_id_foreign');$table->foreign('quiz_id')->reference('id')->on('quiz')->onDelete('cascade');//$table->foreign('quiz_id')->reference('id')->on('quiz');
SO I JUST COMMENT THE ‘onDelete’ COMMAND
12//$table->foreign('user_id')->reference('id')->on('users')->onDelete('cascade');//$table->foreign('quiz_id')->reference('id')->on('quiz')->onDelete('cascade');
THEN THE MIGRATIONS RUN WELL. - generate the new key
1php artisan key:generate - Install npm modules and gulp
1npm install
BUT SOMEHOW I GOT THIS ERROR ON ‘gulp’
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354teddy@teddy-K43SJ:~/Documents/works/laravel/laravel-quiz$ gulp[20:44:18] Using gulpfile ~/Documents/works/laravel/laravel-quiz/gulpfile.js[20:44:18] Starting 'all'...[20:44:18] Starting 'sass'...[20:44:20] Finished 'sass' after 1.6 s[20:44:20] Starting 'webpack'...{ [Error: Entry module not found: Error: Can't resolve 'buble' in '/home/teddy/Documents/works/laravel/laravel-quiz'resolve 'buble' in '/home/teddy/Documents/works/laravel/laravel-quiz'Parsed request is a moduleusing description file: /home/teddy/Documents/works/laravel/laravel-quiz/package.json (relative path: .)after using description file: /home/teddy/Documents/works/laravel/laravel-quiz/package.json (relative path: .)resolve as modulemodule variation buble-loader/home/teddy/Documents/works/laravel/node_modules doesn't exist or is not a directory/home/teddy/Documents/node_modules doesn't exist or is not a directory/home/teddy/Documents/works/node_modules doesn't exist or is not a directory/home/teddy/node_modules doesn't exist or is not a directory/home/node_modules doesn't exist or is not a directory/node_modules doesn't exist or is not a directorylooking for modules in /home/teddy/Documents/works/laravel/laravel-quiz/node_modulesusing description file: /home/teddy/Documents/works/laravel/laravel-quiz/package.json (relative path: ./node_modules)after using description file: /home/teddy/Documents/works/laravel/laravel-quiz/package.json (relative path: ./node_modules)using description file: /home/teddy/Documents/works/laravel/laravel-quiz/package.json (relative path: ./node_modules/buble-loader)as directory/home/teddy/Documents/works/laravel/laravel-quiz/node_modules/buble-loader doesn't existno extension/home/teddy/Documents/works/laravel/laravel-quiz/node_modules/buble-loader doesn't exist.js/home/teddy/Documents/works/laravel/laravel-quiz/node_modules/buble-loader.js doesn't exist.json/home/teddy/Documents/works/laravel/laravel-quiz/node_modules/buble-loader.json doesn't exist/home/teddy/Documents/works/laravel/node_modules doesn't exist or is not a directory/home/teddy/Documents/node_modules doesn't exist or is not a directory/home/teddy/Documents/works/node_modules doesn't exist or is not a directory/home/teddy/node_modules doesn't exist or is not a directory/home/node_modules doesn't exist or is not a directory/node_modules doesn't exist or is not a directorylooking for modules in /home/teddy/Documents/works/laravel/laravel-quiz/node_modulesusing description file: /home/teddy/Documents/works/laravel/laravel-quiz/package.json (relative path: ./node_modules)after using description file: /home/teddy/Documents/works/laravel/laravel-quiz/package.json (relative path: ./node_modules)using description file: /home/teddy/Documents/works/laravel/laravel-quiz/package.json (relative path: ./node_modules/buble)as directory/home/teddy/Documents/works/laravel/laravel-quiz/node_modules/buble doesn't existno extension/home/teddy/Documents/works/laravel/laravel-quiz/node_modules/buble doesn't exist.js/home/teddy/Documents/works/laravel/laravel-quiz/node_modules/buble.js doesn't exist.json/home/teddy/Documents/works/laravel/laravel-quiz/node_modules/buble.json doesn't exist]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',showStack: false,showProperties: true,plugin: 'webpack-stream',__safety: { toString: [Function: bound ] } }
NO SOLUTION YET:
I’VE TRIED FROM https://laracasts.com/discuss/channels/elixir/laravel-53-error-on-gulp-execution?page=1
12npm install buble --save-devnpm install vue-loader --save-dev
BUT FAILED AND GOT THIS ERROR
1234567891011teddy@teddy-K43SJ:~/Documents/works/laravel/laravel-quiz$ gulp[22:04:55] Using gulpfile ~/Documents/works/laravel/laravel-quiz/gulpfile.js[22:04:55] Starting 'all'...[22:04:55] Starting 'sass'...[22:04:56] Finished 'sass' after 1.59 s[22:04:56] Starting 'webpack'.../home/teddy/Documents/works/laravel/laravel-quiz/node_modules/laravel-elixir-webpack-official/node_modules/webpack/node_modules/loader-runner/lib/loadLoader.js:35throw new Error("Module '" + loader.path + "' is not a loader (must have normal or pitch function)");^Error: 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)
I ALSO TRIED (DONT DO THIS BECAUSE I BROKE THE ENVIRONMENT BINDING!)
123sudo npm cache clean -fsudo npm install -g nsudo n stable
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:
1sudo npm rebuild node-sass
BUT THE ERROR STILL PERSIST (ON GULP)! DONT KNOW HOW TO FIX IT!!!
I READ gulpfile.js IN ‘laravel-quiz’ PROJECT DIFFERENT WITH IN ‘quiz’ PROJECT. THEREFORE ‘laravel-quiz’ PROJECT USE VUE!!! - Test it live (http://localhost:8000)
IT RUN WELL - Errors & Solutions:
When I want to see the quiz result by submitting the answer (http://localhost:8000/second-quiz/submit), I got this error:
“ErrorException in QuizResultsController.php line 25:
Trying to get property of non-object”
SOLUTION: This is because I didn’t login first. Use http://localhost:8000/home to login/register (I’ve registered with email: ‘advcha@yahoo.com’ and password: ‘satria’) then take the quiz again and answer the above question. Then the result would be showed up like this:
- Others samples for online quiz:
http://practice.cappassessments.com/Nrt/NrtPage.html (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: https://www.upwork.com/jobs/_~01d2316bc1f3c2cb84/.