Skip to content

Commit

Permalink
Fixed showing submissions issue.
Browse files Browse the repository at this point in the history
Added view submissions in profile
  • Loading branch information
zalsader committed Sep 15, 2015
1 parent 787d58e commit 43f324d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public function up()
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('question_id')->unsigned();
$table->text('blocks');
$table->text('image');
$table->longText('blocks');
$table->longText('image');
$table->boolean('hint_used')->default(false);
$table->double('score', 15, 8);
$table->timestamps();
Expand Down
8 changes: 8 additions & 0 deletions resources/views/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
<tr>
<th width="40%">Question Name</th>
<th width="20%">Question Score</th>
@can('grade', $level)
<th width="40%">Submissions</th>
@else
<th width="40%">Last Submitted</th>
@endcan
</tr>
</thead>
<tbody>
Expand All @@ -23,6 +27,9 @@
<tr>
<td><a href="{{url('question', [$question->id])}}">{{$question->name}}</a></td>
<td>{{round($level->mark,1)}}</td>
@can('grade', $level)
<td><a class="btn btn-danger" href="{{route('Submission::index', ['questionId' => $question->id])}}">View Submissions</a></td>
@else
<?php $lastSub = $question->submissions()
->where('user_id', '=', Auth::user()->id)
->orderBy('created_at', 'desc')->first(); ?>
Expand All @@ -31,6 +38,7 @@
@else
<td> Never </td>
@endif
@endcan
</tr>
@endif
@endforeach
Expand Down
42 changes: 42 additions & 0 deletions resources/views/submissions/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@extends('app')

@section('content')
<div class="container">
<div class="row">
<div class="col-md-8" >
<div class="">
<h1>Submissions for Question #{{$question->id}}: {{ $question->name }}</h1>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th width="30%">User</th>
<th width="20%">Score</th>
<th width="30%">Last Assessed</th>
<th width="20%">View<th>
</tr>
</thead>
<tbody>
@foreach($submissions as $submission)
<tr>
<td>{{$submission->user->name}}</td>
<td>{{round($submission->score,3)}}</td>
<?php $lastAssessment = $submission->assessments()
->orderBy('created_at', 'desc')->first(); ?>
@if (!empty($lastAssessment))
<td>{{\Carbon\Carbon::parse($lastAssessment->created_at)->toDayDateTimeString()}}</td>
@else
<td> Never </td>
@endif
<td><a class="btn btn-danger" href="{{route('Submission::show', ['questionId' => $question->id, 'id' => $submission->id])}}">View Submission<a></td>
</tr>
@endforeach
</tbody>
</table>
</div>
<hr>
</div>
</div>
</div>
</div>
@stop
10 changes: 7 additions & 3 deletions resources/views/submissions/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@
<!-- TODO diff & assess -->
</div>

<iframe class="game" src="{{'https://thinklikeaprogrammer.appspot.com/static/apps/turtle/index.html?blocks='.$submission->blocks}}" width="95%" height="655" sandbox="allow-same-origin allow-scripts"></iframe>
<iframe class="game" src="{{url('/game/apps/turtle/index.html')}}" width="95%" height="655" sandbox="allow-same-origin allow-scripts"></iframe>

@stop

@section('scripts')
<script type="text/javascript">
var defaultXml = '<xml>' + decodeURIComponent('{{$submission->blocks}}') + '</xml>';
$(function(){
$('.measure').each(function(){
createMeasurement(this);
})
});
});
$('.game').on('load', function(){
var BlocklyApps = this.contentWindow.BlocklyApps;
BlocklyApps.loadBlocks(defaultXml);
})
</script>
@stop

0 comments on commit 43f324d

Please sign in to comment.