Commit 2013590a by Hussain Mohamed

changes

parent ac484f0e
......@@ -14,3 +14,5 @@ $route['logout'] = 'AuthController/logout';
$route['recover'] = 'auth/forgetpassword';
$route['verification'] = 'auth/recovery_verification';
$route['privacy'] = 'auth/privacy_policy';
$route['takeExam/(:any)/(:any)/(:any)/'] = "ExamController/takeExam/$1/$1/$1";
\ No newline at end of file
......@@ -28,7 +28,7 @@ class ExamController extends CI_Controller
public function getExamQuestions()
{
$this->db->select('y.year, es.academic,u.email,es.id as sid,ea.question_category,es.exam_schedule, es.objective_date, es.objective_time, es.id,et.exam_type_name as name');
$this->db->select('y.year, es.academic,u.email,es.id as sid,ea.question_category,ea.user_id,es.exam_schedule, es.objective_date, es.objective_time, es.id,et.exam_type_name as name');
$this->db->from('question as q');
$this->db->join('exam_schedule as es', 'es.id = q.schedule_id', 'left');
$this->db->join('accadamic_year as y', 'y.id = q.academic', 'left');
......@@ -41,16 +41,28 @@ class ExamController extends CI_Controller
return $result = $query->result();
}
public function takeExam($id)
public function takeExam($user,$sid,$cat)
{
$view_data['questions']=$this->mcommon->getExamQuestions();
$view_data['questions']=$this->mcommon->getExamQuestions($cat);
$authId = 1;
date_default_timezone_set('Asia/Calcutta');
$date = date('Y-m-d h:i:s',strtotime("+40 minutes"));
$time = date('h:i:s',strtotime("+40 minutes"));
$view_data['time'] = $time;
$view_data['date'] = $date;
$view_data['userData'] = array(
'userId' => $user,
'categoryId' => $cat,
"schedule"=> $sid
);
$examId = $this->mcommon->specific_row_value('exam_assigned',array("user_id"=>$user,"schedule"=>$sid,"question_category"=>$cat),"id");
if($examId != null && $examId > 0 && $examId != '')
{
$updateArray = array('is_attend' => 1,'start_date'=>date('Y-m-d h:i:s'),'end_date'=>$date);
$this->mcommon->common_edit('exam_assigned',$updateArray,array('id'=>$examId));
}
$data = array(
'title' => 'View Exam',
......@@ -62,7 +74,32 @@ class ExamController extends CI_Controller
public function storeExam()
{
echo "<pre>";print_r($_POST);
$userId = $this->input->post('user_id');
$schedule_id = $this->input->post('schedule_id');
$category_id = $this->input->post('category_id');
$question = $this->input->post('question');
$questions = $this->input->post('questions');
$org = $this->input->post('org_ques');
$examId = $this->mcommon->specific_row_value('exam_assigned',array("user_id"=>$userId,"schedule"=>$schedule_id,"question_category"=>$category_id),"id");
if($examId != null && $examId > 0 && $examId != '')
{
foreach($question as $key=>$val)
{
$insertArr = array(
'exam_id' => $examId,
'question_id' => $val,
'org_answer' =>$org[$key],
'user_id' => $userId,
'schedule_id' => $schedule_id,
'category_id' => $category_id,
'answers' => $questions[$val]
);
$this->mcommon->common_insert('exam_attend',$insertArr);
}
redirect('ExamController/viewExam');
}
}
}
......
......@@ -424,11 +424,12 @@ class Common_model extends CI_Model
return $result;
}
public function getExamQuestions()
public function getExamQuestions($cat)
{
$this->db->select('c.category, c.id as categoryId, q.id, q.question, q.option_a, q.option_b, q.option_c, q.option_d, q.answer');
$this->db->from('question as q');
$this->db->join('section_category as c', 'c.id = q.category', 'left');
$this->db->where('q.question_category',$cat);
$query = $this->db->get()->result();
$groupByArr = [];
foreach($query as $key=>$val)
......
......@@ -58,6 +58,9 @@
$tot = 0;
$j = 1; ?>
<form method="POST" action="<?= base_url('ExamController/storeExam') ?>">
<input type="hidden" name="user_id" value="<?= $userData['userId'] ?>" />
<input type="hidden" name="schedule_id" value="<?= $userData['schedule'] ?>" />
<input type="hidden" name="category_id" value="<?= $userData['categoryId'] ?>" />
<div class="tab-content">
<?php foreach ($questions as $key => $val) { ?>
<div class="Questiontab<?= $j ?>" style="display:<?= ($j > 1) ? 'none':'block' ?>">
......@@ -154,33 +157,21 @@
updateTime();
}, 1000);
function previousQuestion(page)
{
$pre = page - 1;
$next = page + 1;
$('.Questiontab'+page).hide();
if(page == 1)
{
$('.Questiontab'+page).show();
}else{
$('.Questiontab'+$pre).show();
}
function previousQuestion(page) {
var pre = page - 1;
$('.Questiontab' + page).hide();
if (pre == 0) {
$('.Questiontab1').show();
} else {
$('.Questiontab' + pre).show();
}
}
function nextQuestion(page)
{
$pre = page - 1;
$next = page + 1;
$('.Questiontab'+$next).show();
if(page == 1)
{
$('.Questiontab'+page).hide();
}else{
$('.Questiontab'+$next).hide();
}
// $('.Questiontab'+$pre).hide();
}
function nextQuestion(page) {
var next = page + 1;
$('.Questiontab' + page).hide();
$('.Questiontab' + next).show();
}
</script>
......@@ -84,7 +84,7 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Start Exam</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<button type="button" onclick="close()" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<input type="hidden" id="userId" value=""/>
......@@ -140,9 +140,9 @@ original sentence. (5 marks)</h5>
<script>
//user,sid,cat
function takeExam(user,sid,cat)
{ $('#userId').val(cat);
$('#Sid').val(user);
$('#Cat').val(sid);
{ $('#userId').val(user);
$('#Sid').val(sid);
$('#Cat').val(cat);
$('#examModal').modal('show');
}
......@@ -156,9 +156,12 @@ function close()
function startExam(id)
{
var user = $('#userId').val();
var sid = $('#Sid').val();
var cat = $('#Cat').val();
if(confirm("are you sure want to start exam?") === true)
{
var url = "<?= base_url('ExamController/takeExam/') ?>"+id;
var url = "<?= base_url('ExamController/takeExam/') ?>"+user+"/"+sid+"/"+cat;
window.location=url;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment