From 47911aaf3bd3078e273ced1e7c123f97090eb2c1 Mon Sep 17 00:00:00 2001 From: daizeyao <1192313493@qq.com> Date: Fri, 20 Sep 2024 21:41:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug&=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E6=98=B5=E7=A7=B0=E4=BF=AE=E6=94=B9&=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=95=99=E5=B8=88=E7=AB=AF=E6=AF=8F=E6=97=A5=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/OJ/daliy_detail.php | 234 +++++++++++++++++++++- web/OJ/template/hznu/daliy_detail.php | 71 ++++++- web/OJ/template/hznu/getstudyproblems.php | 15 +- web/OJ/template/hznu/modifypage.php | 14 +- web/OJ/template/hznu/study_detail.php | 26 +-- 5 files changed, 328 insertions(+), 32 deletions(-) diff --git a/web/OJ/daliy_detail.php b/web/OJ/daliy_detail.php index 1b58b0f47..2057cb9bf 100644 --- a/web/OJ/daliy_detail.php +++ b/web/OJ/daliy_detail.php @@ -14,6 +14,8 @@ ?> free(); +// 教师页面数据 + + + +$OJ_CACHE_SHARE = false; +$cache_time = 30; +require_once('./include/cache_start.php'); +require_once('./include/db_info.inc.php'); +require_once('./include/setlang.php'); +// require_once('updateRank.php'); // 有此语句后每次点击ranklist会自动更新排名 + +$view_title = $MSG_RANKLIST; +$filter_url = ""; // URL中的筛选语句 +$filter_sql = ""; // SQL中的筛选语句 + +$scope = ""; +if (isset($_GET['scope'])) { + $scope = $_GET['scope']; + $filter_url .= "&scope=" . $scope; +} +if ($scope != "" && $scope != 'd' && $scope != 'w' && $scope != 'm') + $scope = 'y'; + +$order_by = ""; +if (isset($_GET['order_by'])) { + $order_by = $_GET['order_by']; + $filter_url .= "&order_by=" . $order_by; +} +if ($order_by != "" && $order_by != 'ac') + $order_by = 's'; + +$page_size = 200; +$rank = 0; +$start = 0; +$page = 1; +if (isset($_GET['page'])) { + $page = intval($_GET['page']); +} + +$start = $rank = ($page - 1) * $page_size; + +if (isset($_GET['class'])) { + $cls = $mysqli->real_escape_string($_GET['class']); + if ($_GET['class'] != "all") + $filter_sql = " WHERE class='" . $cls . "' "; + $filter_url .= "&class=" . $cls; +} + +$filter_url = htmlentities($filter_url); + +if (isset($OJ_LANG)) { + require_once("./lang/$OJ_LANG.php"); +} + +if ($rank < 0) $rank = 0; + +if ($order_by == 'ac') $sql = "SELECT * FROM users " . $filter_sql . "ORDER BY solved DESC, submit, reg_time LIMIT " . strval($rank) . ",$page_size"; +else $sql = "SELECT * FROM users " . $filter_sql . " ORDER BY strength DESC, solved, submit, reg_time LIMIT " . strval($rank) . ",$page_size"; + +if ($scope) { + $s = ""; + switch ($scope) { + case 'd': + $s = date('Y') . '-' . date('m') . '-' . date('d'); + break; + case 'w': + $monday = mktime(0, 0, 0, date("m"), date("d") - (date("w") + 7) % 8 + 1, date("Y")); + //$monday->subDays(date('w')); + $s = strftime("%Y-%m-%d", $monday); + break; + case 'm': + $s = date('Y') . '-' . date('m') . '-01';; + break; + default: + $s = date('Y') . '-01-01'; + } + $sql = "SELECT * FROM `users` + right join + (select count(distinct problem_id) solved ,user_id from solution where in_date>str_to_date('$s','%Y-%m-%d') and result=4 group by user_id order by solved desc limit " . strval($rank) . ",$page_size) s on users.user_id=s.user_id + left join + (select count( problem_id) submit ,user_id from solution where in_date>str_to_date('$s','%Y-%m-%d') group by user_id order by submit desc limit " . strval($rank) . "," . ($page_size * 2) . ") t on users.user_id=t.user_id + " . $class_filter . " ORDER BY solved DESC,t.submit,reg_time LIMIT 0,200"; +} + + +// $result = $mysqli->query ( $sql ); //$mysqli->error; +if ($OJ_MEMCACHE) { + require("./include/memcache.php"); + $result = $mysqli->query_cache($sql); //or die("Error! ".$mysqli->error); + if ($result) $rows_cnt = count($result); + else $rows_cnt = 0; +} else { + $result = $mysqli->query($sql) or die("Error! " . $mysqli->error); + if ($result) $rows_cnt = $result->num_rows; + else $rows_cnt = 0; +} + +function filter_dates_by_range($user_id, $lastday, $today, $mysqli) +{ + // 获取热力图相关数据 + $sql = "SELECT MIN(judgetime) as actime + FROM solution + WHERE user_id = '$user_id' AND result = 4 + GROUP BY problem_id;"; + $daily_result = $mysqli->query($sql); + + $daliy_detail_data = array(); + if ($daily_result->num_rows > 0) { + // 输出每行数据 + while ($num_rows = $daily_result->fetch_assoc()) { + $daliy_detail_data[] = $num_rows["actime"]; + } + } + $data = array(); + $start_time = strtotime($lastday); + $end_time = strtotime($today); + $day_time = 86400; + for ($time = $start_time; $time <= $end_time; $time += $day_time) { + $time_str = date('Y-m-d', $time); + $count = count(array_filter($daliy_detail_data, function ($record) use ($time_str) { + return strpos($record, $time_str) === 0; + })); + $data[] = array($time_str, $count); + } + return $data; +} + +function getColor($value) +{ + if ($value >= 5) { + return '#006400'; + } elseif ($value == 4) { + return '#60b34d'; + } elseif ($value == 3) { + return '#85c96e'; + } elseif ($value == 2) { + return '#aadf8f'; + } elseif ($value == 1) { + return '#d0f0c0'; + } else { + return '#eeeeee'; + } +} + +$view_rank = array(); +$i = 0; +for ($i = 0; $i < $rows_cnt; $i++) { + if ($OJ_MEMCACHE) + $row = $result[$i]; + else + $row = $result->fetch_array(); + + $user_id = $row['user_id']; + $filtered_data = filter_dates_by_range($user_id, $lastday, $today, $mysqli); + + $rank++; + $total = $row['solved'] + $row['ZJU'] + $row['HDU'] + $row['PKU'] + $row['UVA'] + $row['CF']; + $view_rank[$i][0] = "
Rank | +User | +Name | +Solved | +Daily | +"; + echo $table_cell; + echo " | "; + } + echo ""; + } + ?> + +
---|