Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1.  
  2. //        $quiz->setUsernameOrEmail($formData['usernameOrEmail']);
  3. //        $quiz->setPassword($formData['password']);
  4. //        $quiz->login();
  5.  
  6.  
  7.  
  8.         //////////
  9. //        $questions = $quiz->questions->keyBy('id'); // get all quiz questions with their ID as the array key
  10. //
  11. //        // Update Quiz data
  12. //        $quiz->name = $input['name'];
  13. //        $quiz->theme = $input['theme'];
  14. //        try {
  15. //            $quiz->save(); // save the original model object
  16. //        } catch (\Exception $e) {
  17. //
  18. //        };
  19. //
  20. //        foreach ($input['questions'] as $id => $inputQuestion) {
  21. //            $originalQuestion = $questions->get($id); // get original question model object by id
  22. //            $originalQuestion->update([
  23. //                'question' => $inputQuestion['question'] // update original question by the users input
  24. //            ]);
  25. //
  26. //            try {
  27. //                $originalQuestion->save(); // save the original model object
  28. //            } catch (\Exception $e) {
  29. //
  30. //            };
  31. //
  32. //            $answers = $originalQuestion->answers->keyBy('id'); // get all answers with their ID as the array key
  33. //
  34. //            foreach ($inputQuestion['answers'] as $id => $inputAnswer) {
  35. //                $originalAnswer = $answers->get($id);
  36. //
  37. //                $originalAnswer->update([
  38. //                    'answer' => $inputAnswer,
  39. //                    'correct_choice' => ($id == $inputQuestion['correct_choice']) ? 1 : 0
  40. //                ]);
  41. //
  42. //                try {
  43. //                    $originalAnswer->save(); // save the original model object
  44. //                } catch (\Exception $e) {
  45. //
  46. //                };
  47. //            }
  48. //        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement