示例#1
0
 public function assessmentupdateget($dash, $id)
 {
     $assessment = Assessments::find($id);
     $user = User::find($assessment->teacherid);
     if (Sentry::getUser()->id == $user->id) {
         $theme = Theme::uses('dashboard')->layout('default');
         $view = array('name' => 'Dashboard Assessment Update', 'id' => $id);
         $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Assessments', 'url' => Setting::get('system.dashurl') . '/assessments'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/assessment/' . $id]]);
         $theme->appendTitle(' - Assessment Update');
         $theme->asset()->container('datatable')->writeScript('inline-script', '$(document).ready(function(){
             $(\'#attachments\').dataTable({
                 "sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>",
                     "oLanguage": {
                     "sLengthMenu": "_MENU_ ' . ' Attachments per page"
                     },
                     "sPagination":"bootstrap"
                
             });
         });$(document).ready(function(){
             $(\'#questionfail\').dataTable({
                 "sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>",
                     "oLanguage": {
                     "sLengthMenu": "_MENU_ ' . ' Failures per page"
                     },
                     "sPagination":"bootstrap"
                
             });
         });');
         $theme->asset()->container('footer')->writeScript('inline-script', '$(document).ready(function(){
             $("#examsheader").hide();
             $("div#exams").hide();
             $("div#examslock").hide();
             $(".hidequestions").hide();
             $(".hidequestions").click(function(){
                 $("div#exams").hide(2000);
                  $(\'html, body\').animate({
                     scrollTop: $("#top").offset().top
                 }, 2000);
                 $("#examsheader").hide(1200);
                 $("#examslock").hide(1200);
                 $(".hidequestions").hide(1000);
                 $("#showquestions").show(1000);
             });
             $("#showquestions").click(function(){
                 $("div#exams").show(2000);
                 $("div#examslock").show(100);
                 $(\'html, body\').animate({
                     scrollTop: $("#examslock").offset().top
                 }, 2000);
                 $("#examsheader").show(1000);
                 $(".hidequestions").show(1000);
                 $("#showquestions").hide(1000);
             });
         });');
         return $theme->scope('assessment.update', $view)->render();
         // return View::make('dashboard.assessments.update')->with('id',$id);
     } else {
         return "UPDATE NOT AUTHORISED";
     }
 }
 public function attachmentDelete($id, $file)
 {
     $tutorial = Assessments::find($id);
     $studentid = $tutorial->studentid;
     if ($studentid == Sentry::getUser()->id) {
         File::delete(app_path() . '/attachments/assessment-' . $id . '/' . $file);
         return Redirect::to(URL::previous());
     } else {
         return "UNAUTHORISED DELETE OPERATION";
     }
 }
示例#3
0
 public function markExam($dash, $aid, $eid)
 {
     $assessment = Assessments::find($aid);
     $exam = Exams::find($eid);
     $tutorial = Tutorials::find($assessment->tutorialid);
     $questionpath = app_path() . '/files/exam-' . $eid . '/' . $exam->hash . '.json';
     $studentanswer = app_path() . '/files/assessment/' . $aid . '/exam-' . $eid . '/questiondata.json';
     $answers = File::get($questionpath);
     $bystudent = File::get($studentanswer);
     unset($studentanswer);
     $realcount = $exam->totalquestions;
     $json = json_decode($answers, true);
     settype($realcount, 'float');
     $markscount = 0.0;
     settype($markscount, 'float');
     $marksinc = 100.0 / $realcount;
     settype($realcount, 'integer');
     $questionfailed = [];
     $studentanswer = json_decode($bystudent, true);
     $questioncount = Session::put('questioncount_key', 1);
     for ($questioncount = 0; $questioncount <= $realcount;) {
         $questioncount++;
         $acception = [];
         if (isset($studentanswer['answers'][$questioncount][1])) {
             $answerfailed = array();
             if ($studentanswer['answers'][$questioncount][1] == 0 || $studentanswer['answers'][$questioncount][1] == "0") {
                 //Adding 0 Marks if the Question Left Unanswered.
                 $markscount += 0;
             } else {
                 $ccount = 0;
                 $answerfromstudent = $studentanswer['answers'][$questioncount];
                 if (isset($json['questiondata']['question'][$questioncount]['answers'][0])) {
                     $ccount += 1;
                     //Setting Simple Variable
                     $a0 = $json['questiondata']['question'][$questioncount]['answers'][0];
                     $acception[] = self::checkAnswer($a0, $answerfromstudent);
                     if (self::checkAnswer($a0, $answerfromstudent) == 0) {
                         $answerfailed[] = $answerfromstudent;
                     }
                 }
                 if (isset($json['questiondata']['question'][$questioncount]['answers'][1])) {
                     $ccount += 1;
                     //Setting Simple Variable
                     $a1 = $json['questiondata']['question'][$questioncount]['answers'][1];
                     $acception[] = self::checkAnswer($a1, $answerfromstudent);
                     if (self::checkAnswer($a1, $answerfromstudent) == 0) {
                         $answerfailed[] = $answerfromstudent;
                     }
                 }
                 if (isset($json['questiondata']['question'][$questioncount]['answers'][2])) {
                     $ccount += 1;
                     //Setting Simple Variable
                     $a2 = $json['questiondata']['question'][$questioncount]['answers'][2];
                     $acception[] = self::checkAnswer($a2, $answerfromstudent);
                     if (self::checkAnswer($a2, $answerfromstudent) == 0) {
                         $answerfailed[] = $answerfromstudent;
                     }
                 }
                 if (isset($json['questiondata']['question'][$questioncount]['answers'][3])) {
                     $ccount += 1;
                     //Setting Simple Variable
                     $a3 = $json['questiondata']['question'][$questioncount]['answers'][3];
                     $acception[] = self::checkAnswer($a3, $answerfromstudent);
                     if (self::checkAnswer($a3, $answerfromstudent) == 0) {
                         $answerfailed[] = $answerfromstudent;
                     }
                 }
                 if (isset($json['questiondata']['question'][$questioncount]['answers'][4])) {
                     $ccount += 1;
                     //Setting Simple Variable
                     $a4 = $json['questiondata']['question'][$questioncount]['answers'][4];
                     $acception[] = self::checkAnswer($a4, $answerfromstudent);
                     if (self::checkAnswer($a4, $answerfromstudent) == 0) {
                         $answerfailed[] = $answerfromstudent;
                     }
                 }
                 $resulttt = array_unique($acception);
                 $counted = array_count_values($acception);
                 if (isset($counted[1])) {
                     if ($counted[1] == $ccount) {
                         $markscount += $marksinc;
                     } else {
                         $questionfailed['questions'][$questioncount] = $json['questiondata']['questions'][$questioncount];
                         $questionfailed['questions_fail'][$questioncount] = $answerfailed;
                         unset($answerfailed);
                     }
                 }
                 unset($acception);
             }
         }
     }
     $failedquestions = json_encode($questionfailed);
     file_put_contents(app_path() . '/files/assessment/' . $assessment->id . '/exam-' . $exam->id . '/questionfailed.json', $failedquestions);
     $assessment->marks = $markscount;
     $assessment->save();
     return Redirect::to(URL::previous());
 }