Created
October 18, 2012 19:47
-
-
Save pwnall/3914380 to your computer and use it in GitHub Desktop.
Grader sample code
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
require 'bundler' | |
Bundler.require | |
require './grdr.rb' | |
run Grdr |
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
source :rubygems | |
gem 'sinatra', '>= 1.3.1', require: 'sinatra/base' | |
gem 'shotgun', '>= 0.9' | |
gem 'thin', '>= 1.3.1' |
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
require 'sinatra' | |
require 'erb' | |
class Grdr < Sinatra::Base | |
enable :inline_templates | |
get '/' do | |
erb :index | |
end | |
post '/' do | |
@task = params[:task] | |
@code = params[:code] | |
# Replace with actual grading code. | |
@max_score = 1 | |
@score = 1 | |
headers['X-Grader-MaxScore'] = @max_score.to_s | |
headers['X-Grader-Score'] = @score.to_s | |
headers['X-Grader-Verdict'] = 'Accepted' | |
erb :verdict | |
end | |
end | |
__END__ | |
@@index | |
<!doctype html> | |
<html> | |
<head><title>Grader Debug Front-End</title></head> | |
<body> | |
<form action="/" method="POST" enctype="multipart/form-data"> | |
<p> | |
<label for="task-input">Task</label> | |
<select name="task" id="task-input"> | |
<option value="warmup">Warm-up</option> | |
<option value="easy">The easy problem</option> | |
<option value="medium">The reasonable problem</option> | |
<option value="hard">The really tough problem</option> | |
</select> | |
</p> | |
<p> | |
<label for="code-input">Code</label> | |
<textarea name="code"></textarea> | |
</p> | |
<p> | |
<button type="submit">Submit</button> | |
</p> | |
</form> | |
</body> | |
</html> | |
@@verdict | |
<!doctype html> | |
<html> | |
<head> | |
<title>Grader Verdict</title> | |
<style type="text/css"> | |
body { font: 13px Helvetica; } | |
h1 { font: 18px Helvetica; } | |
pre { font-size: 12px; } | |
</style> | |
</head> | |
<body> | |
<h1> | |
Grader verdict for | |
<span class="task-name"><%= @task %></span> | |
</h1> | |
<h2>Submitted code</h2> | |
<pre class="code"><%= escape_html @code %></pre> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment