datums.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. requirePHPLib('form');
  3. requirePHPLib('judger');
  4. if ($myUser == null || !isSuperUser($myUser))
  5. become403Page();
  6. $cancel_form = new UOJForm('retry');
  7. $cancel_form->addInput('id', 'text', '重试请求', '',
  8. function ($id) {
  9. if (!validateUInt($id)) return 'ID 不合法';
  10. $u = queryDatumBrief($id);
  11. if (!$u) return '请求不存在';
  12. if ($u['status'] == 'Generating') return '请求处理中';
  13. return '';
  14. }, null);
  15. $cancel_form->handle = function() {
  16. $id = $_POST['id'];
  17. DB::update("update datum_requests set status = 'Waiting' where id = $id");
  18. };
  19. $cancel_form->submit_button_config['class_str'] = 'btn btn-danger';
  20. $cancel_form->submit_button_config['align'] = 'offset';
  21. $cancel_form->submit_button_config['text'] = '重试';
  22. $cancel_form->runAtServer();
  23. $retry_form = new UOJForm('retry');
  24. $retry_form->addInput('id', 'text', '重试请求', '',
  25. function ($id) {
  26. if (!validateUInt($id)) return 'ID 不合法';
  27. $u = queryDatumBrief($id);
  28. if (!$u) return '请求不存在';
  29. if ($u['status'] == 'Generating') return '请求处理中';
  30. return '';
  31. }, null);
  32. $retry_form->handle = function() {
  33. $id = $_POST['id'];
  34. DB::update("update datum_requests set request_time = now() where id = $id");
  35. DB::update("update datum_requests set finish_time = NULL where id = $id");
  36. DB::update("update datum_requests set status = 'Waiting' where id = $id");
  37. };
  38. $retry_form->submit_button_config['class_str'] = 'btn btn-danger';
  39. $retry_form->submit_button_config['align'] = 'offset';
  40. $retry_form->submit_button_config['text'] = '重试';
  41. $retry_form->runAtServer();
  42. $new_datum_form = new UOJForm('datum');
  43. $new_datum_form->addInput('pid', 'text', '题目编号', '',
  44. function ($pid) {
  45. if (!validateUInt($pid)) return '题号不合法';
  46. if (!queryProblemBrief($pid)) return '题目不存在';
  47. return '';
  48. }, null);
  49. $new_datum_form->addInput('timelim', 'text', '时间限制', '',
  50. function ($pid) {
  51. if (!validateUInt($pid)) return '时间限制不合法';
  52. return '';
  53. }, null);
  54. $new_datum_form->addInput('memlim', 'text', '空间限制', '',
  55. function ($pid) {
  56. if (!validateUInt($pid)) return '空间限制不合法';
  57. return '';
  58. }, null);
  59. $new_datum_form->addSourceCodeInput('std', '标程', array('C++17'));
  60. $new_datum_form->handle = function() {
  61. $std = '';
  62. if ($_POST['std_upload_type'] == 'editor') $std = $_POST['std_editor'];
  63. else $std = $_POST['std_file'];
  64. $std = DB::escape($std);
  65. $pid = $_POST['pid'];
  66. $timelim = $_POST['timelim'];
  67. $memlim = $_POST['memlim'];
  68. DB::insert("insert into datum_requests (pid, request_time, timelimit, memlimit, status, std) values ($pid, now(), $timelim, $memlim, 'Waiting', '$std')");
  69. };
  70. $new_datum_form->runAtServer();
  71. ?>
  72. <?php echoUOJPageHeader('自动数据生成') ?>
  73. <?php
  74. echoDatumList();
  75. echo '<h4>重试由大模型不稳定导致失败的请求</h4>';
  76. $retry_form->printHTML();
  77. echo '<h4>数据生成完毕后请手动点击校验配置并同步数据</h4>';
  78. $new_datum_form->printHTML();
  79. ?>
  80. <?php echoUOJPageFooter() ?>