diff --git a/db/app_uoj233.sql b/db/app_uoj233.sql index aa59101..3ae2d3a 100644 --- a/db/app_uoj233.sql +++ b/db/app_uoj233.sql @@ -366,7 +366,7 @@ UNLOCK TABLES; CREATE TABLE `countdowns` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` text NOT NULL, - `endtime` datetime NOT NULL, + `end_time` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; @@ -448,6 +448,21 @@ CREATE TABLE `groups` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `groups_assignments` +-- + +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `groups_assignments` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `list_id` int(11) NOT NULL, + `group_id` int(11) NOT NULL, + `end_time` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `groups_users` -- @@ -461,22 +476,6 @@ CREATE TABLE `groups_users` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `assignments` --- - -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `assignments` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `list_id` int(11) NOT NULL, - `group_id` int(11) NOT NULL, - `create_time` datetime NOT NULL, - `deadline` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `hacks` -- diff --git a/web/app/controllers/group.php b/web/app/controllers/group.php index b8e5a8a..2988ffb 100644 --- a/web/app/controllers/group.php +++ b/web/app/controllers/group.php @@ -1,4 +1,5 @@ -
+
-
- - + +

[隐藏] @@ -37,57 +37,48 @@ (ID: #)

- -

-

(小组 ID: )

- - - - - - - -
- + - -
+ +
+
+

+ +

+ +
+ purify(HTML::parsedown()->line($group['announcement'])) ?> +
+ +
+ +
+ +
+
+ +

- -
-
-
-
-
-

- -
-
-
-
-
    - class="mb-0" - - > - addtime(now(), '-168:00:00')", + 'order by end_time desc, list_id desc', + << + ID + 标题 + 状态 + 结束时间 + +EOD, + function($row) use ($group, $now) { + $end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']); - echo '
  • '; - echo '', $ass['title'], ' (题单 #', $ass['list_id'], ')'; - - if ($ddl < $now) { - echo ' overdue'; - } elseif ($ddl->getTimestamp() - $now->getTimestamp() < 86400) { // 1d - echo ' soon'; - } elseif ($now->getTimestamp() - $create_time->getTimestamp() < 86400) { // 1d - echo ' new'; - } - - $ddl_str = $ddl->format('Y-m-d H:i'); - echo ' (截止时间: ', $ddl_str, ',查看完成情况)'; - echo '
  • '; - } - - if (count($assignments) == 0) { - echo '

    暂无作业

    '; - } + echo ''; + echo '', $row['list_id'], ''; + echo '', '', HTML::escape($row['title']), '', ''; + if ($end_time < $now) { + echo '已结束'; + } else { + echo '进行中'; + } + echo '', $end_time->format('Y-m-d H:i:s'), ''; + echo ''; + }, + [ + 'echo_full' => true, + 'div_classes' => ['table-responsive'], + 'table_classes' => ['table', 'align-middle', 'mb-0'], + ] + ); ?> -
-

- -
-
-
-
- true, + 50, 'group_id' => $group_id, 'by_accepted' => true, - 'table_classes' => isset($REQUIRE_LIB['bootstrap5']) - ? array('table', 'text-center', 'mb-0') - : array('table', 'table-bordered', 'table-hover', 'table-striped', 'table-text-center') - )) ?> + 'table_classes' => ['table', 'text-center', 'mb-0'], + ]) ?>
- -

- diff --git a/web/app/controllers/group_assignment.php b/web/app/controllers/group_assignment.php index 964489a..ee72dc1 100644 --- a/web/app/controllers/group_assignment.php +++ b/web/app/controllers/group_assignment.php @@ -40,85 +40,140 @@ 作业:

    +
  • 对应题单:#
  • 所属小组:
  • -
  • 开始时间:
  • -
  • 结束时间:
  • +
  • 结束时间:
format('Y-m-d H:i:s'); + + foreach ($problems as $problem) { + $problem_ids[] = $problem['problem_id']; } - $header_row = ''; - $header_row .= ''; - $header_row .= ''.UOJLocale::get('username').''; - $header_row .= ''.UOJLocale::get('contests::total score').''; - foreach ($problem_ids as $problem_id) { - $header_row .= '' . '#'.$problem_id.'' . ''; + sort($problem_ids); + + foreach ($users as $user) { + $usernames[] = $user['username']; } - $header_row .= ''; + + // standings: rank => [user => [username, realname], scores[], rank] + $standings = []; - $print_row = function($row) use ($problem_ids) { - $username = $row['username']; + foreach ($usernames as $username) { + $user = queryUser($username); + $row = ['total_score' => 0]; - $scores = []; - $sum = 0; - $total_score = count($problem_ids) * 100; - $query = DB::query("SELECT MAX(id), problem_id, MAX(score) FROM submissions WHERE (problem_id, score) IN (SELECT problem_id, MAX(score) FROM submissions WHERE submitter = '{$username}' AND problem_id IN (".implode(',', $problem_ids).") GROUP BY problem_id) AND submitter = '{$username}' GROUP BY problem_id"); - - while ($row = DB::fetch($query)) { - $scores[$row['problem_id']] = [ - 'submission_id' => $row['MAX(id)'], - 'score' => $row['MAX(score)'], - ]; - - $sum += $row['MAX(score)']; - } - - if ($sum == $total_score) { - echo ''; - } else { - echo ''; - } - echo '' . getUserLink($username) . ''; - echo ''; - echo '', $sum, ''; - echo ''; + $row['user'] = [ + 'username' => $user['username'], + 'realname' => $user['realname'], + ]; foreach ($problem_ids as $problem_id) { - if (!isset($scores[$problem_id])) { - echo ''; + $cond = "submitter = '{$user['username']}' AND problem_id = $problem_id AND submit_time <= '$submission_end_time'"; + $submission = DB::selectFirst("SELECT id, score FROM submissions INNER JOIN (SELECT MAX(score) AS score FROM submissions WHERE $cond) AS max USING (score) WHERE $cond ORDER BY submit_time DESC"); + + if ($submission) { + $row['scores'][] = [ + 'submission_id' => $submission['id'], + 'score' => intval($submission['score']), + ]; + $row['total_score'] += $submission['score']; } else { - if ($scores[$problem_id]['score'] == 100) { - echo ''; - } else { - echo ''; - } - echo ''.$scores[$problem_id]['score'].''; + $row['scores'][] = null; } - echo ''; } - echo ''; - }; - $from = "user_info a inner join groups_users b on (b.group_id = {$group['id']} and a.username = b.username)"; - $col_names = array('a.username as username'); - $cond = "1"; - $tail = "order by a.username asc"; - $config = [ - 'page_len' => 50, - 'div_classes' => ['card', 'my-3', 'table-responsive', 'text-center'], - 'table_classes' => ['table', 'uoj-table', 'mb-0'], - ]; + $standings[] = $row; + } + + usort($standings, function($lhs, $rhs) { + if ($lhs['total_score'] != $rhs['total_score']) { + return $rhs['total_score'] - $lhs['total_score']; + } - echoLongTable($col_names, $from, $cond, $tail, $header_row, $print_row, $config); + return strcmp($lhs['user']['username'], $rhs['user']['username']); + }); ?> - +
+ + +
+