-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
use App\Http\Requests; | ||
use App\Http\Controllers\Controller; | ||
use App\Assessment; | ||
use App\Question; | ||
use App\Submission; | ||
|
||
class AssessmentController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return Response | ||
*/ | ||
public function index($questionId, $submissionId) | ||
{ | ||
$question = Question::findOrFail($questionId); | ||
$this->authorize('grade', $question); | ||
$submission = Submission::findOrFail($submissionId); | ||
$assessments = $submission->assessments; | ||
return view('assessments.index')->with(compact(['question', 'submission', 'assessments'])); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param Request $request | ||
* @return Response | ||
*/ | ||
public function assess(Request $request, $questionId, $submissionId) | ||
{ | ||
if ($request->ajax()) { | ||
$question = Question::find($questionId); // TODO | ||
$this->authorize('grade', $question); | ||
if (empty($question)) { | ||
retrun \Response::json(['error' => 'true', 'message' => 'Question Not found']); | ||
} | ||
$submission = Submission::findOrFail($id); | ||
$assessment = new Assessment($request->all()); | ||
$assessment->submission_id = $submission->id; | ||
$assessment->grader_id = $request->user()->id; | ||
$assessment->updateFinalGrade(); | ||
$submission->updateScore(); | ||
$submission->user->updateTotalScore(); | ||
return \Response::json(['success' => 'true']); | ||
} else { | ||
return redirect()->home(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@extends('app') | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-2"> | ||
<a class="btn btn-default" href="{{route('Submission::show', ['questionId' => $question->id, 'id' => $submission->id])}}">← Back to submission</a> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-10" > | ||
<div class=""> | ||
<h1>Assessments for Submission.</h1> | ||
<h3>submitted by user {{$submission->user->name}}, {{$submission->user->email}}</h3> | ||
<h3>Question #{{$question->id}}: {{ $question->name }}</h3> | ||
<p>Final Submission Grade {{$submission->score}}</p> | ||
@if(!empty($assessments)) | ||
<div class="table-responsive"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th width="30%">Grader</th> | ||
<th width="20%">Grade</th> | ||
<th width="20%">Score</th> | ||
<th width="30%">Assessed at</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($assessments as $assessment) | ||
<tr> | ||
<td>{{$assessment->grader->name}}</td> | ||
<td>{{round($assessment->grade,5)*100.0}}%</td> | ||
<td>{{round($assessment->final_grade,3)}}</td> | ||
<td>{{\Carbon\Carbon::parse($assessment->created_at)->toDayDateTimeString()}}</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> | ||
@else | ||
No Assessments | ||
@endif | ||
<hr> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters