application/controllers/Lecturers.php
/**
     * View Assignements by lecturer 
     * @param int $course_id Optionally view for specific course
     */
View Assignements by lecturer
@param int $course_id Optionally view for specific course
View Assignements by lecturer @param int $course_id Optionally view for specific course
public function assignments($course_id = '')
    {
        $this->_secure();
        $this->load->model('assignment');
        $this->load->model('course');
        $success = FALSE;
        $error = '';
        $course  = '' ;
        if($course_id)
        {
            $course  = $this->course->getOne(['id' => $course_id]);
            if(!$course->id || $course->lecturer_id != $this->current_user->id)
            {
                show_error("Course Not FOund or You do not have permission");
            }
        }
        $config['allowed_types']        = 'pdf|doc|docx';
        $config['max_size']             = 1000;
        if($this->input->post('submit'))
        {
            $assignment = new Assignment($this->input->post());
            $assignment->course_id = $course_id;
            $assignment->lecturer_id = $this->current_user->id;
            $assignment->deadline = $this->input->post('deadline-period'). ' ' .$this->input->post('deadline-time');
            $config['upload_path']   =  dirname(BASEPATH).'/uploads/assignments/';
            $config['file_name']   =  time();
            $this->load->library('upload', $config);
            if ( !empty($_FILES['file']['name']))
            {
                if(!$this->upload->do_upload('file'))
                {
                    $error = $this->upload->display_errors();
                }
                else
                {
                    $data = $this->upload->data();
                    $assignment->attachment =  url_title($this->input->post('title')).'-'.time();$data['full_path'];
                }
            }
            if(!$error)
            {
                $assignment->save();
                $success = true ;
            }
        }
        $where = $course_id? ['course_id' => $course_id ] : '';
        $assignments = $this->assignment->getAll($where);
        $this->_view('lecturers/assignments' , [
            'assignments' => $assignments,
            'course' => $course,
            'error' => $error ,
            'success' => $success
        ]);
    }
public function assignments ( $ course_id = '' ) { $ this -> _secure ( ) ; $ this -> load -> model ( 'assignment' ) ; $ this -> load -> model ( 'course' ) ; $ success = FALSE ; $ error = '' ; $ course = '' ; if ( $ course_id ) { $ course = $ this -> course -> getOne ( [ 'id' => $ course_id ] ) ; if ( ! $ course -> id || $ course -> lecturer_id != $ this -> current_user -> id ) { show_error ( " Course Not FOund or You do not have permission " ) ; } } $ config [ 'allowed_types' ] = 'pdf|doc|docx' ; $ config [ 'max_size' ] = 1000 ; if ( $ this -> input -> post ( 'submit' ) ) { $ assignment = new Assignment ( $ this -> input -> post ( ) ) ; $ assignment -> course_id = $ course_id ; $ assignment -> lecturer_id = $ this -> current_user -> id ; $ assignment -> deadline = $ this -> input -> post ( 'deadline-period' ) . ' ' . $ this -> input -> post ( 'deadline-time' ) ; $ config [ 'upload_path' ] = dirname ( BASEPATH ) . '/uploads/assignments/' ; $ config [ 'file_name' ] = time ( ) ; $ this -> load -> library ( 'upload' , $ config ) ; if ( ! empty ( $ _FILES [ 'file' ] [ 'name' ] ) ) { if ( ! $ this -> upload -> do_upload ( 'file' ) ) { $ error = $ this -> upload -> display_errors ( ) ; } else { $ data = $ this -> upload -> data ( ) ; $ assignment -> attachment = url_title ( $ this -> input -> post ( 'title' ) ) . '-' . time ( ) ; $ data [ 'full_path' ] ; } } if ( ! $ error ) { $ assignment -> save ( ) ; $ success = true ; } } $ where = $ course_id ? [ 'course_id' => $ course_id ] : '' ; $ assignments = $ this -> assignment -> getAll ( $ where ) ; $ this -> _view ( 'lecturers/assignments' , [ 'assignments' => $ assignments , 'course' => $ course , 'error' => $ error , 'success' => $ success ] ) ; }
View Assignements by lecturer
 @param int $course_id Optionally view for specific course
View Assignements by lecturer @param int $course_id Optionally view for specific course