Welcome Guest, Not a member yet? Register   Sign In
Quiz Questions output
#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


Messages In This Thread
Quiz Questions output - by cndunga - 10-17-2016, 06:21 AM
RE: Quiz Questions output - by drusnac19 - 10-17-2016, 01:43 PM
RE: Quiz Questions output - by cndunga - 10-18-2016, 01:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB