Skip to content

Commit

Permalink
Added show submission
Browse files Browse the repository at this point in the history
Removed sounds and closing message.
  • Loading branch information
zalsader committed Sep 14, 2015
1 parent e6c9bbf commit 4f0dbc2
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 10 deletions.
8 changes: 6 additions & 2 deletions app/Http/Controllers/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class SubmissionController extends Controller
*/
public function index($questionId)
{
//
$question = Question::findOrFail($questionId);
$submissions = $question->submissions;
return view('submissions.index')->with(compact(['question', 'submissions']));
}

/**
Expand Down Expand Up @@ -56,6 +58,8 @@ public function submit(Request $request, $questionId)
*/
public function show($questionId, $id)
{
//
$question = Question::findOrFail($questionId);
$submission = Submission::findOrFail($id);
return view('submissions.show')->with(compact(['question', 'submission']));
}
}
6 changes: 5 additions & 1 deletion app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
Route::get('logout', 'Auth\AuthController@getLogout');
Route::group(['middleware' => 'auth'], function($router){
$router->resource('profile','ProfileController');
$router->post('question/{questionId}/submit', 'SubmissionController@submit');
Route::group(['as' => 'Submission::', 'prefix' => 'question/{questionId}'], function($r){
$r->post('submit', ['as' => 'submit', 'uses' => 'SubmissionController@submit']);
$r->get('submissions/', ['as' => 'index', 'uses' => 'SubmissionController@index']);
$r->get('submissions/{id}', ['as' => 'show', 'uses' => 'SubmissionController@show']);
});
$router->get('question/{questionId}/hint', 'QuestionController@hint');
$router->resource('question','QuestionController');
});
14 changes: 7 additions & 7 deletions public/game/apps/turtle/turtle.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ Turtle.init = function() {
// (execute) and the infinite loop detection function.
Blockly.JavaScript.addReservedWords('Turtle,code');

window.addEventListener('beforeunload', function(e) {
if (Blockly.mainWorkspace.getAllBlocks().length > 2) {
e.returnValue = BlocklyApps.getMsg('Turtle_unloadWarning'); // Gecko.
return BlocklyApps.getMsg('Turtle_unloadWarning'); // Webkit.
}
return null;
});
// window.addEventListener('beforeunload', function(e) {
// if (Blockly.mainWorkspace.getAllBlocks().length > 2) {
// e.returnValue = BlocklyApps.getMsg('Turtle_unloadWarning'); // Gecko.
// return BlocklyApps.getMsg('Turtle_unloadWarning'); // Webkit.
// }
// return null;
// });

// Hide download button if browser lacks support
// (http://caniuse.com/#feat=download).
Expand Down
Binary file added public/game/media/click1.mp3
Binary file not shown.
Binary file added public/game/media/click1.ogg
Binary file not shown.
Binary file added public/game/media/click1.wav
Binary file not shown.
Binary file added public/game/media/delete1.mp3
Binary file not shown.
Binary file added public/game/media/delete1.ogg
Binary file not shown.
1 change: 1 addition & 0 deletions resources/views/questions/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class="{{empty($question->hint_image)? 'hidden': ''}}">
},
success: function(response) {
$('#successfulSubmission').removeClass('hidden');
window.scrollTo(0, 0);
}
});
});
Expand Down
57 changes: 57 additions & 0 deletions resources/views/submissions/show.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@extends('app')

@section('content')
<div class="container">
<div class="row">
<div id="successfulSubmission" class="alert alert-success fade in hidden">
<a href="#" class="close" data-dismiss="alert">&times;</a>
Your assessment has been recorded.
</div>
</div>
<div class="row">
<div class="col-md-2">
<a class="btn btn-default" href="{{route('Submission::index', ['questionId' => $question->id])}}">&#8592; Back to submissions</a>
</div>
</div>
<div class="row">
<div class="col-md-6" >
<h1>{{ $question->name }}</h1>
<h3>Submitted by {{$submission->user->name}}</h3>
<p>{{ $question->description }}</p>
</div>
</div>
<div class="row">
<div class="col-md-6">
<h3>Question:</h3>
<div width="400" height="400" style="position: relative;">
<img src="{{asset('images/questions/'.$question->image)}}" alt="">
<canvas class="measure" width="400" height="400"
style="position: absolute; left: 0; top: 0; z-index: 1;"></canvas>
</div>
</div>
<div class="col-md-6">
<h3>Submission:</h3>
<div width="400" height="400" style="position: relative;">
<img src="{{$submission->image}}" alt="">
<canvas class="measure" width="400" height="400"
style="position: absolute; left: 0; top: 0; z-index: 1;"></canvas>
</div>
</div>
</div>

</div>

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

@stop

@section('scripts')
<script type="text/javascript">
$(function(){
$('.measure').each(function(){
createMeasurement(this);
})
});
</script>
@stop

0 comments on commit 4f0dbc2

Please sign in to comment.