['account.logout': "/logout"]: controller "account.logout"
['account.register': "/register"]: controller "account.register"
- ['problem': '/problem']: controller "problem.problem"
- ['problem.description': '/problem/:problem_name']: controller "problem.problem"
- ['problem.submit': '/problem/:problem_name/submit']: controller "problem.submit"
+ ['problem': '/problems']: controller "problem.problem"
+ ['problem.description': '/problems/:problem_name']: controller "problem.problem"
+ ['problem.submit': '/problems/:problem_name/submit']: controller "problem.submit"
+
+ ['submission.list': '/submissions']: controller "submission.list"
+ ['submission.view': '/submissions/view']: controller "submission.view"
+ ['submission.status': '/submissions/status']: controller "submission.status"
['executer.status_update': "/executer/status_update"]: controller "executer.status_update"
['executer.request': '/executer/request']: controller "executer.request"
['admin.user.reset_password': "/admin/user/reset_password"]: controller "admin.user.reset_password"
['admin.user.delete': "/admin/user/delete"]: controller "admin.user.delete"
- ['admin.problem': "/admin/problem"]: controller "admin.problem"
- ['admin.problem.new': "/admin/problem/new"]: controller "admin.problem.new"
- ['admin.problem.edit': "/admin/problem/edit/:problem_name"]: controller "admin.problem.edit"
- ['admin.problem.delete': "/admin/problem/delete"]: controller "admin.problem.delete"
-
- ['admin.testcase.new': "/admin/testcase/new"]: controller "admin.testcase.new"
- ['admin.testcase.edit': "/admin/testcase/edit"]: controller "admin.testcase.edit"
- ['admin.testcase.delete': "/admin/testcase/delete"]: controller "admin.testcase.delete"
-
- ['admin.submission': "/admin/submission"]: controller "admin.submission"
- ['admin.submission.edit': "/admin/submission/edit"]: controller "admin.submission.edit"
- ['admin.submission.delete': "/admin/submission/delete"]: controller "admin.submission.delete"
-
- ['admin.competition': "/admin/competition"]: controller "admin.competition"
- ['admin.competition.new': "/admin/competition/new"]: controller "admin.competition.new"
- ['admin.competition.edit': "/admin/competition/edit/:competition_id"]: controller "admin.competition.edit"
- ['admin.competition.delete': "/admin/competition/delete/:competition_id"]: controller "admin.competition.delete"
- ['admin.competition.add_problem': "/admin/competition/add_problem"]: controller "admin.competition.add_problem"
- ['admin.competition.delete_problem': "/admin/competition/delete_problem"]: controller "admin.competition.delete_problem"
- ['admin.competition.activate': "/admin/competition/activate/:competition_id"]: controller "admin.competition.activate"
-
- [test: '/test']: =>
- table.insert @scripts, "vendor/ace/ace"
- @html ->
- div style: 'position: relative; width: 100%; height: 15rem', id: 'editor', ->
- text "function test() {
- console.log('Hello World!');
- }"
+ ['admin.problem': "/admin/problems"]: controller "admin.problem"
+ ['admin.problem.new': "/admin/problems/new"]: controller "admin.problem.new"
+ ['admin.problem.edit': "/admin/problems/edit/:problem_name"]: controller "admin.problem.edit"
+ ['admin.problem.delete': "/admin/problems/delete"]: controller "admin.problem.delete"
+
+ ['admin.testcase.new': "/admin/testcases/new"]: controller "admin.testcase.new"
+ ['admin.testcase.edit': "/admin/testcases/edit"]: controller "admin.testcase.edit"
+ ['admin.testcase.delete': "/admin/testcases/delete"]: controller "admin.testcase.delete"
+
+ ['admin.submission': "/admin/submissions"]: controller "admin.submission"
+ ['admin.submission.edit': "/admin/submissions/edit"]: controller "admin.submission.edit"
+ ['admin.submission.delete': "/admin/submissions/delete"]: controller "admin.submission.delete"
+
+ ['admin.competition': "/admin/competitions"]: controller "admin.competition"
+ ['admin.competition.new': "/admin/competitions/new"]: controller "admin.competition.new"
+ ['admin.competition.edit': "/admin/competitions/edit/:competition_id"]: controller "admin.competition.edit"
+ ['admin.competition.delete': "/admin/competitions/delete/:competition_id"]: controller "admin.competition.delete"
+ ['admin.competition.add_problem': "/admin/competitions/add_problem"]: controller "admin.competition.add_problem"
+ ['admin.competition.delete_problem': "/admin/competitions/delete_problem"]: controller "admin.competition.delete_problem"
+ ['admin.competition.activate': "/admin/competitions/activate/:competition_id"]: controller "admin.competition.activate"
"/console": console.make!
GET: =>
r = routes.get(@)
- r.layout or= routes.layout
+ if type(r) == "table"
+ r.layout or= routes.layout
return r
POST: =>
r = routes.post(@)
- r.layout or= routes.layout
+ if type(r) == "table"
+ r.layout or= routes.layout
return r
DELETE: =>
r = routes.delete(@)
- r.layout or= routes.layout
+ if type(r) == "table"
+ r.layout or= routes.layout
return r
}
}
test_cases = problem\get_test_cases!
- id = @executer\request @params.lang, @params.code, @params.problem_id, test_cases, problem.time_limit
+ id = @executer\request @params.lang, @params.code, 1, @params.problem_id, test_cases, problem.time_limit
json: id
), =>
get: =>
@navbar.selected = 1
- @current_comp = Competitions\find active: true
- @problems = @current_comp\get_problems!
-
if @params.problem_name
@problem = Problems\find short_name: @params.problem_name
- for prob in *@problems
- if @queries.has_correct_submission @user.id, prob.short_name
- print "FOUND CORRECT FOR ", prob.name
- prob.tag = "correct"
- elseif @queries.has_incorrect_submission @user.id, prob.short_name
- print "FOUND INCORRECT FOR ", prob.name
- prob.tab = "incorrect"
-
render: 'problem.problem'
--- /dev/null
+import make_controller from require "controllers.controller"
+import from_json, to_json from require 'lapis.util'
+import assert_valid from require 'lapis.validate'
+import capture_errors, capture_errors_json, yield_error from require 'lapis.application'
+import Competitions, Problems from require 'models'
+
+make_controller
+ inject:
+ queries: 'queries'
+ executer: 'executer'
+
+ middleware: { 'logged_in' }
+ scripts: { 'vendor/ace/ace', 'problem_submit' }
+
+ get: capture_errors_json =>
+ assert_valid @params, {
+ { "problem_name", exists: true }
+ }
+
+ @navbar.selected = 1
+
+ @problem = Problems\find short_name: @params.problem_name
+
+ render: 'problem.submit'
+
+ post: capture_errors_json =>
+ assert_valid @params, {
+ { "problem_name", exists: true }
+ { "lang", exists: true }
+ { "code", exists: true }
+ }
+
+ problem = Problems\find short_name: @params.problem_name
+ unless problem
+ return json: { status: 'problem not found' }
+
+ test_cases = problem\get_test_cases!
+
+ id = @executer\request @params.lang, @params.code, @user.id, problem.id, test_cases, problem.time_limit
+
+ json: id
+
--- /dev/null
+include_rules
--- /dev/null
+import make_controller from require "controllers.controller"
+import from_json, to_json from require 'lapis.util'
+import assert_valid from require 'lapis.validate'
+import capture_errors, yield_error from require 'lapis.application'
+import Competitions, Jobs from require 'models'
+
+make_controller
+ inject:
+ queries: 'queries'
+
+ middleware: { 'logged_in' }
+
+ get: =>
+ @navbar.selected = 2
+
+ render: 'submission.list'
\ No newline at end of file
--- /dev/null
+import make_controller from require "controllers.controller"
+import from_json, to_json from require 'lapis.util'
+import assert_valid from require 'lapis.validate'
+import capture_errors, capture_errors_json, yield_error from require 'lapis.application'
+import Competitions, Jobs from require 'models'
+JobResult = require 'views.ssr.job_result'
+
+make_controller
+ layout: false
+ middleware: { 'logged_in' }
+
+ get: capture_errors_json =>
+ @navbar.selected = 2
+
+ assert_valid @params, {
+ { "submission_id", exists: true }
+ }
+
+ @job = Jobs\find job_id: @params.submission_id
+ unless @job.user_id == @user.id
+ yield_error "You are not allowed to view this submission!"
+
+ status_code = 201
+ switch @job.status
+ when Jobs.statuses.queued then status_code = 200
+ when Jobs.statuses.compiling then status_code = 200
+ when Jobs.statuses.running then status_code = 200
+
+ status_widget = JobResult @job
+ return { layout: false, status: status_code, status_widget\render_to_string! }
\ No newline at end of file
--- /dev/null
+import make_controller from require "controllers.controller"
+import from_json, to_json from require 'lapis.util'
+import assert_valid from require 'lapis.validate'
+import capture_errors, capture_errors_json, yield_error from require 'lapis.application'
+import Competitions, Jobs from require 'models'
+
+make_controller
+ inject:
+ queries: 'queries'
+
+ middleware: { 'logged_in' }
+ scripts: { 'vendor/ace/ace', 'submission_reloader' }
+
+ get: capture_errors_json =>
+ @navbar.selected = 2
+
+ assert_valid @params, {
+ { "submission_id", exists: true }
+ }
+
+ @job = Jobs\find job_id: @params.submission_id
+ unless @job.user_id == @user.id
+ yield_error "You are not allowed to view this submission!"
+
+ render: 'submission.view'
\ No newline at end of file
import Jobs from require 'models'
class ExecuterFacade
- request: (lang, code, problem_id, test_cases, time_limit) =>
+ request: (lang, code, user_id, problem_id, test_cases, time_limit) =>
body = http.simple "#{config.executer_addr}/request", {
:lang
:code
job = Jobs\create {
job_id: job_id
- user_id: 1
+ user_id: user_id
problem_id: problem_id
status: Jobs.statuses\for_db 'queued'
lang: lang
for i in [1..segments]
total += parseInt ($p.attr "data-segment-#{i}")
- fill_perc = 0
+ fill_perc = 0.01
anim = ->
acc = 0
acc += ratio
- fill_perc += 0.05
+ fill_perc += fill_perc / 10 + 0.01
if fill_perc >= 1
fill_perc = 1
--- /dev/null
+$(document).ready ->
+ $("#language").change (ev) ->
+ $lang = $(ev.target).val()
+
+ editor_lang = switch $lang
+ when 'c' then 'c_cpp'
+ when 'cpp' then 'c_cpp'
+ when 'py' then 'python'
+ when 'lua' then 'lua'
+
+ editor = ace.edit 'code-editor'
+ editor.session.setMode "ace/mode/#{editor_lang}"
+
+ $('#submit-btn').click ->
+ lang = $('#language').val()
+ code = (ace.edit 'code-editor').getValue()
+
+ $.post window.location.pathname, {
+ lang: lang,
+ code: code
+ }, (data) ->
+ window.location.replace("/submissions/view?submission_id=#{data}");
--- /dev/null
+submission_id = (new URLSearchParams window.location.search).get 'submission_id'
+
+updateStatus = ->
+ $.get '/submissions/status', { submission_id: submission_id }, (html, _, data) ->
+ $('#status-container').html html
+
+ if data.status == 200
+ setTimeout updateStatus, 100
+
+$(document).ready ->
+ updateStatus()
\ No newline at end of file
for (i = j = 1, ref = segments; (1 <= ref ? j <= ref : j >= ref); i = 1 <= ref ? ++j : --j) {
total += parseInt($p.attr(`data-segment-${i}`));
}
- fill_perc = 0;
+ fill_perc = 0.01;
anim = function() {
var acc, color, k, ratio, ref1;
acc = 0;
ctx.fill();
acc += ratio;
}
- fill_perc += 0.05;
+ fill_perc += fill_perc / 10 + 0.01;
if (fill_perc >= 1) {
fill_perc = 1;
window.requestAnimationFrame(anim);
"coffee/pie_chart.coffee"
],
"names": [],
- "mappings": ";AAAA;EAAA,CAAA,CAAE,QAAF,CAAW,CAAC,KAAZ,CAAkB,QAAA,CAAA,CAAA;WACd,CAAA,CAAE,UAAF,CAAa,CAAC,IAAd,CAAmB,QAAA,CAAC,CAAD,EAAI,CAAJ,CAAA;AACf,UAAA,EAAA,EAAA,IAAA,EAAA,MAAA,EAAA,GAAA,EAAA,SAAA,EAAA,CAAA,EAAA,CAAA,EAAA,GAAA,EAAA,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AgB,CAAhB,CAAA,CAAR,CAAV,CAAD,CAAA,GAA2C;UACnD,KAAA,GAAQ,EAAE,CAAC,IAAH,CAAQ,CAAA,aAAA,CAAA,CAAgB,CAAhB,CAAkB,MAAlB,CAAR;UAER,GAAG,CAAC,SAAJ,CAAA;UACA,GAAG,CAAC,MAAJ,CAAW,GAAX,EAAgB,GAAhB;UACA,GAAG,CAAC,GAAJ,CAAQ,GAAR,EAAa,GAAb,EAAkB,GAAlB,EAAwB,CAAC,CAAD,GAAK,IAAI,CAAC,EAAV,GAAe,CAAC,KAAA,GAAQ,GAAT,CAAf,GAA+B,KAAvD,EAAgE,CAAC,CAAD,GAAK,IAAI,CAAC,EAAV,GAAe,GAAf,GAAqB,KAArF;UACA,GAAG,CAAC,SAAJ,CAAA;UACA,GAAG,CAAC,SAAJ,GAAgB;UAChB,GAAG,CAAC,IAAJ,CAAA;UAEA,GAAA,IAAO;QAXX;QAaA,SAAA,IAAa,SAAA,GAAY,EAAZ,GAAiB;QAE9B,IAAG,SAAA,IAAa,CAAhB;UACI,SAAA,GAAY;UACZ,MAAM,CAAC,qBAAP,CAA6B,IAA7B,EAFJ;;QAIA,IAAG,SAAA,GAAY,CAAf;iBACI,MAAM,CAAC,qBAAP,CAA6B,IAA7B,EADJ;;MArBG;aAwBP,MAAM,CAAC,qBAAP,CAA6B,IAA7B;IAxCe,CAAnB;EADc,CAAlB;AAAA",
"sourcesContent": [
- "$(document).ready ->\n $('piechart').each (_, p) ->\n $p = $ p\n segments = $p.attr 'data-segments'\n\n canvas = document.createElement \"canvas\"\n canvas.width = 256\n canvas.height = 256\n $p.append canvas\n ctx = canvas.getContext \"2d\"\n\n total = 0\n for i in [1..segments]\n total += parseInt ($p.attr \"data-segment-#{i}\")\n \n fill_perc = 0\n\n anim = ->\n acc = 0\n for i in [1..segments]\n ratio = (parseInt ($p.attr \"data-segment-#{i}\")) * fill_perc\n color = $p.attr \"data-segment-#{i}-color\"\n\n ctx.beginPath()\n ctx.moveTo 128, 128\n ctx.arc 128, 128, 128, (-2 * Math.PI * (ratio + acc) / total), (-2 * Math.PI * acc / total)\n ctx.closePath()\n ctx.fillStyle = color\n ctx.fill()\n\n acc += ratio\n\n fill_perc += 0.05\n\n if fill_perc >= 1\n fill_perc = 1\n window.requestAnimationFrame anim\n\n if fill_perc < 1\n window.requestAnimationFrame anim\n \n window.requestAnimationFrame anim\n\n"
+ "$(document).ready ->\n $('piechart').each (_, p) ->\n $p = $ p\n segments = $p.attr 'data-segments'\n\n canvas = document.createElement \"canvas\"\n canvas.width = 256\n canvas.height = 256\n $p.append canvas\n ctx = canvas.getContext \"2d\"\n\n total = 0\n for i in [1..segments]\n total += parseInt ($p.attr \"data-segment-#{i}\")\n \n fill_perc = 0.01\n\n anim = ->\n acc = 0\n for i in [1..segments]\n ratio = (parseInt ($p.attr \"data-segment-#{i}\")) * fill_perc\n color = $p.attr \"data-segment-#{i}-color\"\n\n ctx.beginPath()\n ctx.moveTo 128, 128\n ctx.arc 128, 128, 128, (-2 * Math.PI * (ratio + acc) / total), (-2 * Math.PI * acc / total)\n ctx.closePath()\n ctx.fillStyle = color\n ctx.fill()\n\n acc += ratio\n\n fill_perc += fill_perc / 10 + 0.01\n\n if fill_perc >= 1\n fill_perc = 1\n window.requestAnimationFrame anim\n\n if fill_perc < 1\n window.requestAnimationFrame anim\n \n window.requestAnimationFrame anim\n\n"
]
}
\ No newline at end of file
--- /dev/null
+// Generated by CoffeeScript 2.4.1
+(function() {
+ $(document).ready(function() {
+ $("#language").change(function(ev) {
+ var $lang, editor, editor_lang;
+ $lang = $(ev.target).val();
+ editor_lang = (function() {
+ switch ($lang) {
+ case 'c':
+ return 'c_cpp';
+ case 'cpp':
+ return 'c_cpp';
+ case 'py':
+ return 'python';
+ case 'lua':
+ return 'lua';
+ }
+ })();
+ editor = ace.edit('code-editor');
+ return editor.session.setMode(`ace/mode/${editor_lang}`);
+ });
+ return $('#submit-btn').click(function() {
+ var code, lang;
+ lang = $('#language').val();
+ code = (ace.edit('code-editor')).getValue();
+ return $.post(window.location.pathname, {
+ lang: lang,
+ code: code
+ }, function(data) {
+ return window.location.replace(`/submissions/view?submission_id=${data}`);
+ });
+ });
+ });
+
+}).call(this);
+
+//# sourceMappingURL=problem_submit.js.map
--- /dev/null
+{
+ "version": 3,
+ "file": "problem_submit.js",
+ "sourceRoot": "..",
+ "sources": [
+ "coffee/problem_submit.coffee"
+ ],
+ "names": [],
+ "mappings": ";AAAA;EAAA,CAAA,CAAE,QAAF,CAAW,CAAC,KAAZ,CAAkB,QAAA,CAAA,CAAA;IACd,CAAA,CAAE,WAAF,CAAc,CAAC,MAAf,CAAsB,QAAA,CAAC,EAAD,CAAA;AAClB,UAAA,KAAA,EAAA,MAAA,EAAA;MAAA,KAAA,GAAQ,CAAA,CAAE,EAAE,CAAC,MAAL,CAAY,CAAC,GAAb,CAAA;MAER,WAAA;AAAc,gBAAO,KAAP;AAAA,eACL,GADK;mBACI;AADJ,eAEL,KAFK;mBAEM;AAFN,eAGL,IAHK;mBAGK;AAHL,eAIL,KAJK;mBAIM;AAJN;;MAMd,MAAA,GAAS,GAAG,CAAC,IAAJ,CAAS,aAAT;aACT,MAAM,CAAC,OAAO,CAAC,OAAf,CAAuB,CAAA,SAAA,CAAA,CAAY,WAAZ,CAAA,CAAvB;IAVkB,CAAtB;WAYA,CAAA,CAAE,aAAF,CAAgB,CAAC,KAAjB,CAAuB,QAAA,CAAA,CAAA;AACnB,UAAA,IAAA,EAAA;MAAA,IAAA,GAAO,CAAA,CAAE,WAAF,CAAc,CAAC,GAAf,CAAA;MACP,IAAA,GAAO,CAAC,GAAG,CAAC,IAAJ,CAAS,aAAT,CAAD,CAAwB,CAAC,QAAzB,CAAA;aAEP,CAAC,CAAC,IAAF,CAAO,MAAM,CAAC,QAAQ,CAAC,QAAvB,EAAiC;QAC7B,IAAA,EAAM,IADuB;QAE7B,IAAA,EAAM;MAFuB,CAAjC,EAGG,QAAA,CAAC,IAAD,CAAA;eACC,MAAM,CAAC,QAAQ,CAAC,OAAhB,CAAwB,CAAA,gCAAA,CAAA,CAAmC,IAAnC,CAAA,CAAxB;MADD,CAHH;IAJmB,CAAvB;EAbc,CAAlB;AAAA",
+ "sourcesContent": [
+ "$(document).ready ->\n $(\"#language\").change (ev) ->\n $lang = $(ev.target).val()\n\n editor_lang = switch $lang\n when 'c' then 'c_cpp'\n when 'cpp' then 'c_cpp'\n when 'py' then 'python'\n when 'lua' then 'lua'\n \n editor = ace.edit 'code-editor'\n editor.session.setMode \"ace/mode/#{editor_lang}\"\n\n $('#submit-btn').click ->\n lang = $('#language').val()\n code = (ace.edit 'code-editor').getValue()\n\n $.post window.location.pathname, {\n lang: lang,\n code: code\n }, (data) ->\n window.location.replace(\"/submissions/view?submission_id=#{data}\");\n"
+ ]
+}
\ No newline at end of file
--- /dev/null
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var submission_id, updateStatus;
+
+ submission_id = (new URLSearchParams(window.location.search)).get('submission_id');
+
+ updateStatus = function() {
+ return $.get('/submissions/status', {
+ submission_id: submission_id
+ }, function(html, _, data) {
+ $('#status-container').html(html);
+ if (data.status === 200) {
+ return setTimeout(updateStatus, 100);
+ }
+ });
+ };
+
+ $(document).ready(function() {
+ return updateStatus();
+ });
+
+}).call(this);
+
+//# sourceMappingURL=submission_reloader.js.map
--- /dev/null
+{
+ "version": 3,
+ "file": "submission_reloader.js",
+ "sourceRoot": "..",
+ "sources": [
+ "coffee/submission_reloader.coffee"
+ ],
+ "names": [],
+ "mappings": ";AAAA;AAAA,MAAA,aAAA,EAAA;;EAAA,aAAA,GAAgB,CAAC,IAAI,eAAJ,CAAoB,MAAM,CAAC,QAAQ,CAAC,MAApC,CAAD,CAA4C,CAAC,GAA7C,CAAiD,eAAjD;;EAEhB,YAAA,GAAe,QAAA,CAAA,CAAA;WACX,CAAC,CAAC,GAAF,CAAM,qBAAN,EAA6B;MAAE,aAAA,EAAe;IAAjB,CAA7B,EAA+D,QAAA,CAAC,IAAD,EAAO,CAAP,EAAU,IAAV,CAAA;MAC3D,CAAA,CAAE,mBAAF,CAAsB,CAAC,IAAvB,CAA4B,IAA5B;MAEA,IAAG,IAAI,CAAC,MAAL,KAAe,GAAlB;eACI,UAAA,CAAW,YAAX,EAAyB,GAAzB,EADJ;;IAH2D,CAA/D;EADW;;EAOf,CAAA,CAAE,QAAF,CAAW,CAAC,KAAZ,CAAkB,QAAA,CAAA,CAAA;WACd,YAAA,CAAA;EADc,CAAlB;AATA",
+ "sourcesContent": [
+ "submission_id = (new URLSearchParams window.location.search).get 'submission_id'\n\nupdateStatus = ->\n $.get '/submissions/status', { submission_id: submission_id }, (html, _, data) ->\n $('#status-container').html html\n\n if data.status == 200\n setTimeout updateStatus, 100\n\n$(document).ready ->\n updateStatus()"
+ ]
+}
\ No newline at end of file
widget (require('views.ssr.job_result')(@job))
div class: 'header-line', ->
- div -> text "#{@job.lang} code"
+ div -> text "#{@job.lang\upper!} code"
pre { id: 'code-editor', 'data-lang': 'c_cpp', 'data-readonly': 'true' }, -> text @job.code
ul ->
a -> li class: { 'selected': @navbar.selected == 0 }, 'Leaderboard'
a href: (@url_for 'problem'), -> li class: { 'selected': @navbar.selected == 1 }, 'Problems'
- a -> li class: { 'selected': @navbar.selected == 2 }, 'Submissions'
+ a href: (@url_for 'submission.list'), -> li class: { 'selected': @navbar.selected == 2 }, 'Submissions'
--- /dev/null
+html = require 'lapis.html'
+import Competitions from require 'models'
+
+class ProblemSidebar extends html.Widget
+ load_problems: =>
+ @current_comp = Competitions\find active: true
+ @problems = @current_comp\get_problems!
+
+ for prob in *@problems
+ if @queries.has_correct_submission @user.id, prob.short_name
+ prob.tag = "correct"
+ elseif @queries.has_incorrect_submission @user.id, prob.short_name
+ prob.tab = "incorrect"
+
+ content: =>
+ @load_problems!
+
+ for prob in *@problems
+ a href: (@url_for 'problem.description', problem_name: prob.short_name), ->
+ div {
+ selected: prob.short_name == @params.problem_name
+ correct: prob.tag == "correct"
+ wrong: prob.tab == "incorrect"
+ class: 'sidebar-problem'
+ }, ->
+ div class: 'sidebar-problem-letter', -> text prob.letter
+ div class: 'sidebar-problem-name', -> text prob.name
\ No newline at end of file
content: =>
div class: 'sidebar-page-container', ->
div class: 'sidebar-problem-list', ->
- for prob in *@problems
- a href: (@url_for 'problem.description', problem_name: prob.short_name), ->
- div {
- selected: prob.short_name == @params.problem_name
- correct: prob.tag == "correct"
- wrong: prob.tab == "incorrect"
- class: 'sidebar-problem'
- }, ->
- div class: 'sidebar-problem-letter', -> text prob.letter
- div class: 'sidebar-problem-name', -> text prob.name
+ widget (require 'views.partials.problem_sidebar')
div class: 'content', ->
unless @problem
else
h1 @problem.name
div class: 'problem-info', ->
- a style: "width: 100%; text-align: center", class: 'button', -> text "Make a submission"
+ a style: "width: 100%; text-align: center", class: 'button', href: (@url_for 'problem.submit', { problem_name: @problem.short_name }), ->
+ text "Make a submission"
div style: 'font-size: 1.3rem; margin-top: 0', class: 'header-line', -> text "Stats for #{@problem.name}"
--- /dev/null
+html = require 'lapis.html'
+
+class ProblemSubmit extends html.Widget
+ content: =>
+ div class: 'sidebar-page-container', ->
+ div class: 'sidebar-problem-list', ->
+ widget (require 'views.partials.problem_sidebar')
+
+ div class: 'content', ->
+ h1 "Submit to '#{@problem.name}'"
+
+ div class: 'header-line', -> text "Code Editor"
+ div class: 'box', ->
+ div class: 'split-lr', ->
+ div class: 'mar-l-12', ->
+ span -> text "Language: "
+ element 'select', id: 'language', ->
+ option value: 'c', -> text 'C'
+ option value: 'cpp', -> text 'C++'
+ option value: 'py', -> text 'Python'
+ option value: 'lua', -> text 'Lua'
+ div class: 'button-list', ->
+ button id: 'submit-btn', -> text "Submit"
+
+ pre { style: 'height: 40rem', id: 'code-editor', 'data-lang': 'c_cpp' }, ""
\ No newline at end of file
@username = @job\get_user!.username
@problem = @job\get_problem!.name
- @json_data = from_json @job.data
@time_started = @job.time_initiated
+ if @job.data
+ @json_data = from_json @job.data
+ else
+ @json_data = nil
@ring_color = ''
switch @job.status
when Jobs.statuses.bad_language then @show_slash = false
when Jobs.statuses.bad_problem then @show_slash = false
- if @show_slash
+ if @show_slash and type(@json_data) == "table"
@completed_percentage = math.floor(100 * (@json_data.completed / @json_data.total))
content: =>
div class: 'fixed-half-split', ->
div ->
span class: "mar-t-12 mar-l-12 c100 p#{@completed_percentage} big dark #{@ring_color}", ->
- if @show_slash
+ if @show_slash and type(@json_data) == "table"
span -> text "#{@json_data.completed} / #{@json_data.total}"
else
span -> text "Error"
div 'Test cases'
div class: 'box', ->
+ return unless type(@json_data) == "table"
+
for i = 1, @json_data.total
tc_status = 'secondary'
if i <= @json_data.completed
p "---------"
if type(@json_data.run_times[i]) == 'number'
- p "Run time: #{@json_data.run_times[i]}s"
+ p "Run time: #{@json_data.run_times[i] / 1000000}s"
else
div class: 'header-line', ->
div 'Errors'
div class: 'box', ->
+ return unless @job.data
pre (process_str @job.data)
--- /dev/null
+include_rules
--- /dev/null
+html = require 'lapis.html'
+
+class SubmissionList extends html.Widget
+ content: =>
+ h1 "Submission"
\ No newline at end of file
--- /dev/null
+html = require 'lapis.html'
+
+class SubmissionView extends html.Widget
+ content: =>
+ div class: 'content', ->
+ div id: 'status-container', ->
+ widget (require('views.ssr.job_result')(@job))
+
+ div class: 'header-line', ->
+ div -> text "#{@job.lang\upper!} code"
+
+ pre { id: 'code-editor', 'data-lang': 'c_cpp', 'data-readonly': 'true' }, -> text @job.code
\ No newline at end of file
class Executer
compilers: {
- 'C': new CCompiler(),
- 'CPP': new CPPCompiler()
+ 'c': new CCompiler(),
+ 'cpp': new CPPCompiler()
}
executers: {
- 'C': new CExecuter(),
- 'CPP': new CExecuter()
+ 'c': new CExecuter(),
+ 'cpp': new CExecuter()
}
process: (lang, code, test_cases, time_limit) ->
await return
process_code: (lang, code, test_cases, time_limit) ->
- compiler = @compilers[lang]
+ compiler = @compilers[lang.toLowerCase()]
unless compiler?
- yield { status: 8 }
+ yield { status: 7 }
return
yield { status: 2 }
unless executer?
exec_file.delete_file()
- yield { status: 8 }
+ yield { status: 7 }
return
total_cases = test_cases.length
run_times = new Array total_cases
completed = 0
+ # Wait a second so the submission page looks cooler
+ await new Promise (res) ->
+ setTimeout res, 500
+
yield { status: 3, data: { completed: completed, total: total_cases, run_times: run_times } }
for test_case in test_cases
res = await executer.execute exec_file.file_path, test_case.input, time_limit
+ await new Promise (res) ->
+ setTimeout res, 200
switch (res.status)
when 'SUCCESS'