function edit_admin($cid = '') { if (!common::is_logged_in()) { redirect('login'); } if ($cid == '') { redirect('admn'); } $data['error'] = ""; $data['num'] = $this->mod_admin->get_admin_info(); if ($_POST['save']) { if ($this->form_validation->run('valid_admin') && $data['num'] == 0) { $data = array('user_id' => $_POST['user_name'], 'password' => $_POST['password'], 'email' => $_POST['email']); $this->db->update('admin', $data, array('id' => $cid)); $data['new'] = $_POST['user_name']; $data['current'] = $this->session->userdata('user_id'); $this->session->set_userdata('user_id', $data['new']); $this->session->set_flashdata('msg', "<div class='success'>Content Changed Successfully</div>"); redirect('admn'); } else { $this->session->set_flashdata('msg', "<div class='error'>User Exist,choose another name</div>"); redirect('admn'); } } $data = sql::row('admin', 'id=' . $cid); $data['error'] = $err ? $err : ''; $data['dir'] = 'admn'; $data['action'] = 'admn/edit_admin/' . $cid; $data['page'] = 'add_admn'; $data['page_title'] = "Edit"; $this->load->view('main', $data); }
function edit_user($user_id = '') { if (!common::update_permit()) { common::redirect(); } if ($_POST['save']) { if ($this->form_validation->run('valid_user')) { $this->mod_user->update_user(); //Don't Change $this->session->set_flashdata('msg', 'Content Updated Successfully!'); redirect('user'); } } $id = $user_id; if ($id == '') { redirect('user'); } $data = sql::row("scic_user", "id={$id}"); $this->session->set_userdata('edit_user_id', $data['id']); //Don't Change $data['nav_array'] = array(array('title' => 'Manage Users', 'url' => site_url('user')), array('title' => 'Add New User', 'url' => '')); $data['dir'] = 'user'; $data['action'] = 'user/edit_user/' . $user_id; $data['page'] = 'user_form'; //Don't Change $data['page_title'] = 'Edit User'; $this->load->view('main', $data); }
function edit_question($id = '') { if ($_POST['save']) { if ($this->form_validation->run('new_question')) { if ($this->question_model->update_question()) { //$this->session->unset_userdata('edit_qid'); $this->session->set_flashdata('msg', 'Question Updated Successfully!!!'); redirect('question'); } } } $this->session->set_userdata('edit_qid', $id); $data = sql::row('scic_question', 'id=' . $id); $multi_answer = sql::row('scic_multi_ans', 'qid=' . $id); $answer = sql::row('scic_answer', 'ans_number=' . $id, 'answer'); $data['answer'] = $answer; $data['multi_answer'] = $multi_answer; $data['msg'] = $this->session->flashdata('msg'); $data['action'] = 'question/edit_question'; $data['dir'] = 'shorturl'; $data['page'] = 'add_url'; $data['page_title'] = 'Edit Questions'; $this->load->view('main', $data); }
function sendEmail($id) { // parameters of your mail server and how to send your email $config = array('protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => '*****@*****.**', 'smtp_pass' => 'testpasswdxxx', 'mailtype' => 'html'); $data = sql::row("scic_result", "user_id={$id}"); $count = sql::count("scic_question", "type='1' and status='active'"); $mul_marks = $data['first_part'] / $count * 100; $count = sql::count("scic_question", "type='1' and status='active'"); $count_mth = sql::count("scic_question", "type='2' and status='active'"); $math_marks = $data['second_part'] / $count_mth * 100; $name = sql::row("scic_skillset", "user_id={$id}"); $t_tme = common::time_diff($name['left_time'], $name['arrival_time']); $sql = "SELECT * FROM scic_general,scic_question WHERE user_id={$id} and id=ans_number and scic_general.type='0' and scic_question.type='0'"; $query = $this->db->query($sql, array($type)); $result = $query->result_array(); // recipient, sender, subject, and you message $to = "*****@*****.**"; $from = "*****@*****.**"; $subject = "Test Result::" . $name['fullname']; $message = "Candidate Name: " . $name['fullname'] . "</br> Candidate Email: " . $data['email'] . "</br> Marks in General: " . $data['general'] . "</br> Marks in first part:" . $mul_marks . " Percent(" . $data['first_part'] . " right answer among " . $count . " problems) </br> Marks in Second Part:" . $math_marks . " Percent(" . $data['second_part'] . " right answer among " . $count_mth . " problems) </br> Marks in Third Part: " . $data['third_part'] . "</br> Total Time Taken: " . $t_tme . " Seconds </br> </br>"; $message .= "****<strong><u>Test Details::General Section</u></strong>**** </br>"; foreach ($result as $row) { $message .= "<strong>" . $row['texts'] . "</strong></br><strong><u>Ans: </u></strong>" . $row['answer'] . "</br>"; } $sql = "SELECT texts,scic_part_i.answer as given_answer,scic_answer.answer as org_answer,first,second,third,fourth FROM scic_part_i,scic_question,scic_multi_ans,scic_answer WHERE scic_part_i.user_id={$id} and scic_question.id=scic_part_i.ans_number and scic_answer.ans_number=scic_part_i.ans_number and scic_answer.type='1' and scic_part_i.type=scic_question.type and scic_multi_ans.qid=scic_part_i.ans_number"; $query = $this->db->query($sql, array($type)); $result = $query->result_array(); $message .= "</br>****<strong><u>Test Details::Multiple Choice Section</u></strong>**** </br>"; foreach ($result as $row) { if ($row['given_answer'] == "a") { $mul = $row['first']; if ($row['given_answer'] != $row['org_answer']) { $mul = $mul . "(<font color='red'>Wrong Answer</font>)"; } } else { if ($row['given_answer'] == "b") { $mul = $row['second']; if ($row['given_answer'] != $row['org_answer']) { $mul = $mul . "(<font color='red'>Wrong Answer</font>)"; } } else { if ($row['given_answer'] == "c") { $mul = $row['third']; if ($row['given_answer'] != $row['org_answer']) { $mul = $mul . "(<font color='red'>Wrong Answer</font>)"; } } else { if ($row['given_answer'] == "d") { $mul = $row['fourth']; if ($row['given_answer'] != $row['org_answer']) { $mul = $mul . "(<font color='red'>Wrong Answer</font>)"; } } else { $mul = "None(<font color='red'>Wrong Answer</font>)"; } } } } $message .= "<strong>" . $row['texts'] . "</strong></br><strong><u>Ans: </u></strong>" . $mul . "</br>"; } $sql = "SELECT texts,scic_part_ii.answer as given_answer,scic_answer.answer as org_answer FROM scic_part_ii,scic_question,scic_answer WHERE scic_part_ii.user_id={$id} and scic_question.id=scic_part_ii.ans_number and scic_part_ii.type=scic_question.type and scic_answer.type='2' and scic_answer.ans_number=scic_part_ii.ans_number"; $query = $this->db->query($sql, array($type)); $result = $query->result_array(); $message .= "</br>****<strong><u>Test Details::Math Section</u></strong>**** </br>"; foreach ($result as $row) { if ($row['given_answer'] != $row['org_answer']) { $mul = $row['given_answer'] . "(<font color='red'>Wrong Answer</font>)"; } else { $mul = $row['given_answer']; } //"None(<font color='red'>Wrong Answer</font>)"; $message .= "<strong>" . $row['texts'] . "</strong></br><strong><u>Ans: </u></strong>" . $mul . "</br>"; } $sql = "SELECT * FROM scic_part_iii,scic_question WHERE user_id={$id} and id=ans_number and scic_part_iii.type=scic_question.type"; $query = $this->db->query($sql, array($type)); $result = $query->result_array(); $message .= "</br>****<strong><u>Test Details::Scenerio Section</u></strong>**** </br>"; foreach ($result as $row) { $message .= "<strong>" . $row['texts'] . "</strong></br><strong><u>Ans: </u></strong>" . $row['answer'] . "</br>"; } // load the email library that provided by CI //$this->load->library('email', $config); $this->load->library('email'); // this will bind your attributes to email library //$this->email->set_newline("\r\n"); $this->email->from($from, 'Space Coast IC'); $this->email->to($to); $this->email->subject($subject); $this->email->message($message); $this->email->set_mailtype("html"); // send your email. if it produce an error it will print 'Fail to send your message!' for you if ($this->email->send()) { $sql = "update scic_result set\n notification=1\n where user_id={$id}"; return $this->db->query($sql); } else { echo "Fail to send your message!"; } }
function submit_third_part() { $data['msg'] = ""; $logged_in = $this->session->userdata('logged_in'); $type = $this->session->userdata('type'); if ($logged_in && $type == 'part_iii') { if (isset($_POST['submit_math'])) { if ($this->answer_submission->submit_third()) { $check = sql::row("scic_result", "user_id={$logged_in}"); if ($check['first_part'] != -1 && $check['second_part'] != -1 && $check['notification'] == 0) { $this->answer_submission->sendEmail($logged_in); } $data['msg'] = "You have successfully completed the Third part question section. Please <a href='" . site_url('logout') . "'>click here</a> to continue."; } else { $data['msg'] = "Something Wrong."; } } } else { $data['msg'] = "Do not adopt unfair means. <a href='" . site_url('logout') . "'>click here</a> to continue."; } $data['title'] = 'Test Done!!'; $data['dir'] = 'general'; $data['page'] = 'success'; $this->load->view('main', $data); }
function edit_url($id = '') { if ($_POST['save']) { if ($this->form_validation->run('add_url')) { if ($this->shorturl_model->update_url($id)) { $this->session->set_flashdata('msg', 'Url Updated Successfully!!!'); redirect('shorturl'); } } } $data = sql::row('urls', 'id=' . $id); $data['msg'] = $this->session->flashdata('msg'); $data['dir'] = 'shorturl'; $data['page'] = 'edit_url'; $this->load->view('main', $data); }
function delete_question($id = '') { $ty = sql::row('scic_multi_ans', 'qid=' . $id); if ($ty != null) { $sql = "delete from scic_multi_ans where qid=" . $id; $this->db->query($sql); } $sql = "delete from scic_question where id=" . $id; $this->db->query($sql); $sql = "delete from scic_answer where ans_number=" . $id; return $this->db->query($sql); }
function evaluate_third($user_id = '') { if (!common::update_permit()) { common::redirect(); } $id = $user_id; if ($_POST['save']) { if ($this->form_validation->run('valid_third')) { $this->mod_result->update_third_marks($id); //Don't Change $this->session->set_flashdata('msg', 'Third Part Evaluated Successfully!'); $check = sql::row("scic_result", "user_id={$id}"); if ($check['general'] != -1 && $check['third_part'] != -1 && $check['notification'] == 0) { $this->mod_result->sendEmail($id); } redirect('result'); } } if ($id == '') { redirect('result'); } $data = sql::row("scic_result", "user_id={$id}"); //$this->session->set_userdata('edit_user_id', $data['id']); //Don't Change $data['nav_array'] = array(array('title' => 'Manage Results', 'url' => site_url('result')), array('title' => 'Evaluate Third Part', 'url' => '')); $data['question'] = $this->mod_result->get_third(); $data['answer'] = $this->mod_result->get_third_answer($id); $data['dir'] = 'result'; $data['action'] = 'result/evaluate_third/' . $user_id; $data['page'] = 'third_form'; //Don't Change $data['page_title'] = 'Evaluation'; $this->load->view('main', $data); }