コード例 #1
0
 public function index()
 {
     if (Auth::check()) {
         $question = Question::all();
         return View::make('Exam.exam', compact('questions'));
     }
     return "No estas logueado como estudiante.";
 }
コード例 #2
0
 public function postQuestionChange()
 {
     //message-notification
     $messages = array();
     //handle navigation
     $admin_navigation = new AdminNavigation();
     if ($admin_navigation->isNavigate()) {
         return $admin_navigation->goToN();
     }
     //handle chapter-text change
     //redirect after changed
     if (Input::has('chapter_change')) {
         $chapter = Chapter::find(Input::get('chapter_change'));
         $chapter->text = Input::get('chapter_text');
         $chapter->save();
         $messages['chapter_change_text'] = 'chapter-' . $chapter->id . ':saved';
         $this->messageController->send($messages, $this::MESSAGE_KEY);
         return Redirect::back();
     }
     //handle delete-question
     //redirect after deleted, no need to modify other inputs
     if (Input::has('delete_question')) {
         $question = Question::find(Input::get('delete_question'));
         $store_question_id = $question->id;
         $question->delete();
         $messages['delete_question'] = 'question-' . $store_question_id . ':deleted';
         $this->messageController->send($messages, $this::MESSAGE_KEY);
         return Redirect::back();
     }
     //handle change on a question (both this one, and it's options)
     //redirect after all-changes saved
     if (Input::has('question_change')) {
         $question = Question::find(Input::get('question_change'));
         //question-change, change question-text
         if (Input::has('question_text')) {
             $question->text = Input::get('question_text');
             $question->save();
             $messages['question_change_text'] = 'question-' . $question->id . ':saved';
         }
         //question-change, change question-chapter_id
         if (Input::has('chapter_id')) {
             $question->chapter_id = Input::get('chapter_id');
             $question->save();
             $new_chapter = $question->getChapter;
             $messages['question_change_chapter_id'] = 'question-' . $question->id . ':now belongs to chapter-' . $new_chapter->id;
         }
         //options-change
         if (Input::has('options')) {
             $options = Input::get('options');
             //save options-change
             $i = -1;
             foreach ($options as $option_id => $option_text) {
                 $option = Option::find($option_id);
                 $option->text = $option_text;
                 //reset all option-is_right = 0
                 //is_right set again with input-is_right checked
                 $option->is_right = 0;
                 $option->save();
                 $messages['options_change[' . ++$i . ']'] = 'option-' . $option->id . ':saved';
             }
             //modify option-is_right
             if (Input::has('is_right')) {
                 $option = Option::find(Input::get('is_right'));
                 //this option set is_right = 1
                 $option->is_right = 1;
                 $option->save();
                 $messages['options_change_is_right'] = 'option-' . $option->id . '-is_right:saved';
             }
         }
         //send message-notification
         $this->messageController->send($messages, $this::MESSAGE_KEY);
         return Redirect::back();
     }
     //new-question
     //redirect after create new-one
     if (Input::has('new_question')) {
         //save new question
         $question = new Question();
         //delete + auto_increment >>> modify question-id not continuous
         //manually change question-id
         $last_question = Question::all()->last();
         $question->id = $last_question->id + 1;
         $question->text = Input::get('question_text');
         $question->chapter_id = Input::get('chapter_id');
         $question->save();
         $question_id = $question->id;
         $messages['new_question'] = 'question-' . $question->id . ':saved';
         //save new options
         $options_text = Input::get('options');
         $created_options = array();
         for ($i = 0; $i < 4; $i++) {
             $option = new Option();
             $option->text = $options_text[$i];
             $option->question_id = $question_id;
             $option->is_right = 0;
             $option->save();
             //store in array new-option in $created_options, to add is_right on which
             $created_options[$i] = $option;
             $messages['option[' . $i . ']'] = 'option-' . $option->id . ':saved';
         }
         if (Input::has('is_right')) {
             $right_option = Input::get('is_right');
             //get option from store-$created_options, which selected is_right
             $option = $created_options[$right_option];
             $option->is_right = 1;
             $option->save();
             $messages['option_is_right'] = 'option-' . $option->id . '-is_right:saved';
         }
         //send message-notification
         $this->messageController->send($messages, $this::MESSAGE_KEY);
         return Redirect::back();
     }
     //as a fallback
     //send message-notification
     $this->messageController->send($messages, $this::MESSAGE_KEY);
     return Redirect::back();
 }
コード例 #3
0
ファイル: q2a.php プロジェクト: Osin/Intranet
<?php

include '../../inc/init.inc';
if (isset($tag)) {
    $conditions = array('id in (?)', Questions_Tag::find('all', array('conditions' => array('tag_id' => Tag::find_by_name($tag)->id)))->asQuestion_ID());
}
isset($conditions) ? $args['conditions'] = $conditions : ($args['conditions'] = 'title NOT LIKE ""');
$res->total = isset($args) ? Question::count($args) : Question::count();
$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 7;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'created_at desc';
$res->questions = Question::all($args);
$res->tags = Tag::find('all', array('order' => 'Rand()', 'limit' => 20));
if (!isset($infos)) {
    $infos = array();
}
$res->search_opts = array(0 => array('label' => 'Quelle question vous posez vous ?', 'field' => 'title', 'type' => 'text', 'class' => 'xxlarge'));
$res->useTemplate("Questions - Reponses", $infos);
コード例 #4
0
 public function index()
 {
     $questions = Question::all();
     return View::make('ask.index')->with(['questions' => $questions]);
 }
コード例 #5
0
 public function show()
 {
     $questions = Question::all();
     return View::make('user.dashboard', ['questions' => $questions]);
 }
コード例 #6
0
ファイル: routes.php プロジェクト: Roc4rdho/ubexchange
        //$message->from('*****@*****.**', 'c01tana Ltd');
        $message->to('*****@*****.**', 'rocard')->subject('test mail');
    });
    return 'done.';
});
Route::get('/', function () {
    $data['users'] = User::all();
    //$data['questions'] = DB::select( DB::raw("SELECT * FROM  `questions` ORDER BY  `created_at` DESC LIMIT 1") );
    $data['questions'] = Question::orderBy('created_at', 'desc')->paginate(10);
    $data['count'] = Question::all()->count();
    return View::make('site.home')->with($data);
});
Route::get('questions', function () {
    $data['users'] = User::all();
    $data['questions'] = Question::orderBy('created_at', 'desc')->paginate(10);
    $data['count'] = Question::all()->count();
    return View::make('site.questions')->with($data);
});
Route::get('question/{id}/{slug}', function ($id, $slug) {
    $data['users'] = User::all();
    $data['qvotes'] = Qvote::where('question_id', '=', $id)->get();
    $data['question'] = Question::find($id);
    $data['answers'] = Answer::where('question_id', '=', $id)->orderBy('votes', 'desc')->get();
    $data['comments'] = Comment::where('question_id', '=', $id)->orderBy('created_at', 'desc')->get();
    $data['count'] = Answer::where('question_id', '=', $id)->count();
    return View::make('site.question')->with($data);
});
Route::get('users', function () {
    $data['users'] = User::orderBy('reputation', 'desc')->paginate(20);
    return View::make('site.users')->with($data);
});
コード例 #7
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $questions = Question::all();
     return View::make('questions.index')->with('questions', $questions);
 }
コード例 #8
0
 public static function percentageAll()
 {
     $number1 = Auth::user()->correctQuestions()->count();
     $number2 = Question::all()->count();
     if ($number2 == 0) {
         $finalNumber = 100;
     } else {
         $quotient = $number1 / $number2;
         $finalNumber = $quotient * 100;
     }
     return round($finalNumber);
 }
コード例 #9
0
 /**
  * Display the specified resource.
  * GET /questions/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     return Question::all();
 }
コード例 #10
0
 public function questionsdone()
 {
     $questions = Question::all();
     $playerid = Input::get('player');
     foreach ($questions as $q) {
         $answer = new Answer();
         $answername = 'field' . $q->id;
         $answer->answer = Input::get($answername);
         $answer->player_id = $playerid;
         $answer->question_id = $q->id;
         $answer->save();
     }
     return View::make('thanks');
 }
コード例 #11
0
ファイル: SerialController.php プロジェクト: AlMos321/laravel
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function index()
 {
     $questions = Question::all();
     return response()->json($questions);
 }
コード例 #12
0
 public function index_admin()
 {
     $questions = Question::all();
     return View::make('commonquestions.admin_index', compact('questions'));
 }