{ "description", exists: true }
{ "time_limit", exists: true, is_integer: true }
{ "kind", exists: true }
+ { "blacklisted_langs", exists: true }
}
@problem = Problems\find @params.problem_id
description: @params.description
time_limit: @params.time_limit
kind: Problems.kinds\for_db @params.kind
+ blacklisted_langs: @params.blacklisted_langs
}
redirect_to: (@url_for "admin.problem.edit", problem_name: @params.short_name)
unless problem
return json: { status: 'problem not found' }
+ blacklisted = string.split problem.blacklisted_langs, ','
+ if table.contains blacklisted, @params.lang
+ return json: { status: 'Language is blacklisted for this problem' }
+
test_cases = problem\get_test_cases!
id = @executer\request @params.lang, @params.code, @user.id, problem.id, @competition.id, test_cases, problem.time_limit
{ "competition_id", types.foreign_key }
{ "user_id", types.foreign_key }
}
+
+ [13]: =>
+ add_column "problems", "blacklisted_langs", (types.varchar default: "")
}
input type: 'hidden', name: 'csrf_token', value: @csrf_token
input type: 'hidden', name: 'problem_id', value: @problem.id
- label for: 'name', 'Problem name'
- input type: 'text', name: 'name', placeholder: 'Problem name', value: @problem.name, ""
-
- div class: 'split-3', ->
+ div class: 'split-2-1', ->
div class: 'mar-r-12', ->
+ label for: 'name', 'Problem name'
+ input type: 'text', name: 'name', placeholder: 'Problem name', value: @problem.name, ""
+
+ div class: 'mar-l-12', ->
label for: 'name', 'Short name'
input type: 'text', name: 'short_name', placeholder: 'Short URL name', value: @problem.short_name, ""
- div class: 'mar-l-12 mar-r-12', ->
+ div class: 'split-3', ->
+ div class: 'mar-r-12', ->
label for: 'name', 'Time limit'
input type: 'number', value: 500, name: 'time_limit', value: @problem.time_limit, ""
- div class: 'mar-l-12', ->
+ div class: 'mar-l-12 mar-r-12', ->
label for: 'kind', 'Problem kind'
element 'select', name: 'kind', ->
option { value: 'code', selected: @problem.kind == Problems.kinds.code }, 'Programming'
option { value: 'golf', selected: @problem.kind == Problems.kinds.golf }, 'Code Golf'
option { value: 'word', selected: @problem.kind == Problems.kinds.word }, 'Word'
+ div class: 'mar-l-12', ->
+ label for: 'blacklisted_langs', 'Language blacklist (comma separated)'
+ input type: 'text', name: 'blacklisted_langs', value: @problem.blacklisted_langs, ""
+
div class: 'header-line', -> div 'Problem description'
pre { style: 'height: 32rem;', id: 'code-editor', 'data-lang': 'markdown' }, @problem.description
div "Problem kind:"
kind = Problems.kinds\to_name @problem.kind
div "#{kind}"
+ unless @problem.blacklisted_langs == ""
+ div class: 'split-lr pad-12', ->
+ div "Language blacklist:"
+ div "#{@problem.blacklisted_langs}"
div style: 'font-size: 1.3rem;', class: 'header-line', -> text "Stats for #{@problem.name}"
html = require 'lapis.html'
+require 'utils.string'
class ProblemSubmit extends html.Widget
content: =>
div class: 'split-lr', ->
div class: 'mar-l-12', ->
span -> text "Language: "
+
+ blacklisted = string.split @problem.blacklisted_langs, ','
element 'select', id: 'language', ->
- option value: 'c', -> text 'C'
- option value: 'cpp', -> text 'C++'
- option value: 'py', -> text 'Python 3'
- option value: 'lua', -> text 'Lua'
+ unless table.contains blacklisted, 'c'
+ option value: 'c', -> text 'C'
+ unless table.contains blacklisted, 'cpp'
+ option value: 'cpp', -> text 'C++'
+ unless table.contains blacklisted, 'py'
+ option value: 'py', -> text 'Python 3'
+ unless table.contains blacklisted, 'lua'
+ 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
+ pre { style: 'height: 40rem', id: 'code-editor', 'data-lang': 'c_cpp' }, ""
[X] Highlight logged in user on leaderboard
-[ ] Competition users table for enrolled users
-[ ] Competition settings table
- * Active languages
- * Points per problem type
+[X] Competition users table for enrolled users
+[X] Problem language blacklist
+[ ] Leaderboard timer and just better looking
[ ] Word problems
* Use test case 1 for answer
* input doesn't matter