ok

Mini Shell

Direktori : /home2/selectio/public_html/bharath/application/controllers/user/
Upload File :
Current File : /home2/selectio/public_html/bharath/application/controllers/user/Exam_question_paper.php

<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class Exam_question_paper extends Student_Controller
{

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $this->session->set_userdata('top_menu', 'Examinations');
        $this->session->set_userdata('sub_menu', 'Exam_question_paper/index');
        $data['title'] = 'Exam Question Paper';

        $student_id = $this->customlib->getStudentSessionUserID();
        $student = $this->student_model->get($student_id);   
        $data['title_list'] = 'List of Exam Question Paper';
        $student_current_class = $this->customlib->getStudentCurrentClsSection();

        $list = $this->content_model->getListByCategoryforUser($student_current_class->class_id, $student_current_class->section_id,"question_paper");
        $data['list'] = $list;
        
        $answerlist = $this->content_model->getAnswerByStdId($student_id);
        $data['answerlist'] = $answerlist;

        $this->load->view('layout/student/header', $data);
        $this->load->view('user/exam_question_paper/exam_question_paper', $data);
        $this->load->view('layout/student/footer', $data);
    }

   

    public function add_answer(){
     
		 $student_id = $this->customlib->getStudentSessionUserID();
		 $this->form_validation->set_rules('apply_date', $this->lang->line('upload')." ".$this->lang->line('date'), 'trim|required|xss_clean');
		 //$this->form_validation->set_rules('userfile', $this->lang->line('attach_document'), 'trim|required|xss_clean');
        if ($this->form_validation->run() == FALSE) {

            $msg = array(
                'upload_date' => form_error('apply_date'),
                'attach_document' => form_error('userfile'),
                'student_session_id' => form_error('student_session_id'),
                'student_id' => form_error('student_id'),
                'class_id' => form_error('class_id'),
                'section_id' => form_error('section_id'),

            );

            $array = array('status' => 'fail', 'error' => $msg, 'message' => '');
            
        }else{
            $student_session_id=$this->session->userdata['current_class']['student_session_id'];
            $student_id = $this->customlib->getStudentSessionUserID();
            $student = $this->studentsession_model->searchMultiClsSectionByStudent($student_id);
            $content_id = $this->input->post('content_id');
            foreach ($student as $value) {
                $class_id = $value->class_id;
                $section_id = $value->section_id;
            }
            
        	$data=array(
        		'upload_date'=>date('Y-m-d',strtotime($this->input->post('apply_date'))),
        		'student_session_id' => $student_session_id,
                'student_id' => $student_id,
                'class_id' => $class_id,
                'section_id' => $section_id,
                'content_id' => $content_id,
            );
            
            if($this->input->post('leave_id')==''){
             $answer_id=$this->question_model->add_answer($data);
            }else{
                $data['id']=$this->input->post('leave_id');
                $answer_id=$data['id'];
                $this->question_model->add_answer($data);
            }
        	
			
             if (isset($_FILES["userfile"]) && !empty($_FILES['userfile']['name'])) {
                $fileInfo = pathinfo($_FILES["userfile"]["name"]);
                $img_name = $answer_id . '.' . $fileInfo['extension'];
                move_uploaded_file($_FILES["userfile"]["tmp_name"], "./uploads/student_answer/" . $img_name);
                $data = array('id' => $answer_id, 'docs' => 'uploads/student_answer/'.$img_name);
                $this->question_model->add_answer($data);
    
            }
           
            $array = array('status' => 'success', 'error' => '', 'message' => $this->lang->line('success_message'));
        }
        echo json_encode($array);
	}

}
 

Zerion Mini Shell 1.0