예제 #1
0
 public function startTestByAssigner(Requests\Client\Assigners\Show $request, Assigner $Assigner)
 {
     $Prototype = $Assigner->prototype;
     $Test = new Test();
     $Test->fill(['user_id' => $Assigner->user_id, 'prototype_id' => $Prototype->id]);
     $Questions = $Assigner->prototype->questions;
     if ($Prototype->qount_questions === 0) {
         $count_question = $Questions->count();
     } else {
         if ($Questions->count() >= $Prototype->count_questions) {
             $count_question = $Prototype->count_questions;
         } else {
             $count_question = $Questions->count();
         }
     }
     $ids = array_rand($Questions->toArray(), $count_question);
     $Test->save();
     $Assigner->test()->associate($Test);
     $Assigner->save();
     foreach ($ids as $id) {
         $Test->questions()->attach($Questions[$id]->id);
     }
     return redirect(route('client.test', $Test));
 }
예제 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Assigner $Assigner)
 {
     $Assigner->delete();
     return redirect()->back();
 }