Skip to content

Commit

Permalink
fixed studydetail and ico
Browse files Browse the repository at this point in the history
  • Loading branch information
daizeyao committed Mar 25, 2024
1 parent bf56d03 commit e0b10a7
Show file tree
Hide file tree
Showing 7 changed files with 609 additions and 144 deletions.
49 changes: 49 additions & 0 deletions web/OJ/daliy_detail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

<?php
require_once('./include/db_info.inc.php');


$current_year = date("Y");

$sql = "SELECT * FROM dailydetails";
$res = $mysqli->query($sql);
$row = $res->fetch_assoc();

$lastday = date("Y-m-d", strtotime($row['start_time']));
$today = date("Y-m-d", strtotime($row['end_time']));
?>

<?php
if ($_GET['user']) $user = $_GET['user'];
else $user = $_POST['daliy_detail'];
if (!is_valid_user_name($user)) {
echo "No such User!";
exit(0);
}
$user_mysql = $mysqli->real_escape_string($user);

// 获取热力图相关数据
$sql = "SELECT MIN(judgetime) as actime
FROM solution
WHERE user_id = '$user_mysql' AND result = 4
GROUP BY problem_id;";
$result = $mysqli->query($sql);

$daliy_detail_data = array();
if ($result->num_rows > 0) {
// 输出每行数据
while ($row = $result->fetch_assoc()) {
$daliy_detail_data[] = $row["actime"];
}
}

$daliy_detail_data_json = json_encode($daliy_detail_data);
$result->free();



/////////////////////////Template
require("template/".$OJ_TEMPLATE."/daliy_detail.php");
/////////////////////////Common foot

?>
88 changes: 88 additions & 0 deletions web/OJ/study_detail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php $title = "Study Detail"; ?>
<?php
require_once('./include/db_info.inc.php');

require_once("study_detail_data.php");
?>

<?php
$user = $_GET['user'];
if (!is_valid_user_name($user)) {
echo "No such User!";
exit(0);
}

$studydata = array();
$studydata = array_fill_keys($studytags, 0);
//studydata['xx']=0;

$sql = "SELECT pt.tag, COUNT(DISTINCT s.problem_id) as count
FROM solution s
JOIN problem_tag pt ON s.problem_id = pt.problem_id
WHERE s.user_id = '$user' AND s.result = 4 AND pt.tag IN ('" . implode("', '", $studytags) . "')
GROUP BY pt.tag;";
$result = $mysqli->query($sql);

while ($row = $result->fetch_assoc()) {
$studydata[$row['tag']] = $row['count'];
}

$result->free();

///////////////////////////////////////////////////////////////////////////////cs
// if($user == "admin")
// foreach ($studytags as $tag)
// $studydata[$tag] = 1;

///////////////////////////////////////////////////////////////////////////////cs

//此处修改层次颜色
$pointcolor = ['#e5e5e5', '#d0f0c0', '#aadf8f', '#85c96e'];

$neednum = array();
$neednum = array_fill_keys($studytags, [0, 1, 2, 4]);
//neednum['xx'] = [0, 1, 2, 4];


foreach ($studytags3 as $tag) {
$studydata[$tagfa[$tag]] = 0;
$neednum[$tagfa[$tag]] = [0, 0, 0, 0];
}
foreach ($studytags2 as $tag) {
$studydata[$tagfa[$tag]] = 0;
$neednum[$tagfa[$tag]] = [0, 0, 0, 0];
}

foreach ($studytags3 as $tag) {
$studydata[$tagfa[$tag]] += $studydata[$tag];
$counts = $neednum[$tag];
for ($i = 0; $i < count($counts); $i++) {
$neednum[$tagfa[$tag]][$i] += $counts[$i];
}
}
foreach ($studytags2 as $tag) {
$studydata[$tagfa[$tag]] += $studydata[$tag];
$counts = $neednum[$tag];
for ($i = 0; $i < count($counts); $i++) {
$neednum[$tagfa[$tag]][$i] += $counts[$i];
}
}


$nowcolor = array();

foreach ($studytags as $tag) {
for ($i = 3; $i >= 0; $i--) {
if ($studydata[$tag] >= $neednum[$tag][$i]) {
$nowcolor[$tag] = $pointcolor[$i];
break;
}
}
}


/////////////////////////Template
require("template/" . $OJ_TEMPLATE . "/study_detail.php");
/////////////////////////Common foot

?>
Loading

0 comments on commit e0b10a7

Please sign in to comment.