In an old site (from 6 years ago) I had several quizzes which were in PHP with scores and names saved to a small database. The app I used for the quizzes was freely available on line. The PHP version I used is now way obsolete and my current hosting provider no longer supports that version. It's been years since I did anything in PHP and I'm so rusty even looking at PHP 4 that I can't figure out how to fix/update the deprecated and unsupported code. I'm looking for quiz software that will allow mult choice, scoring after the test is taken, display of the user's answers with the correct choices shown (and reasons if needed) and storage to a database so users can see their scores compared to other test takers. Any suggestions?
There's a few here, not sure if any meet your requirements: https://codecanyon.net/category/php-scripts?term=quiz
You can find some here https://www.hotscripts.com/category/scripts/php/scripts-programs/tests-quizzes/ or you can easily make your own, its not that difficult.
Those all require a fee. My application is a hobby, not supported by an enterprise. ===================== Most of those are very obsolete or dead links. I wish I remembered enough PHP to update the version which used to work.
Get your old one and upgrade it. It'll be a few commands, change the database calls so that they're pdo. Will be an interesting learning project.
1. Run locally on my hosted web server 2. Current php/mysql versions (most of the ones I reviewed use obsolete php) 3. Ideally allow me to format page how I want (like use html <form> tag) 4. When test completes, give score and link to answer key page 5. Allow quiz taker to visit score page showing all takers' scores I've been using Quiz-o-matic '76 By Matt Hughes (http://www.ebto.org.tr/test/) which has all these features. But I think it's in php 4 and my host is using 7.2 now so the code won't run any longer.
What about these options: manage quiz in your existing admin section have more than one quiz at a time have a start date & time, end date & time for each quiz show visitors the results after voting show visitors the results without voting allow visitors to change their vote limit votes to logged-in visitors limit votes to one per IP address limit votes to one per email address show old quiz results
The old php code did all of that except these: allow visitors to change their vote limit votes to logged-in visitors limit votes to one per IP address limit votes to one per email address which I don't need. I'm trying to update the v. 4 php myself but since I haven't used it in over 15 years, it's not easy.
Here's one. Can't seem to get this to work to make a table in a db. From a function.inc file: ... function Create_Table($testname, $answerarray) { $sql = "CREATE TABLE $testname ( id SMALLINT(5) NOT NULL AUTO_INCREMENT, name varchar(30), score int, date DATETIME DEFAULT NULL, PRIMARY KEY (id), UNIQUE id (id) )"; $result = mysqli_query($sql) or die("Cannot create table: ".mysqli_error()); $numberofquestions = count($answerarray); for($i=1 ;$i<=$numberofquestions ; $i++) { $newfieldname="q$i"; $sql = "alter table $testname add column $newfieldname tinyint(1)"; $result = mysqli_query($sql) or die("Cannot update table: ".mysqli_error()); } } ... PHP: Used to store quiz name and details in the db with this code: <?php ... include ("functions.inc"); $db = Open_Database ($server, $user, $password, $database); if (!Table_Exists($_POST['testname'])) { Create_Table(($_POST['testname']), $answerarray); } $testname = $_POST['testname']; Create_Response_Array ($responses, $questions, $answerarray); Create_CorrectAnswer_Array ($responses, $answerarray, $correctanswers); ... ?> PHP: No errors thrown but the table isn't created. All the db access specs are checked and correct. Can't see why this code won't work. I updated all the quiz mechanics to php 7.2 and the quiz itself now works ok, scoring and all. But can't get it to write the table to the db.
Because you're not distributing the script just scrap the whole function making the table, open up phpMyAdmin and make it manually. So in the second script snippet you don't need the Table_Exists function call.
I have dozens of quizzes so making tables for all of them, with variable numbers of questions, would be a huge job. That's why I'm trying to use the old script which used to work with no problem.
you don't have one table per quiz If your script is any good you'll have quiz (`id`,`name`,`questions`, `options`) I'd have options as a text field where each new line is a choice answers (`id`, `quiz_id`, `answer`, `created`, `ip`)
Modify the function like this and try again. function Create_Table($testname, $answerarray) { global $db; $sql = "CREATE TABLE $testname ( id SMALLINT(5) NOT NULL AUTO_INCREMENT, name varchar(30), score int, date DATETIME DEFAULT NULL, PRIMARY KEY (id), UNIQUE id (id) )"; $result = mysqli_query($db, $sql) or die("Cannot create table: ".mysqli_error()); $numberofquestions = count($answerarray); for($i=1 ;$i<=$numberofquestions ; $i++) { $newfieldname="q$i"; $sql = "alter table $testname add column $newfieldname tinyint(1)"; $result = mysqli_query($db, $sql) or die("Cannot update table: ".mysqli_error()); } } Code (php): ...
Tried and no go. Table not created. The only difference between what I was trying and what you suggested is the global statement. I had already modified the query statements to include the $link ($db). I accidentally picked an older code version to put here instead of the one with the $link that mysqli needs. No error is shown when I run the script.
Post the code of your "Open_Database" function please. Make sure Error_reporting is not turned off. I am thinking error_reporting is off, that is why script is not showing errors. What are you seeing on the webpage when you run the script? You must be seeing something, if not errors...
function Open_Database($server, $user, $password, $database) { $db = mysqli_connect($server,$user,$password,$database) or die("Cannot connect to database: ".mysqli_connect_error()); return $db; } PHP: I do see errors that stop the script from running. Don't know how to check error reporting. I don't have access to the server's php.ini. I get the full results of the scoring and answer display with no errors shown. But nothing gets written to the mysql database.