Example #1
0
 public function save($id2, Request $request)
 {
     $id = urldecode($id2);
     //$question=DB::select('select * from questions where question = :id',['id'=>$id]);
     $question = question::where('question', $id)->get()->first();
     // $question->question_answer()->create(["user_id" => Auth::user()->id],$request->all());
     $answer = new answer();
     $answer->question = $question->question;
     $answer->user_id = Auth::user()->id;
     $answer->answer = $request['answer'];
     $answer->save();
     return redirect()->route('answer', ['question' => urlencode($id2)]);
 }
Example #2
0
 public function register()
 {
     //slaat antwoord op
     $input = Request::all();
     $controll = answer::find($input['id']);
     $controll = $controll['controll'];
     $answer = array();
     $answer['answer'] = $input['status'];
     $answer['question'] = $input['id'];
     $session = Session::all();
     $counter = $session['counter'];
     if ($controll == $input['status']) {
         $answer['controll'] = 'correct';
         $counter = $counter + 1;
     } else {
         $answer['controll'] = 'incorrect';
     }
     Session::put($input['id'], $answer);
     Session::put('counter', $counter);
     $session = Session::all();
     $session = json_encode($session);
     $input = json_encode($input);
     //controle voor het einde van de test
     header('Content-type: application/json');
     print_r($input);
     die;
 }
Example #3
0
 public function display($id)
 {
     //echo ($id);
     $id = urldecode($id);
     $question = question::where('question', $id)->get()->first();
     $topic = topic::where('id', $question->topic_id)->get()->first();
     $answer = answer::where('question', $id)->get();
     if ($answer !== null) {
         $name = DB::select('select name, users.id,answer, question, preffered, upvoted , downvoted from users inner join answers on users.id=answers.user_id');
         return view('show.answer', compact('question', 'topic', 'name'));
         //   return $answer;
     } else {
         return view('show.answer', compact('question', 'topic'));
     }
     //return $id;
 }
<html>
<head>
	<style>
	body 
	{
		background-image: url("real.jpg");
	}
	.row
	{ font-size: 20px;
    }
	</style>
</head>	
<?php 
$answers = \App\answer::where('author_id', '=', $_SESSION["user"])->get();
$values = [];
$k = 0;
foreach ($answers as $answer) {
    $values[$k] = $answer->ques_id;
    $k++;
}
$question = \App\question::where('author', '!=', $_SESSION["user"])->whereNotIn('id', $values)->get(['id', 'question', 'opt1', 'opt2', 'opt3', 'opt4', 'points']);
echo '
        <div class="jumbotron">
  <div class="container">
    <h1>THE OFFICIAL QUIZ PAGE</h1> 
    <p>The questions present below are the questions submitted by other users. </p>     
    <p>The users have two options.
       Either they can play the quiz or
       they can submit a question of their own. </p>
    <p>The user score will be updated and stored dynamically. </p>
    <p>So what are you waiting for? Go Ahead. GOOD LUCK  </p>
Example #5
0
        $signinurl = "";
        $login = "******";
        $loginurl = url("logout");
        $login_failure = 0;
    }
}
if ($login_failure) {
    echo '
   <script>
  window.location="' . url("/") . '";
  </script>
  
  ';
} else {
    include 'navbar.php';
    $answer = \App\answer::where('ques_id', '=', $quesid)->where('author_id', '=', $_SESSION["user"])->get();
    if (count($answer)) {
        echo '
		 <div class="row">
		 <div class="col-sm-2 col-xs-2 " ></div>
		 <div class="alert alert-info col-sm-8 col-xs-8 text-center" > <strong>Question you are trying to answer is already answered</strong></div>
		 </div>';
    } else {
        $question = \App\question::where('id', '=', $quesid)->first();
        if ($ans == $question->correct) {
            echo '
		 <div class="row">
		 <div class="col-sm-2 col-xs-2 " ></div>
		 <div class="alert alert-success col-sm-12 col-xs-8 text-center" > <strong>Right Answer! ' . $question->points . ' points added to your score.</strong></div>
		 <div class="alert alert-success col-sm-12 col-xs-8 text-center" > <strong>Keep going. Continue the same form.</strong></div>
		 </div>';