Welcome Guest, Not a member yet? Register   Sign In
Quiz Questions output
#1

Dear All,

I have a code which is displaying questions in a quiz randomly. I would like the questions to be displayed as entered in the database. What do I need to change?
Reply
#2

Your activity domain :/
Reply
#3

The code for retrieving the questions is as follows

//GET EXAM QUESTION DETAILS (for the Quiz/Exam)
$quizRecords = $this->base_model->run_query(
"select q.*,qq.*,s.subjectid,s.name as subjectname from "
.$this->db->dbprefix('quiz')." q, ".$this->db->dbprefix('quizquestions')
." qq, ".$this->db->dbprefix('subjects')." s 
where qq.quizid=q.quizid and qq.subjectid=s.subjectid and q.quizid=".$id
);
$questArray = array();
foreach ($quizRecords as $r) {
$subjectwiseQuestions = $this->base_model->run_query(
"select * from ".$this->db->dbprefix('questions')
." where subjectid=".$r->subjectid." and difficultylevel='"
.$r->difficultylevel."' and answer1!='' and answer2!='' 
and correctanswer!='' ORDER by rand() LIMIT ".$r->totalquestion
);
array_push($questArray, $subjectwiseQuestions);
}
$this->data['quiz_info'] = $quizRecords;

if ($this->session->userdata('isExamStarted') == 1) {
$this->session->set_userdata('questions', $questArray);
$answers = '';
foreach ($this->session->userdata('questions') as $row) {
foreach ($row as $q) {
$answers[$q->questionid] = $q->correctanswer;
}
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB