/** * Run the database seeds. * * @return void */ public function run() { // /*DB::table('tests')->delete(); $user = test::whereEmail('*****@*****.**')->first(); if($user !== NULL) { return; }*/ $test = new test(); $test->test_name = "php unit testing"; $test->test_result = "result ok"; $test->save(); }
/** * Save student's Emotional Stability test * * @return Response */ public function submitTest() { $user = Auth::user(); // initialized scales' scores to zero $scl_intra = 0; // Intrapersonal Scale $scl_inter = 0; // Interpersonal Scale $scl_strss = 0; // Stress Management Scale $scl_adap = 0; // Adapatability Scale $scl_gmood = 0; // General Mood Scale $total_eq = 0; // Total Emotional Quotient Scale $scl_imprssn = 0; // Positive Impression Scale $index_inc = 0; // Index of Inconsistency $pairIndex = 0; // index counter $indexInc_pair = [7, 13, 9, 33, 12, 45, 16, 22, 21, 39, 26, 8, 30, 36, 32, 47, 34, 40, 42, 46]; // Iterate through questions taken for ($itemNum = 0; $itemNum <= 50; $itemNum++) { // Get the answer for the question // Find the question in database $answer = Input::get($itemNum); $question = questions::find($itemNum); // Determine if current question has a // pair for index of inconsistency if ($itemNum == $indexInc_pair[$pairIndex]) { $index_inc += Input::get($indexInc_pair[$pairIndex]) - Input::get($indexInc_pair[$pairIndex + 1]); $pairIndex = ($pairIndex + 2) % 20; } // Determine question's category; // Add question's answer to the total sum of the category switch ($question->scale_type) { case 1: $scl_intra += $answer; break; case 2: $scl_inter += $answer; break; case 3: $scl_strss += $answer; break; case 4: $scl_adap += $answer; break; case 5: $scl_gmood += $answer; break; case 7: $scl_imprssn += $answer; break; default: break; } // Save student's answer to the question $student_question = new student_question(array('user_id' => $user->id, 'question_id' => $question->id, 'value' => $answer)); $student_question->save(); } // Compute total Emotional Quotient $total_eq = ($scl_intra + $scl_inter + $scl_strss + $scl_adap + $scl_gmood) / 5; // Save the test $test = new test(array('user_id' => $user->id, 'date_taken' => date('Y-m-d'), 'intra_score' => $scl_intra, 'inter_score' => $scl_inter, 'strss_mgt_score' => $scl_strss, 'adap_score' => $scl_adap, 'gen_mood_score' => $scl_gmood, 'total_eq' => $total_eq, 'index_inconsistency' => $index_inc, 'pstv_imprssn_score' => $scl_imprssn)); $test->save(); return $this->testinterp(); }