public function checkQuiz()
 {
     if (Session::has('id') && (Session::get('type') === 'Student' || Session::get('type') === 'SuperAdmin')) {
         $input = Request::all();
         $correctAnswers = Session::get('correct_answer');
         $total_qus = Session::get('total_qus');
         $count = 0;
         foreach ($correctAnswers as $key => $value) {
             $k = 'q-' . $key;
             if (isset($input[$k]) && $input[$k] == $value) {
                 $count++;
             }
         }
         $marks = $count;
         $tot_marks = $total_qus;
         $s = $tot_marks - $marks;
         //echo $s;
         $result = new Result();
         $result->marks = $marks;
         $result->total_marks = $tot_marks;
         $result->unanswered = $s;
         $result->save();
         return View::make('result', array('result' => $result));
     } else {
         echo 'You are not authorized';
     }
 }
Пример #2
0
 public function getSingle()
 {
     $type = $_GET['type'];
     $name = $_GET['name'];
     $resultModel = new Result();
     $result = $resultModel->getSingleResult($type, $name);
     $data['result'] = $result;
     return view('single', $data);
 }
Пример #3
0
 public function search($query)
 {
     $results = array();
     if (trim($query) != "") {
         $resultModel = new Result();
         $results = $resultModel->searchResults($query);
     }
     $data['results'] = $results;
     return view('index', $data);
 }
Пример #4
0
 public function actionCreate()
 {
     if (Yii::$app->getRequest()->getMethod() === 'OPTIONS') {
         return true;
     }
     $model = new Result();
     $model->load(Yii::$app->request->post());
     $model->user_id = Yii::$app->user->id;
     if (!$model->save()) {
         return $model->getErrors();
     }
     return true;
 }
 public function actionClean()
 {
     Code::updateAll(['used' => 0, 'status' => 0]);
     Meta::deleteAll();
     Result::deleteAll();
     return $this->redirect(['/system/statistic']);
 }
Пример #6
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Exam $exam)
 {
     $results = Result::whereExamId($exam->id)->get();
     foreach ($results as $result) {
         $result['name'] = $result->student()->first()->name;
         $result['roll'] = $result->student()->first()->roll;
     }
     return view("admin.partials._results")->with('exam', $exam)->with('results', $results);
 }
 /**
  * indexAction
  *
  * @param Request $request
  * @author Zaid Sadhoe <*****@*****.**>
  */
 public function indexAction(Request $request)
 {
     $ajax = new Request();
     $ajax->headers->set('X-Requested-With', 'XMLHttpRequest');
     $memberCount = Member::count();
     $webpageCount = Webpage::count();
     $resultCount = Result::count();
     return view('site.' . Site::getName() . '.page.index', ['request' => $request, 'memberCount' => $memberCount, 'webpageCount' => $webpageCount, 'resultCount' => $resultCount]);
 }
Пример #8
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $fromWhere = Input::get('from', null);
     // Problem --------------------------------------------------
     $problem_id = Input::get('problem_id', '');
     // User -----------------------------------------------------
     $username = Input::get('user', '');
     // Result ---------------------------------------------------
     $resultRefs = Result::all();
     $result_id = Input::get('result_id', 0);
     // Language -------------------------------------------------
     $lang_id = Input::get('lang_id', 0);
     $langRefs = Language::all();
     $acceptCode = Result::acceptCode;
     $solutions = SolutionService::getSolutionsByOption(['problem_id' => $problem_id, 'username' => $username, 'lang_id' => $lang_id, 'result_id' => $result_id]);
     // $solutions = $solutions->paginateFrom(Input::get('top', ''), 20);
     //$solutions = $solutions->paginate(20, ['url' => \Request::url()]);
     $getUser_id = SolutionService::getUser();
     if ($getUser_id) {
         $getUser_id = $getUser_id->id;
     }
     return view('solutions.index', compact('fromWhere', 'solutions', 'problem_id', 'username', 'result_id', 'resultRefs', 'lang_id', 'langRefs', 'acceptCode', 'getUser_id'));
 }
Пример #9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getResults()
 {
     return $this->hasMany(Result::className(), ['election_id' => 'id']);
 }
Пример #10
0
 /**
  * Get the users script for specified language, userKey and tool
  *
  * @param Request $request
  * @param string $sessionKey
  * @param string $tool
  * @return Response The script content
  */
 public static function registerResult(Request $request)
 {
     $origin = $request->headers->get('Origin');
     $response = static::getResponse('application/json', $origin);
     if (!$origin) {
         return $response;
     }
     $user = static::getUser();
     if ($user && $user->hasLicense() && $user->is_enabled) {
         $evaluation = static::getEvaluation($request->sessionKey);
         $results = $request->get('results', null);
         if (!$evaluation || !$results) {
             return $response;
         }
         foreach ($results as $result) {
             $result['evaluation_id'] = $evaluation->id;
             Result::create($result);
         }
         $response->setContent(json_encode(['error' => 0]));
     }
     return $response;
 }
Пример #11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Exam $exam, Result $result)
 {
     $result->delete();
 }
Пример #12
0
 public function saveAnswers($code, $answers)
 {
     $questions = $this->getQuestions();
     foreach ($answers as $key => $answer) {
         $aq = $this->getQuestionByPosition($questions, $key);
         $fr_id = $aq['fr_id'];
         $answer = $this->answerToDefault($fr_id, $answer);
         if (is_array($answer)) {
             $answer = implode(";", $answer);
         }
         $count = Result::find()->andWhere(['e_z_id' => $code['z_id'], 'e_fr_id' => $fr_id])->count();
         if (!$count) {
             if (!trim($answer)) {
                 if (isset($aq['dset'])) {
                     $aid = $aq['dset'];
                 } else {
                     $aid = "err";
                     $answer = "";
                 }
             } else {
                 $aid = $this->getAnswerId($aq, $answer);
             }
             if ($aq['display'] == "radio" && $aid !== "err") {
                 $result = new Result();
                 $result->e_z_id = $code['z_id'];
                 $result->e_fr_id = $fr_id;
                 $result->a_id = $aid;
                 $result->save();
             } else {
                 $result = new Result();
                 $result->e_z_id = $code['z_id'];
                 $result->e_fr_id = $fr_id;
                 $result->antwort = $answer;
                 $result->save();
             }
         }
         $status = $key;
     }
     $codeObj = Code::findOne($code['z_id']);
     $codeObj->status = $status;
     $codeObj->save();
     return $status;
 }