Skip to content

Commit

Permalink
Fix code sniffer errors (#5)
Browse files Browse the repository at this point in the history
* Fix code sniffer errors

* Fix code sniffer warnings
  • Loading branch information
christophherr authored and ankitjain28may committed Oct 1, 2017
1 parent 343fc91 commit 1ea308b
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 57 deletions.
5 changes: 3 additions & 2 deletions app/Event.php
Expand Up @@ -23,8 +23,9 @@ class Event extends Model
* @var array
*/
protected $fillable = [
'eventName', 'eventCode', 'eventDes', 'startTime', 'endTime', 'duration', 'totalQues',
'societyId', 'type', 'approve', 'active', 'forum', 'winners'
'eventName', 'eventCode', 'eventDes', 'startTime',
'endTime', 'duration', 'totalQues', 'societyId',
'type', 'approve', 'active', 'forum', 'winners'
];

/**
Expand Down
26 changes: 17 additions & 9 deletions app/Http/Controllers/Event/AnswerControllerApi.php
Expand Up @@ -61,7 +61,7 @@ public function create()
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $eventId
* @param int $eventCode
* @param int $id
* @return \Illuminate\Http\Response
*/
Expand Down Expand Up @@ -104,16 +104,20 @@ public function store(Request $request, $eventCode, $id)
];
$result = $this->correctAnswer($correct, $score, $data);
if ($result) {
return Response::json([
"status" => True,
return Response::json(
[
"status" => true,
"message" => $randomMessage->correct,
"redirect" => '/event/'.$eventCode.'/dashboard'
]);
]
);
}
return Response::json([
"status" => False,
return Response::json(
[
"status" => false,
"message" => $randomMessage->incorrect
]);
]
);
}

/**
Expand Down Expand Up @@ -205,9 +209,13 @@ public function submitFile(Request $request)
// renaming image
$fileNamevfile = "";
if ($userDetails->admissionNo == "") {
$fileNamevfile = $name."_".$userDetails->college.'.'.$extensionvfile;
$fileNamevfile = $name . "_";
$fileNamevfile .= $userDetails->college . '.';
$fileNamevfile .= $extensionvfile;
}
$fileNamevfile = $name."_".$userDetails->admissionNo.'.'.$extensionvfile;
$fileNamevfile = $name . "_";
$fileNamevfile .= $userDetails->admissionNo . '.';
$fileNamevfile .= $extensionvfile;
Input::file('file')->move(
$destinationPathvfile, $fileNamevfile
);
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/Event/EventController.php
Expand Up @@ -146,7 +146,7 @@ public function destroy($id)
/**
* Display the specified resource.
*
* @param int $id
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function dashboard($eventCode)
Expand All @@ -170,8 +170,7 @@ public function dashboard($eventCode)

if ($eventCode == "sherlocked") {
return Redirect::to('http://sherlocked.zealicon.in/');
}
elseif ($event->type == 3) {
} elseif ($event->type == 3) {
return File::get(public_path()."/gameplay/dashboard3.html");
}
$getScore = Score::where(
Expand Down
20 changes: 11 additions & 9 deletions app/Http/Controllers/Event/EventControllerApi.php
Expand Up @@ -139,7 +139,7 @@ public function store(Request $request)
/**
* Display the specified resource.
*
* @param int $id
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function show($eventCode)
Expand Down Expand Up @@ -170,7 +170,7 @@ public function show($eventCode)
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function edit($eventCode)
Expand Down Expand Up @@ -226,7 +226,7 @@ public function update(Request $request, $eventCode)
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function destroy($eventCode)
Expand All @@ -253,14 +253,14 @@ public function destroy($eventCode)
/**
* Approve the Event.
*
* @param int $id
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function approve($eventCode)
{
$approve = Input::all();

$event = Event::where('eventCode' ,$eventCode)->first();
$event = Event::where('eventCode', $eventCode)->first();

if ($approve['action']) {
$event->approve = 1;
Expand Down Expand Up @@ -288,14 +288,14 @@ public function approve($eventCode)
/**
* Active the Event.
*
* @param int $id
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function active($eventCode)
{
$active = Input::all();

$event = Event::where('eventCode' ,$eventCode)->first();
$event = Event::where('eventCode', $eventCode)->first();
// $event = Event::find($id);

if ($active['action']) {
Expand Down Expand Up @@ -323,7 +323,7 @@ public function active($eventCode)
/**
* Display the specified resource.
*
* @param int $id
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function dashboard($eventCode)
Expand Down Expand Up @@ -386,7 +386,9 @@ public function dashboard($eventCode)

if (Auth::guard('society')->check()) {
$question = Question::where('eventId', $id)->get()->toJson();
} elseif (!Auth::guard('society')->check() && !Auth::guard('user')->check()) {
} elseif (!Auth::guard('society')->check()
&& !Auth::guard('user')->check()
) {
return Redirect::to('/event');
}

Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Event/QuestionController.php
Expand Up @@ -32,6 +32,7 @@ public function __construct()
/**
* Display a listing of the resource.
*
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function index($eventCode)
Expand Down Expand Up @@ -102,7 +103,7 @@ public function store(Request $request)
/**
* Display the specified resource.
*
* @param int $eventId
* @param int $eventCode
* @param int $id
* @return \Illuminate\Http\Response
*/
Expand Down Expand Up @@ -139,7 +140,7 @@ public function show($eventCode, $id)
/**
* Show the form for editing the specified resource.
*
* @param int $eventId
* @param int $eventCode
* @param int $id
* @return \Illuminate\Http\Response
*/
Expand Down
56 changes: 34 additions & 22 deletions app/Http/Controllers/Event/QuestionControllerApi.php
Expand Up @@ -37,38 +37,44 @@ public function __construct()
/**
* Display a listing of the resource.
*
* @param int $id
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function index($eventCode)
{
$event = Event::where('eventCode', $eventCode)->first();
if (!count($event)) {
return Response::json([
return Response::json(
[
"status" => false,
"data" => [],
"error" => ['Event not found']
]);
]
);
}
$id = $event->id;

$question = Question::where('eventId', $id)->get();


if (!count($question)) {
return Response::json([
return Response::json(
[
"status" => false,
"data" => [],
"error" => ['No Questions Found']
]);
]
);
}

if (!Auth::guard('society')->check() && !Auth::guard('user')->check()) {
return Response::json([
return Response::json(
[
"status" => false,
"data" => [],
"error" => ['No Questions Found']
]);
]
);
} elseif (Auth::guard('society')->check()) {
foreach ($question as $key => $value) {
$value->html = htmlspecialchars_decode($value->html);
Expand All @@ -81,16 +87,20 @@ public function index($eventCode)
$res['questions'] = $question;
$res['event'] = $event;

return Response::json([
return Response::json(
[
"status" => true,
"data" => $res
]);
]
);
} elseif (Auth::guard('user')->check() && $event->type != 3) {
return Response::json([
return Response::json(
[
"status" => false,
"data" => [],
"error" => ["Questions not found"]
]);
]
);
}

return Response::json(
Expand All @@ -115,7 +125,7 @@ public function create()
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $eventId
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function store(Request $request, $eventCode)
Expand Down Expand Up @@ -193,13 +203,13 @@ public function store(Request $request, $eventCode)

return Response::json(
[
"status" => True
"status" => true
]
);
}
return Response::json(
[
"status" => False,
"status" => false,
"error" => "Invalid Event"
]
);
Expand Down Expand Up @@ -245,7 +255,7 @@ public function show($eventCode, $id)
/**
* Show the form for editing the specified resource.
*
* @param int $eventId
* @param int $eventCode
* @param int $id
* @return \Illuminate\Http\Response
*/
Expand Down Expand Up @@ -283,7 +293,7 @@ public function edit($eventCode, $id)
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $eventId
* @param int $eventCode
* @param int $id
* @return \Illuminate\Http\Response
*/
Expand All @@ -295,7 +305,7 @@ public function update(Request $request, $eventCode, $id)
/**
* Remove the specified resource from storage.
*
* @param int $eventId
* @param int $eventCode
* @param int $id
* @return \Illuminate\Http\Response
*/
Expand All @@ -321,7 +331,7 @@ public function destroy($eventCode, $id)
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $eventId
* @param int $eventCode
* @return \Illuminate\Http\Response
*/
public function quesType3(Request $request, $eventCode)
Expand All @@ -331,11 +341,13 @@ public function quesType3(Request $request, $eventCode)
$eventId = $event->id;

if (!count($event)) {
return Response::json([
return Response::json(
[
"status" => false,
"data" => [],
"error" => ["Event not found"]
]);
]
);
}

$questionInput = Input::all();
Expand Down Expand Up @@ -365,13 +377,13 @@ public function quesType3(Request $request, $eventCode)
if ($question->save()) {
return Response::json(
[
"status" => True
"status" => true
]
);
}
return Response::json(
[
"status" => False
"status" => false
]
);
}
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/HomeController.php
Expand Up @@ -96,7 +96,10 @@ public function leaderboard($id)
$eventId = $event->id;

$score = Score::where('eventId', $eventId)
->orderBy('score', 'desc')->orderBy('logged_on', 'asc')->limit(30)->get();
->orderBy('score', 'desc')
->orderBy('logged_on', 'asc')
->limit(30)
->get();
foreach ($score as $key => $value) {
$user = User::find($value->userId);
$value->user = $user;
Expand Down

0 comments on commit 1ea308b

Please sign in to comment.