Quizzin with scorings from users
(9 posts) (3 voices)-
Hi,
i would like to be able to save user info and his scoring after completing a quiz, to show some kind of High Score user rating on the quiz. Could you give me some tips where I should start to implement this kind of functionality for your Quizzin plugin, or have you done it yourself already?
Kind regards,
JimPosted 3 years ago # -
Take a look at the code - its mostly understandable. You will have to create a few tables to store the data. Also, look at the Surveys plugin - it does what you want - but its not a Quiz plugin. You can copy the code from that plugin to the Quiz plugin.
Get the latest(beta version) of the surveys plugin here...
viewtopic.php?f=14&t=317#p648Posted 3 years ago # -
Hi,
I'm working on the feature to save score results and therefor I want to create a new table on the database, but with this code it isn't working. I have to add the
'quiz_users_scores' table manually in phpMyAdmin, because the following code doesn't create the tables upon activation of the plugin.
I've added an extra register activation hook, but that isn't helping either.
Can you help me further?
add_action('activate_quizzin/quizzin.php','quizzin_activate');
function quizzin_activate() {
global $wpdb;
$database_version = '3';
$installed_db = get_option('quizzin_db_version');
// Initial options.
add_option('quizzin_show_answers', 1);
add_option('quizzin_single_page', 0);
if($database_version != $installed_db) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$sql = "CREATE TABLE {$wpdb->prefix}quiz_answer (
ID int(11) unsigned NOT NULL auto_increment,
question_id int(11) unsigned NOT NULL,
answer varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
correct enum('0','1') NOT NULL default '0',
sort_order int(3) NOT NULL default 0,
PRIMARY KEY (ID)
);
CREATE TABLE {$wpdb->prefix}quiz_question (
ID int(11) unsigned NOT NULL auto_increment,
quiz_id int(11) unsigned NOT NULL,
question mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
sort_order int(3) NOT NULL default 0,
explanation mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (ID),
KEY quiz_id (quiz_id)
);
CREATE TABLE {$wpdb->prefix}quiz_quiz (
ID int(11) unsigned NOT NULL auto_increment,
name varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
description mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
final_screen mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
added_on datetime NOT NULL,
PRIMARY KEY (ID)
);
CREATE TABLE {$wpdb->prefix}quiz_users_scores (
quiz_id int(11) unsigned NOT NULL,
user_id int(11) unsigned NOT NULL,
percentage int(11) unsigned NOT NULL,
grade int(11) unsigned NOT NULL,
rating varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
played_on varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
user_name varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
user_email varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
quiz_name varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (quiz_id, user_id)
);";
dbDelta($sql);
update_option( "quizzin_db_version", $database_version );
}
}
// added register activation hook
register_activation_hook(__FILE__,'quizzin_activate');Posted 3 years ago # -
Try changing the $database_version. Make it...
$database_version = '4';Posted 3 years ago # -
we're you able to have this working jim?Posted 3 years ago #
-
Jim! did you accomplish your task!
Please, post your code here!!!Posted 3 years ago # -
i just want to ask binnyva if there are any plans to implement such a feature
Posted 3 years ago # -
Its possible - but its not high on my priority list. Maybe when I get some free time - very rare these days.Posted 3 years ago #
-
Just wanted to agree with the request for saving of scores/results. Some sort of amalgamation of the Surveys plugin and Quizzin would be great!
Would be nice to know if Jim had any success too...
Nice work though.Posted 2 years ago #
Reply
You must log in to post.