Completed
Push — master ( ce3620...30316a )
by UP805717
12:23
created

QuizController::showQuestion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use App\Models\Quiz;
7
8
class QuizController extends Controller
9
{
10
    public function showIndexWelcome()
11
    {
12
        return view('index.welcome');
13
    }
14
15
    public function showHostDashboard()
16
    {
17
        return view('quiz_host.dashboard.index');
18
    }
19
20
    public function showQuestion()
21
    {
22
        return view('quiz_user.question');
23
    }
24
25
    public function showPin()
26
    {
27
        return view('quiz_user.pin');
28
    }
29
30
    public function showSplash()
31
    {
32
        return view('quiz_user.splash');
33
    }
34
35
    public function enterQuizPin(Request $request)
36
    {
37
        // @TODO - PIN max length needs to be dynamic with trait
38
        // will sort out soon - Matt.
39
        $validatedData = $request->validate([
0 ignored issues
show
Unused Code introduced by
The assignment to $validatedData is dead and can be removed.
Loading history...
40
            'username' => 'required|string',
41
            'pin'      => 'required|string'
42
        ]);
43
44
        // if (Quiz::where('quiz_pin', $request->get('pin'))->where('active', 1)->get()->isEmpty()) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
71% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
        //     return back()->with('errors', 'The quiz PIN does not exist');
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
46
        // } else {
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
47
        //     return back()->with('success', 'Whoa, the quiz exists');
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
        // }
49
50
        // FIX XSS HERE ALSO
51
        $quiz = Quiz::where('quiz_pin', $request->get('pin'))
52
                    ->where('active', 1)
53
                    ->first();
54
55
        if (!$quiz->exists()) {
56
            return back()->with('pin_error', 'Either the quiz doesn\'t exits, or it hasn\'t been activated');
57
        } else {
58
            //return back()->with('success', 'The quiz ' . $quiz->quiz_name . ' exits and is ready to play.');
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
59
            return redirect()->route('quiz_user.showSplash');
60
        }
61
    }
62
}
63