From 4f71b5ff582b1b5add92d555844ac1a889c6defc Mon Sep 17 00:00:00 2001 From: daizeyao <1192313493@qq.com> Date: Thu, 21 Mar 2024 14:06:56 +0800 Subject: [PATCH] study_details --- web/OJ/template/hznu/getstudyproblems.php | 10 +- web/OJ/template/hznu/study_detail.php | 391 ++++------ web/OJ/template/hznu/study_detail_data.php | 859 +++++++++++++++++++++ web/OJ/template/hznu/userinfo.php | 14 +- 4 files changed, 1027 insertions(+), 247 deletions(-) create mode 100644 web/OJ/template/hznu/study_detail_data.php diff --git a/web/OJ/template/hznu/getstudyproblems.php b/web/OJ/template/hznu/getstudyproblems.php index 34981dc7..0f21bdf0 100644 --- a/web/OJ/template/hznu/getstudyproblems.php +++ b/web/OJ/template/hznu/getstudyproblems.php @@ -4,7 +4,7 @@ $user = $_POST['user']; $tag = $_POST['tag']; -$sql = "SELECT p.problem_id, s.result +$sql = "SELECT p.problem_id, s.result, p.score FROM problem_tag pt JOIN problem p ON pt.problem_id = p.problem_id LEFT JOIN solution s ON p.problem_id = s.problem_id AND s.user_id = ? @@ -25,10 +25,14 @@ ); while ($row = $result->fetch_assoc()) { + $problem = array( + 'id' => $row['problem_id'], + 'score' => $row['score'] + ); if ($row['result'] == 4) { - $data['solved'][] = $row['problem_id']; + $data['solved'][] = $problem; } else { - $data['unsolved'][] = $row['problem_id']; + $data['unsolved'][] = $problem; } } diff --git a/web/OJ/template/hznu/study_detail.php b/web/OJ/template/hznu/study_detail.php index 957271f2..ad67267a 100644 --- a/web/OJ/template/hznu/study_detail.php +++ b/web/OJ/template/hznu/study_detail.php @@ -1,21 +1,16 @@ free(); + +///////////////////////////////////////////////////////////////////////////////cs +// if($user == "admin") +// foreach ($studytags as $tag) +// $studydata[$tag] = 1; + +///////////////////////////////////////////////////////////////////////////////cs + //此处修改层次颜色 $color = ['#cccccc', '#d0f0c0', '#aadf8f', '#85c96e']; @@ -40,6 +43,32 @@ $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) { @@ -51,41 +80,14 @@ } } -$pointposition = [ - 'HelloWorld!' => ['x' => 0, 'y' => 400], - '基础数据类型' => ['x' => 150, 'y' => 400], - '输入输出' => ['x' => 300, 'y' => 400], - '控制结构' => ['x' => 450, 'y' => 400], - '数组' => ['x' => 800, 'y' => 130], - '函数' => ['x' => 800, 'y' => 310], - '指针' => ['x' => 800, 'y' => 490], - '结构体' => ['x' => 800, 'y' => 670], - '综合' => ['x' => 1250, 'y' => 400], - - '顺序结构' => ['x' => 535, 'y' => 290], - '选择结构' => ['x' => 600, 'y' => 400], - '循环结构' => ['x' => 535, 'y' => 510], - '一维数组' => ['x' => 700, 'y' => 210], - '二维数组' => ['x' => 800, 'y' => 210], - '字符串' => ['x' => 900, 'y' => 210], - '函数基础' => ['x' => 700, 'y' => 390], - '自定义函数' => ['x' => 800, 'y' => 390], - '内置函数' => ['x' => 900, 'y' => 390], - '指针基础' => ['x' => 700, 'y' => 570], - '指针数组' => ['x' => 800, 'y' => 570], - '函数指针' => ['x' => 900, 'y' => 570], - '结构体基础' => ['x' => 750, 'y' => 750], - '结构体数组' => ['x' => 850, 'y' => 750] -]; - ?> -
-
-
+
+
+
@@ -111,8 +113,6 @@
- - @@ -121,162 +121,25 @@ var myChart = echarts.init(chartDom); var option; - var studydata = ; var neednum = ; - var links = [{ - source: 'HelloWorld!', - target: '基础数据类型' - }, - { - source: '基础数据类型', - target: '输入输出' - }, - { - source: '输入输出', - target: '控制结构' - }, - { - source: '控制结构', - target: '数组', - lineStyle: { - curveness: 0.5 - } - }, - { - source: '控制结构', - target: '函数', - lineStyle: { - curveness: 0.2 - } - }, - { - source: '控制结构', - target: '指针', - lineStyle: { - curveness: -0.2 - } - }, - { - source: '控制结构', - target: '结构体', - lineStyle: { - curveness: -0.5 - } - }, - { - source: '控制结构', - target: '顺序结构', - lineStyle: { - curveness: 0.3 - } - }, - { - source: '控制结构', - target: '选择结构', - lineStyle: { - curveness: 0 - } - }, - { - source: '控制结构', - target: '循环结构', - lineStyle: { - curveness: -0.3 - } - }, - { - source: '数组', - target: '一维数组', - lineStyle: { - curveness: -0.3 - } - }, - { - source: '数组', - target: '二维数组', - lineStyle: { - curveness: 0 - } - }, - { - source: '数组', - target: '字符串', - lineStyle: { - curveness: 0.3 - } - }, - { - source: '函数', - target: '函数基础', - lineStyle: { - curveness: -0.3 - } - }, - { - source: '函数', - target: '自定义函数', - lineStyle: { - curveness: 0 - } - }, - { - source: '函数', - target: '内置函数', - lineStyle: { - curveness: 0.3 - } - }, - { - source: '指针', - target: '指针基础', - lineStyle: { - curveness: -0.3 - } - }, - { - source: '指针', - target: '指针数组', - lineStyle: { - curveness: 0 - } - }, - { - source: '指针', - target: '函数指针', - lineStyle: { - curveness: 0.3 - } - }, - { - source: '结构体', - target: '结构体基础', - lineStyle: { - curveness: -0.2 - } - }, - { - source: '结构体', - target: '结构体数组', - lineStyle: { - curveness: 0.2 - } - } - ]; - - for (let i = 0; i < links.length; i++) { - if (i < 7) { - links[i].symbol = ['circle', 'arrow']; - } - links[i].tooltip = { - show: false - }; - } - option = { title: { - text: '学习里程碑' + text: '学习里程碑', + left: "1%", + top: "5%", + }, + legend: { + data: ["Newbie", "Learner", "Expert", "Master"], + selectedMode: false, //控制是否可以点击 + left: "1%", + top: "15%", + width: "1%", + textStyle: { + color: "black", + fontSize: 16 + } }, tooltip: { formatter: function(params) { @@ -291,82 +154,136 @@ type: 'graph', layout: 'none', symbol: "roundRect", - symbolSize: 90, + symbolSize: 70, roam: false, label: { show: true, - fontSize: 15 + fontSize: 12 }, - edgeSymbolSize: [0, 10], + edgeSymbolSize: [0, 14], edgeLabel: { fontSize: 30 }, + categories: [{ + name: 'Newbie', + itemStyle: { + color: '#cccccc', + } + }, { + name: 'Learner', + itemStyle: { + color: '#d0f0c0' + } + }, { + name: 'Expert', + itemStyle: { + color: '#aadf8f' + } + }, { + name: 'Master', + itemStyle: { + color: '#85c96e' + } + }], data: [ $position) { - if ($count < 9) { + if ($count < 8) { //前八个方形 echo "{name: '" . $tag . "',x: " . $position['x'] . ",y: " . $position['y'] . - ",itemStyle: {color:'" . $nowcolor[$tag] . "'}},"; + ",itemStyle: {color:'" . $nowcolor[$tag] . "' }},"; } else { echo "{name: '" . $tag . "',x: " . $position['x'] . ",y: " . $position['y'] . - ", symbol:'circle', symbolSize: 78, itemStyle: {color:'" . $nowcolor[$tag] . "'}},"; + ", symbol:'circle', symbolSize: 70, itemStyle: {color:'" . $nowcolor[$tag] . "'}},"; } $count++; } + foreach ($breakpoint as $tag => $position) { + echo "{name: '" . $tag . "',x: " . $position['x'] . ",y: " . $position['y'] . + ", symbol:'circle', symbolSize: 0, tooltip: { show: false }, label: {show: false}},"; + } ?> ], links: links, lineStyle: { opacity: 0.9, - width: 2, + width: 3, curveness: 0, + color: '#996633' } - }] + }, ] }; option && myChart.setOption(option); myChart.on('click', function(params) { - // 获取被点击的标签 - var tag = params.data.name; - - // 发送 AJAX 请求 - $.ajax({ - url: 'getstudyproblems.php', - type: 'POST', - data: { - user: '', - tag: tag - }, - success: function(response) { - var data = JSON.parse(response); - - // 生成已解决问题的链接 - var solvedLinks = data.solved.map(function(problemId, index) { - return '' + problemId + ''; - }); - if (solvedLinks.length === 0) { - solvedLinks = ['No Problem Now!']; - } - $('#modal-solved-bd').html(solvedLinks.join(' ')); - - // 生成未解决问题的链接 - var unsolvedLinks = data.unsolved.map(function(problemId, index) { - return '' + problemId + ''; - }); - if (unsolvedLinks.length === 0) { - unsolvedLinks = ['No Problem Now!']; - } - $('#modal-recommend-bd').html(unsolvedLinks.join(' ')); - // 更新弹窗标题 - $('.am-modal-hd').eq(0).text('Solved (' + data.solved.length + ')'); - $('.am-modal-hd').eq(1).text('Recommended (' + data.unsolved.length + ')'); + if (params.dataType === 'node' && params.data.name[0] != 'b') { + // 获取被点击的标签 + var tag = params.data.name; + + // 发送 AJAX 请求 + $.ajax({ + url: 'getstudyproblems.php', + type: 'POST', + data: { + user: '', + tag: tag + }, + success: function(response) { + var data = JSON.parse(response); + + // 生成已解决问题的链接 + var solvedLinks = data.solved.map(function(problem, index) { + var score = problem.score; + var colorClass; + if (score <= 20) colorClass = 'am-badge-success'; + else if (score <= 40) colorClass = 'am-badge-secondary'; + else if (score <= 60) colorClass = 'am-badge-primary'; + else if (score <= 80) colorClass = 'am-badge-warning'; + else colorClass = 'am-badge-danger'; + return '' + + '' + problem.id + ''; + }); + if (solvedLinks.length === 0) { + solvedLinks = ['No Problem Now!']; + } + $('#modal-solved-bd').html(solvedLinks.join(' ')); + + // 生成未解决问题的链接 + var unsolvedLinks = data.unsolved.map(function(problem, index) { + var score = problem.score; + var colorClass; + if (score <= 20) colorClass = 'am-badge-success'; + else if (score <= 40) colorClass = 'am-badge-secondary'; + else if (score <= 60) colorClass = 'am-badge-primary'; + else if (score <= 80) colorClass = 'am-badge-warning'; + else colorClass = 'am-badge-danger'; + + /////////////////////////////////cs + // if (index <= 2) colorClass = 'am-badge-success'; + // else if (index <= 4) colorClass = 'am-badge-secondary'; + // else if (index <= 6) colorClass = 'am-badge-primary'; + // else if (index <= 8) colorClass = 'am-badge-warning'; + // else colorClass = 'am-badge-danger'; + //////////////////////////////////cs + + return '' + + '' + problem.id + ''; + }); + if (unsolvedLinks.length === 0) { + unsolvedLinks = ['No Problem Now!']; + } + $('#modal-recommend-bd').html(unsolvedLinks.join(' ')); - // 显示弹窗 - $('#modal-study').modal(); - } - }); + // 更新弹窗标题 + $('.am-modal-hd').eq(0).text('Solved (' + data.solved.length + ')'); + $('.am-modal-hd').eq(1).text('Recommended (' + data.unsolved.length + ')'); + + // 显示弹窗 + $('#modal-study').modal(); + } + }); + } }); diff --git a/web/OJ/template/hznu/study_detail_data.php b/web/OJ/template/hznu/study_detail_data.php new file mode 100644 index 00000000..fbea42ca --- /dev/null +++ b/web/OJ/template/hznu/study_detail_data.php @@ -0,0 +1,859 @@ + ['x' => 0, 'y' => 400], + '基础数据类型' => ['x' => 500, 'y' => 400], + '运算符' => ['x' => 1000, 'y' => 400], + '控制结构' => ['x' => 1700, 'y' => 400], + '函数' => ['x' => 1350, 'y' => 200], + '指针' => ['x' => 2100, 'y' => 200], + '结构体' => ['x' => 2850, 'y' => 200], + '数组' => ['x' => 2800, 'y' => 400], + + '基础输入输出' => ['x' => -100, 'y' => 525], + '转义字符' => ['x' => 100, 'y' => 525], + + '整型' => ['x' => 350, 'y' => 200], + '浮点型' => ['x' => 500, 'y' => 200], + '字符型' => ['x' => 650, 'y' => 200], + + '加减乘除运算' => ['x' => 850, 'y' => 525], + '逻辑运算' => ['x' => 1000, 'y' => 525], + '二进制运算' => ['x' => 1150, 'y' => 525], + + '指针基础' => ['x' => 1925, 'y' => 50], + '指针数组' => ['x' => 2100, 'y' => 50], + '函数指针' => ['x' => 2275, 'y' => 50], + + '结构体基础' => ['x' => 2725, 'y' => 50], + '结构体数组' => ['x' => 2975, 'y' => 50], + + '一维数组' => ['x' => 2600, 'y' => 525], + '字符串' => ['x' => 2800, 'y' => 525], + '二维数组' => ['x' => 3000, 'y' => 525], + '找最值' => ['x' => 2450, 'y' => 650], + '排序' => ['x' => 2600, 'y' => 650], + '二分' => ['x' => 2750, 'y' => 650], + + '函数基础' => ['x' => 1100, 'y' => 50], + '自定义函数' => ['x' => 1275, 'y' => 50], + '内置函数' => ['x' => 1425, 'y' => 50], + '递归函数' => ['x' => 1600, 'y' => 50], + + '顺序结构' => ['x' => 1400, 'y' => 525], + '选择结构' => ['x' => 1650, 'y' => 525], + '循环结构' => ['x' => 2000, 'y' => 525], + + '科学计算' => ['x' => 1400, 'y' => 650], + '单分支' => ['x' => 1585, 'y' => 650], + '多分支' => ['x' => 1715, 'y' => 650], + '多重循环' => ['x' => 1875, 'y' => 650], + '迭代' => ['x' => 2000, 'y' => 650], + '枚举' => ['x' => 2125, 'y' => 650], +]; + +$breakpoint = [ + 'b_HelloWorld!' => ['x' => 0, 'y' => 455], + 'b_基础输入输出' => ['x' => -100, 'y' => 455], + 'b_转义字符' => ['x' => 100, 'y' => 455], + + 'b_基础数据类型' => ['x' => 500, 'y' => 300], + 'b_整型' => ['x' => 350, 'y' => 300], + 'b_字符型' => ['x' => 650, 'y' => 300], + + 'b_运算符' => ['x' => 1000, 'y' => 450], + 'b_加减乘除运算' => ['x' => 850, 'y' => 450], + 'b_二进制运算' => ['x' => 1150, 'y' => 450], + + 'b_函数' => ['x' => 1350, 'y' => 135], + 'b_函数基础' => ['x' => 1100, 'y' => 135], + 'b_自定义函数' => ['x' => 1275, 'y' => 135], + 'b_内置函数' => ['x' => 1425, 'y' => 135], + 'b_递归函数' => ['x' => 1600, 'y' => 135], + + 'b_控制结构' => ['x' => 1700, 'y' => 450], + 'b_顺序结构' => ['x' => 1400, 'y' => 450], + 'b_选择结构' => ['x' => 1650, 'y' => 450], + 'b_循环结构' => ['x' => 2000, 'y' => 450], + + 'b_选择结构_bottom' => ['x' => 1650, 'y' => 575], + 'b_单分支' => ['x' => 1585, 'y' => 575], + 'b_多分支' => ['x' => 1715, 'y' => 575], + + 'b_循环结构_bottom' => ['x' => 2000, 'y' => 575], + 'b_多重循环' => ['x' => 1875, 'y' => 575], + 'b_枚举' => ['x' => 2125, 'y' => 575], + + 'b_指针' => ['x' => 2100, 'y' => 135], + 'b_指针基础' => ['x' => 1925, 'y' => 135], + 'b_函数指针' => ['x' => 2275, 'y' => 135], + + 'b_结构体' => ['x' => 2850, 'y' => 135], + 'b_结构体基础' => ['x' => 2725, 'y' => 135], + 'b_结构体数组' => ['x' => 2975, 'y' => 135], + + 'b_数组' => ['x' => 2800, 'y' => 450], + 'b_一维数组' => ['x' => 2600, 'y' => 450], + 'b_二维数组' => ['x' => 3000, 'y' => 450], + + 'b_一维数组_bottom' => ['x' => 2600, 'y' => 575], + 'b_找最值' => ['x' => 2450, 'y' => 575], + 'b_二分' => ['x' => 2750, 'y' => 575], + + 'b_基础数据类型_right' => ['x' => 800, 'y' => 400], + 'b_基础数据类型_right_top' => ['x' => 800, 'y' => 300], + 'b_函数_bottom' => ['x' => 1350, 'y' => 300], + 'b_指针_bottom' => ['x' => 2100, 'y' => 300], + 'b_数组_top' => ['x' => 2800, 'y' => 300], + 'b_结构体_bottom' => ['x' => 2850, 'y' => 300], +]; +?> + + + \ No newline at end of file diff --git a/web/OJ/template/hznu/userinfo.php b/web/OJ/template/hznu/userinfo.php index 96c42076..7544a0c9 100644 --- a/web/OJ/template/hznu/userinfo.php +++ b/web/OJ/template/hznu/userinfo.php @@ -26,10 +26,10 @@ border-radius: 0; text-transform: uppercase; font-weight: bold; - font-size: 20px; padding: 15px 50px; position: relative; z-index: 1; + color: black; } .loading-btn:hover { @@ -177,14 +177,14 @@
-
- -
+ + +
-
- -
+ + +