Skip to content

调整 #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 26, 2025
Merged

调整 #1036

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dataModels/DocumentModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ schema.methods.getGlobalPostReviewStatus = async function () {
return {
needReview: true,
type: 'notPassedAD',
reason: '用户没有通过入学考试,审核通过的文章数量不足',
reason: '用户没有通过入学培训,审核通过的文章数量不足',
};
}

Expand Down
4 changes: 2 additions & 2 deletions dataModels/ExamsCategoryModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const schema = new Schema(
type: Number,
default: 1, // 1: 基础级, 2: 专业级
},
// 表示试卷是A卷还是B卷还是入学考试
// 表示试卷是A卷还是B卷还是入学培训
// 这跟QuestionModel上的volume有所不同,QuestionModel上的volume相当于level,表示试题的难度
volume: {
type: String,
default: 'A', // A: A卷考试, B: B卷考试, AD: 入学考试
default: 'A', // A: A卷考试, B: B卷考试, AD: 入学培训
},
//闭卷考试是必带uid,但是开卷考试用户并没有uid
uid: {
Expand Down
2 changes: 1 addition & 1 deletion dataModels/ReviewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ schema.statics.getReviewStatusAndCreateLog = async function (post) {
return {
needReview: true,
type: 'notPassedAD',
reason: '用户没有通过入学考试,审核通过的文章数量不足',
reason: '用户没有通过入学培训,审核通过的文章数量不足',
};
}

Expand Down
31 changes: 29 additions & 2 deletions defaultData/settings/exam.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,34 @@ module.exports = {
waitingTime: 15, // 超过次数之后的等待时间(天)
count: 50, // 超过一定数量后需等待一定时间(waitingTime)之后才能参加考试
countOneDay: 10, // 每天参加考试次数最大值
examNotes: '', //闭卷考试须知
publicExamNotes: '', //开卷考试须知
examNotes:
'科创是面向科技爱好者的网站,非大众网站。\n' +
'Kechuang is a website for Enthusiasts, not a general website.\n' +
'科技爱好者是专业的、狂热的、实操的,并且具有持久性。\n' +
'Enthusiasts are professional, enthusiastic, practical, and persistent.\n' +
'科创欢迎新人且足够友好。同时为了持续改善学习氛围,有必要设置招生门槛。\n' +
'Kechuang welcomes new members and is very friendly to new members. At the same time, in order to continuously improve the academic atmosphere, registration requires you to first understand the culture and rules of kechuang.\n' +
'已将资源下载等服务向游客开放。除非打算深度参与,没有必要注册。\n' +
'Services such as resource downloading have been opened to tourists. There is no need to register unless you plan to participate deeply.\n' +
'请通过答题来了解一些科创的知识。题目经过挑选,有利于迅速融入。\n' +
'Please answer the questions to learn some knowledge about kechuang. The topics have been selected and representative.', //闭卷考试须知
volumeANotes:
'A卷考试是闭卷考试。\n' +
'通过A卷考试是进入论坛(预印本)发表文章的前提条件之一。\n' +
'通过A卷考试的用户将来可以再参加B卷考试。',
volumeBNotes:
'B卷考试是闭卷考试。\n' +
'通过B卷考试是参与特种科技爱好话题交流的条件之一。\n',
volumeADNotes:
'入学培训属于学习型考试,不评判分数,通过提示可以全部答对。\n' +
'如果回答正确,选中的选项会显示绿色。\n' +
'如果回答错误,选项不变色,但会展示对选项的讲解。\n' +
'如果回答错误,请仔细阅读每个选项的讲解,理解其意义,然后点击“重做”按钮。\n' +
'当所有的题目都答对以后,培训结业。\n' +
'The purpose of first test is to help you understand the culture here. You can answer all questions correctly through prompts.\n' +
'If answered correctly, the selected option will appear green.\n' +
'If the answer is incorrect, the option will not change color, but an explanation of the option will be displayed.\n' +
'If you answer incorrectly, please read the explanation of each option carefully to understand its meaning, and then click the "Redo" button.\n' +
'When all questions are answered correctly, the exam is passed.',
},
};
6 changes: 6 additions & 0 deletions defaultData/settings/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
thread: {
postPermission: {
authLevelMin: 0,
baseEnabled: false,
examEnabled: false,
examVolumeAD: true,
examVolumeA: true,
Expand Down Expand Up @@ -89,6 +90,7 @@ module.exports = {
post: {
postPermission: {
authLevelMin: 0,
baseEnabled: false,
examEnabled: false,
examVolumeAD: true,
examVolumeA: true,
Expand Down Expand Up @@ -173,6 +175,7 @@ module.exports = {
article: {
postPermission: {
authLevelMin: 0,
baseEnabled: false,
examEnabled: false,
examVolumeAD: true,
examVolumeA: true,
Expand Down Expand Up @@ -257,6 +260,7 @@ module.exports = {
comment: {
postPermission: {
authLevelMin: 0,
baseEnabled: false,
examEnabled: false,
examVolumeAD: true,
examVolumeA: true,
Expand Down Expand Up @@ -341,6 +345,7 @@ module.exports = {
moment: {
postPermission: {
authLevelMin: 0,
baseEnabled: false,
examEnabled: false,
examVolumeAD: true,
examVolumeA: true,
Expand Down Expand Up @@ -425,6 +430,7 @@ module.exports = {
draft: {
postPermission: {
authLevelMin: 0,
baseEnabled: false,
examEnabled: false,
examVolumeAD: true,
examVolumeA: true,
Expand Down
2 changes: 1 addition & 1 deletion defaultData/settings/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ module.exports = {
noticeForDestroy:
'1、注销账号会删除用户名,解除手机、邮箱绑定。\\n2、依据相关法律法规和政策,注销账号后,用户的历史行为依然可以被追溯。\\n3、为保证回复、评论等他人发表的内容不因你的注销行为而失效或受到破坏,依据用户协议,你的发言将会被保留,不可清除。',
examNotice:
'<h3 style="text-align: center;">注册说明</h3>\n为了让新用户可以更好地融入科创,现要求新用户在注册前需通过科创的入学考试。',
'<h3 style="text-align: center;">注册说明</h3>\n为了让新用户可以更好地融入科创,现要求新用户在注册前需通过科创的入学培训。',
},
};
4 changes: 2 additions & 2 deletions pages/exam/editCategory.pug
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ block content
div
label.radio-inline
input(type='radio' value="AD" v-model="category.volume")
| 入学考试
| 入学培训
label.radio-inline
input(type='radio' value="A" v-model="category.volume")
| A卷考试
Expand Down Expand Up @@ -125,7 +125,7 @@ block content
for c in data.categories
h5
span=`【${c.name}】`
span=`${{'AD': '【入学考试】', 'A': "【A卷考试】", 'B': "【B卷考试】"}[c.volume]}${c.disabled?'【已屏蔽】':''}`
span=`${{'AD': '【入学培训】', 'A': "【A卷考试】", 'B': "【B卷考试】"}[c.volume]}${c.disabled?'【已屏蔽】':''}`
a(href=`/exam/categories/editor?cid=${c._id}`) 编辑
block scripts
+includeJS('/exam/editCategory.js')
7 changes: 7 additions & 0 deletions pages/exam/exam.less
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,10 @@
}
}
}

.volume-hl{
background-color: #ffd27063!important;
}
.volume-description{
font-size: 1.25rem;
}
23 changes: 23 additions & 0 deletions pages/exam/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,26 @@ window.createPaper = function (cid) {
})
.catch(sweetError);
};

function highlightElement() {
// 获取当前URL中的锚点
const hash = window.location.hash;
if (hash) {
// 移除之前的高亮
const highlightedElements = document.querySelectorAll('.volume-hl');
highlightedElements.forEach((el) => el.classList.remove('volume-hl'));

// 根据锚点找到对应的元素并添加高亮类
const targetElement = document.querySelector(hash);
if (targetElement) {
const examListContainer = document.querySelector(`[data-id="${hash}"]`);
targetElement.classList.add('volume-hl');
examListContainer.classList.add('volume-hl');
}
}
}

// 页面加载时执行高亮函数
window.onload = highlightElement;
// 监听hashchange事件,以便在锚点变化时重新高亮
window.onhashchange = highlightElement;
23 changes: 15 additions & 8 deletions pages/exam/home.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends ../bootstrap_base
block title
title=`${state.serverSettings.websiteName} | 考试系统`
-const {countOneDay, count, waitingTime, examNotes ,publicExamNotes} = data.examSettings;
-const {countOneDay, count, waitingTime, examNotes ,publicExamNotes, volumeADNotes, volumeANotes, volumeBNotes} = data.examSettings;
+includeCSS('/exam/exam.css')
block content
mixin examsCategoryList(categories)
Expand All @@ -21,24 +21,31 @@ block content
div=`通过率 ${(category.passRate * 100).toFixed(2)}%`
.category-button-container
div.fa.fa-chevron-circle-right(onclick=`createPaper(${category._id})` title='开始考试')
mixin examDescription(notes)
.volume-description
.pre-content= notes
.container-fluid.max-width
.row
.col-xs-12.col-md-12
include ./nav.pug
.col-xs-12.col-md-9.box-shadow-panel
.m-b-1
.panel-header 考试说明
.text-info.p-a-1.bg-info.border-radius-3px
.pre-content= examNotes
h5= `每天最多进行 ${countOneDay} 次考试,考试次数累计达到 ${count} 次时,在 ${waitingTime} 天之内将无法再次参加考试。`
.m-b-1
.panel-header 入学考试
+examDescription(examNotes + `\n\n每天最多进行 ${countOneDay} 次考试,考试次数累计达到 ${count} 次时,在 ${waitingTime} 天之内将无法再次参加考试。`)
#AD(style='scroll-margin-top: 5rem;')
.panel-header 入学培训
+examDescription(volumeADNotes)
.m-b-1(data-id='#AD')
+examsCategoryList(data.examsCategories.volumeAD)
.m-b-1
#A(style='scroll-margin-top: 5rem;')
.panel-header A卷考试
+examDescription(volumeANotes)
.m-b-1(data-id='#A')
+examsCategoryList(data.examsCategories.volumeA)
.m-b-1
#B(style='scroll-margin-top: 5rem;')
.panel-header B卷考试
+examDescription(volumeBNotes)
.m-b-1(data-id='#B')
+examsCategoryList(data.examsCategories.volumeB)

.col-xs-12.col-md-3.box-shadow-panel.p-l-0
Expand Down
2 changes: 1 addition & 1 deletion pages/exam/record/paper.pug
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ block content
else if paper.category.volume === 'B'
| B卷考试
else
| 入学考试
| 入学培训
th
if paper.timeOut
span.text-danger 超时
Expand Down
2 changes: 1 addition & 1 deletion pages/experimental/log/exam/paper.pug
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ block eContent
h5.col-sm-7
strong(v-if='category.volume === "A"') A卷考试
strong(v-else-if='category.volume === "B"') B卷考试
strong(v-else) 入学考试
strong(v-else) 入学培训
.form-group
label.col-sm-5.control-label 及格分数:
h5.col-sm-7
Expand Down
25 changes: 9 additions & 16 deletions pages/experimental/settings/exam.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
var app = new Vue({
import { getDataById } from '../../lib/js/dataConversion';
import { nkcAPI } from '../../lib/js/netAPI';
import { sweetSuccess, sweetError } from '../../lib/js/sweetAlert';

const data = getDataById('data');
var app = new window.Vue({
el: '#app',
data: {
examSettings: {},
},
mounted: function () {
var data = document.getElementById('data');
data = JSON.parse(data.innerHTML);
var settings = data.examSettings;
var examSettings = {};
examSettings.count = settings.count || 0;
examSettings.countOneDay = settings.countOneDay || 0;
examSettings.waitingTime = settings.waitingTime || 0;
examSettings.examNotes = settings.examNotes || '';
examSettings.publicExamNotes = settings.publicExamNotes || '';
this.examSettings = examSettings;
examSettings: data.examSettings,
},
methods: {
save: function () {
nkcAPI('/e/settings/exam', 'PUT', { examSettings: app.examSettings })
.then(function () {
screenTopAlert('保存成功');
sweetSuccess('保存成功');
})
.catch(function (data) {
screenTopWarning(data);
sweetError(data);
});
},
},
Expand Down
35 changes: 15 additions & 20 deletions pages/experimental/settings/exam.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ block content
include ../nav
.hidden#data= JSON.stringify({examSettings: data.examSettings})
.col-xs-12.col-md-12#app(v-cloak)
h4 闭卷考试设置
h4 考试设置
.form-horizontal
.form-group
label.col-sm-2.control-label 每天最多考试次数
Expand All @@ -26,27 +26,22 @@ block content
input.form-control(type='number' v-model.number='examSettings.waitingTime')
h5.text-danger 考试次数达到总次数限制后,该用户将会被禁考一段时间。

h4 闭卷考试须知
.form-horizontal
.form-group
.col-sm-6
.col-md-6.col-xs-12
.form
.form-group
h4 考试说明
textarea.form-control(rows="10" v-model="examSettings.examNotes")= data.examSettings.examNotes
.form-group
label.col-sm-2.control-label
.col-sm-4

h4 开卷考试须知
.form-horizontal
.form-group
.col-sm-6
textarea.form-control(rows="10" v-model="examSettings.publicExamNotes")= data.examSettings.publicExamNotes
.form-group
label.col-sm-2.control-label
.col-sm-4
.form-group
h4 入学培训说明
textarea.form-control(rows="10" v-model="examSettings.volumeADNotes")= data.examSettings.volumeADNotes
.form-group
h4 A卷考试说明
textarea.form-control(rows="10" v-model="examSettings.volumeANotes")= data.examSettings.volumeANotes
.form-group
h4 B卷考试说明
textarea.form-control(rows="10" v-model="examSettings.volumeBNotes")= data.examSettings.volumeBNotes
.form-group
button.btn.btn-primary.btn-block(@click='save') 保存




block scripts
+includeJS('/experimental/settings/exam.js')
22 changes: 20 additions & 2 deletions pages/experimental/settings/publish/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ const app = new window.Vue({
settings() {
return this.publishSettings[this.selectSourceType] || null;
},
disableMomentCount() {
return this.selectSourceType === 'moment';
canNotPublishMoment() {
return this.selectSourceType === 'moment' &&
this.settings.postPermission.momentCount.limited &&
this.settings.postPermission.examNotPass.status === false
? '当前设置会导致永远无权发表电文'
: '';
},
mustSelectOneExam() {
return this.settings.postPermission.examEnabled &&
!this.settings.postPermission.examVolumeA &&
!this.settings.postPermission.examVolumeB &&
!this.settings.postPermission.examVolumeAD
? '请至少勾选一种考试'
: '';
},
},
methods: {
Expand Down Expand Up @@ -54,6 +66,12 @@ const app = new window.Vue({
},
submit() {
const { publishSettings } = this;
if (this.canNotPublishMoment) {
return sweetError(this.canNotPublishMoment);
}
if (this.mustSelectOneExam) {
return sweetError(this.mustSelectOneExam);
}
nkcAPI('/e/settings/publish', 'PUT', { publishSettings })
.then(() => {
sweetSuccess(`保存成功`);
Expand Down
Loading