学生端选课进课闭环
This commit is contained in:
@@ -31,6 +31,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- 可以继续添加课程卡片 -->
|
||||
{% for course in user_selected_course %}
|
||||
<div class="course-card"onclick="openCourseProgress('{{course._id}}')">
|
||||
<img src="{{course.image_url}}" alt="课程封面" class="course-image">
|
||||
<div class="course-info">
|
||||
<h3 class="course-name">{{course.name}}</h3>
|
||||
<p class="course-description">{{course.description}}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -52,13 +59,14 @@
|
||||
</div>
|
||||
<script src="/static/js/dashboard.js"></script>
|
||||
<script>
|
||||
window.appData = {
|
||||
user_data: JSON.parse(`{{user_data}}`.replace(/"/g, "\"")),
|
||||
user_course_data: JSON.parse(`{{user_course_data}}`.replace(/"/g, "\""))
|
||||
}
|
||||
console.log(window.appData.user_data)
|
||||
console.log(window.appData.user_course_data)
|
||||
show_user_data(window.appData.user_data, window.appData.user_course_data)
|
||||
|
||||
console.log(`{{user_data}}`.replaceAll("'", "\"").replaceAll("True", "true").replaceAll("False", "false"))
|
||||
console.log(`{{user_course_data}}`.replaceAll(""", "\"").replaceAll("True", "true").replaceAll("False", "false"))
|
||||
let user_data = JSON.parse(`{{user_data}}`.replaceAll("'", "\"").replaceAll("True", "true").replaceAll("False", "false"));
|
||||
let user_course_data = JSON.parse(`{{user_course_data}}`.replaceAll(""", "\"").replaceAll("True", "true").replaceAll("False", "false"))
|
||||
console.log(user_data)
|
||||
console.log(user_course_data)
|
||||
show_user_data(user_data, user_course_data)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="maxcontainer" id="maxcontainer">
|
||||
<div class="maxcontainer" id="maxcontainer" style="height: 100%;">
|
||||
<!-- 左侧内容 -->
|
||||
<div class="sidebar" id="leftSidebar" style="width: 100%;height: 100%;">
|
||||
<div id="markdown-content"style="width: 100%;height: 95%;">
|
||||
<div id="markdown-content"style="width: 100%;height: 93%;">
|
||||
<!-- 动态加载的 HTML 会显示在这里 -->
|
||||
</div>
|
||||
<div id="markdown-content-process"style="width: 100%;height: 5%;">
|
||||
@@ -30,14 +30,14 @@
|
||||
<!-- 这里将显示鼠标悬停的详情 -->
|
||||
</div>
|
||||
</div>
|
||||
<div id="dragbar"></div>
|
||||
<div id="dragbar" class="resizer"></div>
|
||||
|
||||
<!-- 中间嵌入的 Vscode-web 窗口,带有 tkn 参数 -->
|
||||
<div class="vscode-web"id="vscodeWeb">
|
||||
</div>
|
||||
<div class="vscode-web"id="vscodeWeb" >
|
||||
</div>
|
||||
|
||||
|
||||
<div id="dragbar2"></div>
|
||||
<div id="dragbar2" class="resizer"></div>
|
||||
<!-- 右侧内容 -->
|
||||
<div class="sidebar" id="rightSidebar"style="width: 100%;height: 100%;">
|
||||
<div class="chatbox-header">
|
||||
@@ -54,7 +54,8 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chatbox" id="chatbox" style="width: 100%;height: 80%;">
|
||||
|
||||
<div class="chatbox" id="chatbox" >
|
||||
<!-- 消息会在这里显示 -->
|
||||
</div>
|
||||
<div class="input-area">
|
||||
@@ -66,7 +67,8 @@
|
||||
window.appData = {
|
||||
user_uuid:"{{user_uuid}}",
|
||||
course_id:"{{course_id}}",
|
||||
chapter_id:"{{chapter_id}}",
|
||||
lesson_name:"{{lesson_name}}",
|
||||
chapter_name:"{{chapter_name}}",
|
||||
folder:"{{workspace_path}}"
|
||||
}
|
||||
</script>
|
||||
@@ -112,12 +114,19 @@
|
||||
let isDraggingLeft = false;
|
||||
let isDraggingRight = false;
|
||||
|
||||
dragbar.addEventListener('mousedown', function() {
|
||||
isDraggingLeft = true;
|
||||
// 当鼠标按下时,禁用 iframe 的鼠标事件
|
||||
dragbar.addEventListener('mousedown', function(e) {
|
||||
isDraggingLeft = true;
|
||||
document.querySelectorAll('iframe').forEach(function(iframe) {
|
||||
iframe.style.pointerEvents = 'none'; // 禁止 iframe 捕获鼠标事件
|
||||
});
|
||||
});
|
||||
|
||||
dragbar2.addEventListener('mousedown', function() {
|
||||
isDraggingRight = true;
|
||||
dragbar2.addEventListener('mousedown', function(e) {
|
||||
isDraggingRight = true;
|
||||
document.querySelectorAll('iframe').forEach(function(iframe) {
|
||||
iframe.style.pointerEvents = 'none'; // 禁止 iframe 捕获鼠标事件
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('mousemove', function(e) {
|
||||
@@ -131,8 +140,11 @@
|
||||
});
|
||||
|
||||
document.addEventListener('mouseup', function() {
|
||||
isDraggingLeft = false;
|
||||
isDraggingRight = false;
|
||||
isDraggingLeft = false;
|
||||
isDraggingRight = false;
|
||||
document.querySelectorAll('iframe').forEach(function(iframe) {
|
||||
iframe.style.pointerEvents = 'auto'; // 恢复 iframe 的鼠标事件
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -156,7 +168,7 @@
|
||||
const sessionInfo = data
|
||||
iframe.src = '{{vscode_web_url}}/?workspace={{workspace_path}}&folder={{workspace_path}}';
|
||||
iframe.style.width = '100%';
|
||||
iframe.style.height = '100%';
|
||||
iframe.style.height = '99%';
|
||||
|
||||
// 将 iframe 插入到指定的 div 中
|
||||
document.getElementById('vscodeWeb').appendChild(iframe);
|
||||
@@ -174,8 +186,8 @@
|
||||
|
||||
|
||||
// 动态加载 Markdown 文件
|
||||
function loadMarkdown(course_id, filename) {
|
||||
fetch(`/${course_id}-${filename}-markdown`)
|
||||
function loadMarkdown(course_id, chapter_name, lesson_name) {
|
||||
fetch(`/${course_id}-${chapter_name}-${lesson_name}-markdown`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.html_url) {
|
||||
@@ -194,7 +206,7 @@
|
||||
});
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadMarkdown('{{course_id}}','{{chapter_id}}');
|
||||
loadMarkdown('{{course_id}}','{{chapter_name}}','{{lesson_name}}');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -6,21 +6,21 @@
|
||||
<title>课程选择主页</title>
|
||||
<link rel="stylesheet" href="/static/css/index.css">
|
||||
</head>
|
||||
<body onload="init_index()" >
|
||||
<body >
|
||||
{% include 'navbar.html' %} <!-- 引入navbar.html -->
|
||||
<main>
|
||||
<div class="course-selection">
|
||||
<h2>课程列表</h2>
|
||||
<div class="course-list">
|
||||
{% for course_id, course in courses_data.items() %}
|
||||
<div class="course-card" onclick="show_course_details('{{ course_id }}')">
|
||||
<img src="{{ course.course_img_path }}" alt="{{ course.course_name }}">
|
||||
<h3>{{ course.course_name }}</h3>
|
||||
<p>{{ course.course_description }}</p>
|
||||
{% if course_id in selected_courses %}
|
||||
{% for course in courses_data %}
|
||||
<div class="course-card" onclick="show_course_details('{{ course._id }}')">
|
||||
<img src="{{ course.image_url }}" alt="{{ course.course_name }}">
|
||||
<h3>{{ course.name }}</h3>
|
||||
<p>{{ course.description }}</p>
|
||||
{% if course._id in selected_courses %}
|
||||
<button class="selected-button">已选择</button>
|
||||
{% else %}
|
||||
<button class="select-button" data-course-id="{{course_id}}">选择课程</button>
|
||||
<button class="select-button" data-course-id="{{course._id}}">选择课程</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<div class="avatar dropdown">
|
||||
<img src="/static/image/algorithm/book_cover.png" alt="个人头像" class="avatar-img">
|
||||
<div class="dropdown-content">
|
||||
<a href="/switch-role" id="switch-role">切换到学生/教师</a>
|
||||
<a href="/switch-role/{{'student' if role != 'teacher' else 'teacher'}}" id="switch-role">切换到学生/教师</a>
|
||||
<a href="/logout" id="logout">注销</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user