['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.problem.preview': "/admin/problems/preview/:problem_name"]: controller "admin.problem.preview"
['admin.testcase.new': "/admin/testcases/new"]: controller "admin.testcase.new"
['admin.testcase.edit': "/admin/testcases/edit"]: controller "admin.testcase.edit"
--- /dev/null
+import make_controller from require "controllers.controller"
+import assert_valid from require "lapis.validate"
+import capture_errors, capture_errors_json, yield_error from require 'lapis.application'
+import Problems from require 'models'
+
+make_controller
+ layout: require 'views.partials.admin_layout'
+
+ middleware: { 'logged_in', 'admin_required' }
+
+ scripts: { 'admin_problem', 'vendor/ace/ace' }
+ raw_scripts: {
+ "https://polyfill.io/v3/polyfill.min.js?features=es6"
+ "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
+ }
+
+ get: capture_errors_json =>
+ @navbar.selected = 1
+
+ assert_valid @params, {
+ { "problem_name", exists: true }
+ }
+
+ @problem = Problems\find short_name: @params.problem_name
+ unless @problem
+ yield_error "Problem not found"
+
+ render: true
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'
+ div class: 'option-line', ->
+ div 'Problem description'
+ span class: 'button-list', ->
+ a href: (@url_for "admin.problem.preview", { problem_name: @problem.short_name }), "Preview"
+
pre { style: 'height: 32rem;', id: 'code-editor', 'data-lang': 'markdown' }, @problem.description
input class: 'mar-t-24', type: 'submit', value: 'Update problem info'
--- /dev/null
+html = require "lapis.html"
+markdown = require "markdown"
+
+class AdminProblemPreview extends html.Widget
+ content: =>
+ div style: 'overflow:hidden', class: 'content', ->
+ h1 @problem.name
+
+ div class: 'problem-description', ->
+ raw (markdown @problem.description)
for s in *@scripts
script type: "text/javascript", src: "/static/js/#{s}.js"
+ for s in *@raw_scripts
+ script type: "text/javascript", src: s
+
body ->
widget AdminNavbar
widget ErrorList
html = require 'lapis.html'
-import Jobs, Users from require 'models'
+import Jobs, Users, Problems from require 'models'
class SubmissionList extends html.Widget
content: =>
div class: 'content', ->
for prob in *@problems
+ if prob.kind == Problems.kinds.word then continue
+
div class: 'header-line', -> div prob.name
div class: 'box', ->
jobs = Users\get_jobs_by_problem @user.id, prob.id, @competition.id
X Show result on problem page
* This could be better and not require a reload
+[X] Problem preview
+ X Add button on problem edit page
+ X Add page that simply renders the problem in the same way as the existing problem description
+
[ ] Multiple active competitions at a time
* When users visit root of site, display list of active competitions
* Users join each competition independently