diff --git a/web/app/controllers/problem_data_configure.php b/web/app/controllers/problem_data_configure.php new file mode 100644 index 00000000..a38d23b2 --- /dev/null +++ b/web/app/controllers/problem_data_configure.php @@ -0,0 +1,62 @@ +userCanManage(Auth::user()) || UOJResponse::page403(); + +$problem_configure = new UOJProblemConfigure(UOJProblem::cur()); +$problem_configure->runAtServer(); +$problem_conf_str = ''; + +foreach ($problem_configure->problem_conf->conf as $key => $val) { + if ($key == 'use_builtin_judger' && $val == 'off') { + continue; + } + + if ($key == 'use_builtin_checker' && $val == 'ownchk') { + continue; + } + + $problem_conf_str .= "{$key} {$val}\n"; +} +?> + +getTitle(['with' => 'id']))) ?> + +
= $problem_conf_str ?>
+ 此处可以对 传统题 进行快速配置,在填写完成之后点击页面底部的「提交」按钮即可替换现有配置文件并进行数据同步。
+目前暂不支持对交互题、提交答案题、通信题进行配置,对于此类题目请手动编写配置文件。
+如需要配置子任务依赖,也可以基于此处生成的配置文件进行修改后再手动上传。
+关于数据配置的更多帮助,请查阅 帮助文档。
+' + res + '');
+ });
+}
+
+// problem_configure: point scores
+$.fn.problem_configure_point_scores = function(problem_conf) {
+ return $(this).each(function() {
+ var _this = this;
+ var n_tests = parseInt(problem_conf['n_tests']);
+
+ $(this).empty();
+
+ if (isNaN(n_tests) || n_tests <= 0) {
+ $(this).html('不可用。');
+
+ return;
+ }
+
+ for (var i = 1; i <= n_tests; i++) {
+ var input_point_score = $('');
+
+ if (problem_conf['point_score_' + i]) {
+ input_point_score.val(problem_conf['point_score_' + i]);
+ }
+
+ (function(i){
+ input_point_score.change(function() {
+ problem_conf['point_score_' + i] = $(this).val();
+ $('#problem-conf-preview').problem_conf_preview(problem_conf);
+ });
+ })(i);
+
+ $(this).append(
+ $('').append(
+ $('')
+ .append($('').append(''))
+ .append($('').append(input_point_score))
+ )
+ );
+ }
+
+ $('.uoj-problem-configure-point-score-input', this).change(function() {
+ var full_score = 100;
+ var rest_tests = parseInt(problem_conf['n_tests'] || '10');
+ var score_type = problem_conf['score_type'] || 'int';
+
+ $('.uoj-problem-configure-point-score-input', _this).each(function() {
+ var point_score = parseInt($(this).val());
+ if (!isNaN(point_score)) {
+ full_score -= point_score;
+ rest_tests--;
+ }
+ });
+
+ $('.uoj-problem-configure-point-score-input', _this).each(function() {
+ if ($(this).val() == '') {
+ var val = full_score / rest_tests;
+
+ if (score_type == 'int') {
+ val = Math.floor(val);
+ } else {
+ var decimal_places = parseInt(score_type.substring(5));
+
+ val = val.toFixed(decimal_places);
+ }
+
+ $(this).attr('placeholder', val);
+ }
+ });
+ });
+
+ $('.uoj-problem-configure-point-score-input', this).first().trigger('change');
+ });
+};
+
+// problem_configure: subtasks
+$.fn.problem_configure_subtasks = function(problem_conf) {
+ return $(this).each(function() {
+ var _this = this;
+ var n_subtasks = parseInt(problem_conf['n_subtasks'] || '0');
+
+ $(this).empty();
+
+ if (isNaN(n_subtasks)) {
+ $(this).html('不可用。');
+
+ return;
+ }
+
+ var input_n_subtasks = $('');
+ var div_subtasks = $('');
+
+ if (n_subtasks) {
+ input_n_subtasks.val(n_subtasks);
+ }
+
+ $(this).append(
+ $('').append(
+ $('').append(
+ $('').append('')
+ ).append(
+ $('').append(input_n_subtasks)
+ )
+ )
+ ).append(div_subtasks);
+
+ input_n_subtasks.change(function() {
+ div_subtasks.empty();
+
+ var n_subtasks = parseInt(input_n_subtasks.val() || '0');
+ var n_tests = parseInt(problem_conf['n_tests'] || '10');
+ problem_conf['n_subtasks'] = input_n_subtasks.val();
+
+ for (var i = 1; i <= n_subtasks; i++) {
+ var input_subtask_type = $('');
+ var input_subtask_end = $('');
+ var input_subtask_score = $('');
+ var input_subtask_used_time_type = $('');
+
+ input_subtask_type
+ .append($('').text('错一个就零分'))
+ .append($('').text('取所有测试点中的最小值'));
+ input_subtask_used_time_type
+ .append($('').text('全部相加'))
+ .append($('').text('取所有测试点中的最大值'));
+
+ (function(i) {
+ input_subtask_type.change(function() {
+ problem_conf['subtask_type_' + i] = $(this).val();
+ $('#problem-conf-preview').problem_conf_preview(problem_conf);
+ });
+
+ input_subtask_end.change(function() {
+ problem_conf['subtask_end_' + i] = $(this).val();
+ $('#problem-conf-preview').problem_conf_preview(problem_conf);
+ })
+
+ input_subtask_score.change(function() {
+ problem_conf['subtask_score_' + i] = $(this).val();
+ $('#problem-conf-preview').problem_conf_preview(problem_conf);
+ });
+
+ input_subtask_used_time_type.change(function() {
+ problem_conf['subtask_used_time_type_' + i] = $(this).val();
+ $('#problem-conf-preview').problem_conf_preview(problem_conf);
+ });
+ })(i);
+
+ if (problem_conf['subtask_type_' + i]) {
+ input_subtask_type.val(problem_conf['subtask_type_' + i]);
+ }
+
+ if (problem_conf['subtask_end_' + i]) {
+ input_subtask_end.val(problem_conf['subtask_end_' + i]);
+ }
+
+ if (problem_conf['subtask_score_' + i]) {
+ input_subtask_score.val(problem_conf['subtask_score_' + i]);
+ }
+
+ if (problem_conf['subtask_used_time_type_' + i]) {
+ input_subtask_used_time_type.val(problem_conf['subtask_used_time_type_' + i]);
+ }
+
+ div_subtasks.append(
+ $('').append(
+ $('').text('Subtask #' + i)
+ ).append(
+ $('').append(
+ $('').append(
+ $('').append('')
+ ).append(
+ $('').append(input_subtask_type)
+ )
+ ).append(
+ $('').append(
+ $('').append('')
+ ).append(
+ $('').append(input_subtask_end)
+ )
+ ).append(
+ $('').append(
+ $('').append('')
+ ).append(
+ $('').append(input_subtask_score)
+ )
+ ).append(
+ $('').append(
+ $('').append('')
+ ).append(
+ $('').append(input_subtask_used_time_type)
+ )
+ )
+ )
+ );
+ }
+
+ $('.uoj-problem-configure-subtask-score-input', _this).change(function() {
+ var full_score = 100;
+ var rest_subtasks = parseInt(problem_conf['n_subtasks'] || '10');
+ var score_type = problem_conf['score_type'] || 'int';
+
+ $('.uoj-problem-configure-subtask-score-input', _this).each(function() {
+ var subtask_score = parseInt($(this).val());
+
+ if (!isNaN(subtask_score)) {
+ full_score -= subtask_score;
+ rest_subtasks--;
+ }
+ });
+
+ $('.uoj-problem-configure-subtask-score-input', _this).each(function() {
+ if ($(this).val() == '') {
+ var val = full_score / rest_subtasks;
+
+ if (score_type == 'int') {
+ val = Math.floor(val);
+ } else {
+ var decimal_places = parseInt(score_type.substring(5));
+
+ val = val.toFixed(decimal_places);
+ }
+
+ $(this).attr('placeholder', val);
+ }
+ });
+ });
+
+ $('.uoj-problem-configure-subtask-score-input', _this).first().trigger('change');
+ $('#problem-conf-preview').problem_conf_preview(problem_conf);
+ });
+
+ input_n_subtasks.trigger('change');
+ });
+};
+
// custom test
function custom_test_onsubmit(response_text, div_result, url) {
if (response_text != '') {