From 56c5b3dd3cbafafa378df4ee5181ef803b12fa0d Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Fri, 17 Mar 2023 13:41:03 -0500 Subject: [PATCH] Disable ace editor for output-only problem --- judge/views/problem.py | 1 + templates/problem/submit.html | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/judge/views/problem.py b/judge/views/problem.py index e031a90..450f017 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -1194,6 +1194,7 @@ def problem_submit(request, problem, submission=None): "ACE_URL": settings.ACE_URL, "default_lang": default_lang, "problem_id": problem.id, + "output_only": problem.data_files.output_only, }, ) diff --git a/templates/problem/submit.html b/templates/problem/submit.html index 85aa159..7f36406 100644 --- a/templates/problem/submit.html +++ b/templates/problem/submit.html @@ -21,22 +21,26 @@ } function update_language_template() { - var source = $('textarea#id_source'); - if (source.val() == window.previous_template.replace(/\r/g, '') || source.val() == '') { - var lang_id = $('#id_language').val(); - var code = localStorage.getItem('submit:' + $('#id_language').val()); + {% if output_only %} + window.ace_source.env.editor.setReadOnly(true); + {% else %} + var source = $('textarea#id_source'); + if (source.val() == window.previous_template.replace(/\r/g, '') || source.val() == '') { + var lang_id = $('#id_language').val(); + var code = localStorage.getItem('submit:' + $('#id_language').val()); - if (code != null) { - update_submit_area(code); - } else { - $.get('{{ url('language_template_ajax') }}', { - id: lang_id, - problem: {{problem_id}} - }).done(function (template) { - update_submit_area(template); - }); + if (code != null) { + update_submit_area(code); + } else { + $.get('{{ url('language_template_ajax') }}', { + id: lang_id, + problem: {{problem_id}} + }).done(function (template) { + update_submit_area(template); + }); + } } - } + {% endif %} } function makeDisplayData(data) {