Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,042 members, 7,818,090 topics. Date: Sunday, 05 May 2024 at 07:27 AM

Urgent Help 4rm My Esteemed Webmasters! - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Urgent Help 4rm My Esteemed Webmasters! (831 Views)

Collect And Extract Emails,phone And Fax Numbers 4rm The Websites Around D World / How To Translate A Scanned Jpeg Document Into English: Urgent Help Pls! / Urgent: Help Recover My Article Site Admin's - Articlebeach Script (2) (3) (4)

(1) (Reply) (Go Down)

Urgent Help 4rm My Esteemed Webmasters! by Benny95(m): 12:01pm On Dec 18, 2013
So I'm working on a computer based test(CBT) web app, on a php platform, I'v gon a lil far in it, upto d point of rendering d questions(randomly) 2d user, my problem nw is how do I mark d test and give d user his/her score? Just a pseudo, thanks in anticipation.
Re: Urgent Help 4rm My Esteemed Webmasters! by Afam4eva(m): 12:05pm On Dec 18, 2013
Benny95: So I'm working on a computer based test(CBT) web app, on a php platform, I'v gon a lil far in it, upto d point of rendering d questions(randomly) 2d user, my problem nw is how do I mark d test and give d user his/her score? Just a pseudo, thanks in anticipation.
Shouldn't you have a database of the questions and the answers such that it juxtaposes the user's answer to the correct and answer and assign a score and at the end, it does a calculation to arrive at the final score.
Re: Urgent Help 4rm My Esteemed Webmasters! by Benny95(m): 12:12pm On Dec 18, 2013
Afam4eva:
Shouldn't you have a database of the questions and the answers such that it juxtaposes the user's answer to the correct and answer and assign a score and at the end, it does a calculation to arrive at the final score.

Yeah I do, I'm using mongoDB as d database, I can also use mysql tho, I'm just looking 4 a way 2 loop through all d user-supplied answers and compare to the answers in my DB........fanks
Re: Urgent Help 4rm My Esteemed Webmasters! by elvis10ten(m): 5:24pm On Dec 18, 2013
Benny95:

Yeah I do, I'm using mongoDB as d database, I can also use mysql tho, I'm just looking 4 a way 2 loop through all d user-supplied answers and compare to the answers in my DB........fanks


<?php
$pos = 0;
$db = new mysqli('server', 'username', 'password', 'dbName');
if($db->connect_errno > 0) {
die('Unable to connect to database'.$db->connect_error);
}
$stmt = $db->prepare("SELECT `id`, `answer` FROM `question` LIMIT ?, 10"wink;
$stmt->bind_param('i', $pos);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id, $answer);
while($stmt->fetch()) {
$answers[$id] = $answer;
}
$db->close();
$score = 0;
foreach($_POST as $key => $value) {
if($value == $answers[$key]) {
$score += 1;
}
}
?>

please edit the query and other mysqli_ ish stuff. The code above expect your html input tag names to be the id of the question from the db.
Re: Urgent Help 4rm My Esteemed Webmasters! by Benny95(m): 1:05am On Dec 19, 2013
elvis10ten:


<?php
$pos = 0;
$db = new mysqli('server', 'username', 'password', 'dbName');
if($db->connect_errno > 0) {
die('Unable to connect to database'.$db->connect_error);
}
$stmt = $db->prepare("SELECT `id`, `answer` FROM `question` LIMIT ?, 10"wink;
$stmt->bind_param('i', $pos);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id, $answer);
while($stmt->fetch()) {
$answers[$id] = $answer;
}
$db->close();
$score = 0;
foreach($_POST as $key => $value) {
if($value == $answers[$key]) {
$score += 1;
}
}
?>

please edit the query and other mysqli_ ish stuff. The code above expect your html input tag names to be the id of the question from the db.
Thanks!
Re: Urgent Help 4rm My Esteemed Webmasters! by elvis10ten(m): 10:04am On Dec 19, 2013
Benny95: Thanks!
ur welcome.

(1) (Reply)

I Need A Software That Can Extract Phone Number / Where Is This Tremendous Traffic To My Blog Coming From? / I Need To Send Bulk Sms! Help Me Out!

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.