Commit e83ebf3a authored by liujiangnan's avatar liujiangnan

feat

parent f169b8a3
...@@ -251,6 +251,88 @@ body{ ...@@ -251,6 +251,88 @@ body{
padding: 4px 6px; padding: 4px 6px;
} }
.quiz-toolbar{
display: flex;
gap: 8px;
margin-bottom: 12px;
flex-wrap: wrap;
}
.quiz-list{
display: flex;
flex-direction: column;
gap: 12px;
}
.quiz-item{
border: 1px solid #ebeef5;
border-radius: 6px;
padding: 12px;
background: #fafafa;
}
.quiz-item.dragging{
opacity: 0.6;
border-style: dashed;
}
.quiz-item-head{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.quiz-item-title{
font-weight: 600;
color: #303133;
}
.quiz-item-actions{
display: flex;
gap: 8px;
align-items: center;
}
.quiz-item-type{
font-size: 12px;
color: #606266;
}
.quiz-item-body{
display: flex;
flex-direction: column;
gap: 10px;
}
.quiz-row{
display: flex;
gap: 10px;
align-items: flex-start;
}
.quiz-label{
width: 70px;
font-size: 12px;
color: #606266;
padding-top: 6px;
}
.quiz-options,
.quiz-answers{
flex: 1;
display: flex;
flex-direction: column;
gap: 6px;
}
.quiz-option,
.quiz-answer{
display: flex;
gap: 8px;
align-items: center;
}
.uploader .hint{ .uploader .hint{
margin-left: 10px; margin-left: 10px;
color: #909399; color: #909399;
......
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
<el-button type="info" @click="openAiDialog">编辑AI打点内容</el-button> <el-button type="info" @click="openAiDialog">编辑AI打点内容</el-button>
<el-button type="success" plain @click="handleAiImage">AI图片理解</el-button> <el-button type="success" plain @click="handleAiImage">AI图片理解</el-button>
<el-button type="info" plain @click="openAiImageDialog">编辑AI图片理解内容</el-button> <el-button type="info" plain @click="openAiImageDialog">编辑AI图片理解内容</el-button>
<el-button type="primary" plain @click="openQuizDialog">录入习题</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-col> </el-col>
...@@ -190,6 +191,93 @@ ...@@ -190,6 +191,93 @@
</span> </span>
</el-dialog> </el-dialog>
<el-dialog
title="录入习题"
:visible.sync="quizDialogVisible"
width="80%"
@close="closeQuizDialog">
<div class="quiz-toolbar">
<el-button size="mini" type="primary" @click="addQuestion('choice')">新增选择题</el-button>
<el-button size="mini" type="primary" @click="addQuestion('text')">新增问答题</el-button>
<el-button size="mini" type="primary" @click="addQuestion('judge')">新增判断题</el-button>
<el-button size="mini" type="primary" @click="addQuestion('blank')">新增填空题</el-button>
</div>
<div class="quiz-list" v-if="quizList.length">
<div
class="quiz-item"
v-for="(q, qIndex) in quizList"
:key="q.id"
:class="{ dragging: dragIndex === qIndex }"
draggable="true"
@dragstart="onQuizDragStart(qIndex, $event)"
@dragover="onQuizDragOver(qIndex, $event)"
@dragend="onQuizDragEnd"
@drop="onQuizDrop(qIndex, $event)">
<div class="quiz-item-head">
<div class="quiz-item-title">第{{ qIndex + 1 }}题</div>
<div class="quiz-item-actions">
<span class="quiz-item-type">{{ getQuizTypeLabel(q.type) }}</span>
<el-button size="mini" type="danger" @click="removeQuestion(qIndex)">删除</el-button>
</div>
</div>
<div class="quiz-item-body">
<div class="quiz-row">
<div class="quiz-label">题干</div>
<el-input size="mini" v-model="q.question" @input="saveData"></el-input>
</div>
<div class="quiz-row" v-if="q.type === 'choice'">
<div class="quiz-label">选项</div>
<div class="quiz-options">
<div class="quiz-option" v-for="(opt, optIndex) in q.options" :key="optIndex">
<el-input size="mini" v-model="opt.text" placeholder="请输入选项内容" @input="saveData"></el-input>
<el-checkbox v-model="opt.isCorrect" @change="saveData">正确</el-checkbox>
<el-button size="mini" type="text" :disabled="q.options.length <= 2" @click="removeChoiceOption(qIndex, optIndex)">删除</el-button>
</div>
<el-button size="mini" type="primary" plain :disabled="q.options.length >= 4" @click="addChoiceOption(qIndex)">新增选项</el-button>
</div>
</div>
<div class="quiz-row" v-if="q.type === 'judge'">
<div class="quiz-label">正确答案</div>
<el-radio-group v-model="q.correct" @change="saveData">
<el-radio :label="true">对</el-radio>
<el-radio :label="false">错</el-radio>
</el-radio-group>
</div>
<div class="quiz-row" v-if="q.type === 'text'">
<div class="quiz-label">参考答案</div>
<div class="quiz-answers">
<div class="quiz-answer" v-for="(ans, ansIndex) in q.answers" :key="ansIndex">
<el-input size="mini" v-model="q.answers[ansIndex]" @input="saveData"></el-input>
<el-button size="mini" type="text" :disabled="q.answers.length <= 1" @click="removeAnswer(qIndex, ansIndex)">删除</el-button>
</div>
<el-button size="mini" type="primary" plain @click="addAnswer(qIndex)">新增答案</el-button>
</div>
</div>
<div class="quiz-row" v-if="q.type === 'blank'">
<div class="quiz-label">参考答案</div>
<div class="quiz-answers">
<div class="quiz-answer" v-for="(ans, ansIndex) in q.answers" :key="ansIndex">
<el-input size="mini" v-model="q.answers[ansIndex]" @input="saveData"></el-input>
<el-button size="mini" type="text" :disabled="q.answers.length <= 1" @click="removeAnswer(qIndex, ansIndex)">删除</el-button>
</div>
<el-button size="mini" type="primary" plain @click="addAnswer(qIndex)">新增答案</el-button>
</div>
</div>
</div>
</div>
</div>
<div v-else class="empty-text">暂无习题,请新增</div>
<span slot="footer" class="dialog-footer">
<el-button @click="closeQuizDialog">取消</el-button>
<el-button type="primary" @click="saveQuizDialog">保存</el-button>
</span>
</el-dialog>
<el-col :span="12" class="panel"> <el-col :span="12" class="panel">
<div class="panel-title">AI 编排脚本区</div> <div class="panel-title">AI 编排脚本区</div>
<el-input <el-input
......
...@@ -34,6 +34,9 @@ new Vue({ ...@@ -34,6 +34,9 @@ new Vue({
aiImageContent: '', aiImageContent: '',
aiImageLoading: false, aiImageLoading: false,
aiImageError: '', aiImageError: '',
quizList: [],
quizDialogVisible: false,
dragIndex: -1,
uploading: false, uploading: false,
uploadProgress: 0, uploadProgress: 0,
currentUploadId: 0, currentUploadId: 0,
...@@ -71,6 +74,9 @@ new Vue({ ...@@ -71,6 +74,9 @@ new Vue({
if (typeof data.aiImageContent === 'string') { if (typeof data.aiImageContent === 'string') {
_this.aiImageContent = data.aiImageContent; _this.aiImageContent = data.aiImageContent;
} }
if (Array.isArray(data.quizList)) {
_this.quizList = data.quizList;
}
if (data.scriptText) { if (data.scriptText) {
_this.scriptText = data.scriptText; _this.scriptText = data.scriptText;
} }
...@@ -109,6 +115,122 @@ new Vue({ ...@@ -109,6 +115,122 @@ new Vue({
this.saveData(); this.saveData();
this.closeAiImageDialog(); this.closeAiImageDialog();
}, },
openQuizDialog: function () {
this.quizDialogVisible = true;
},
closeQuizDialog: function () {
this.quizDialogVisible = false;
},
saveQuizDialog: function () {
this.saveData();
this.closeQuizDialog();
},
addQuestion: function (type) {
var item = {
id: 'q_' + Date.now() + '_' + Math.random().toString(16).slice(2),
type: type,
question: ''
};
if (type === 'choice') {
item.options = [
{ text: '', isCorrect: true },
{ text: '', isCorrect: false }
];
} else if (type === 'text') {
item.answers = [''];
} else if (type === 'judge') {
item.correct = true;
} else if (type === 'blank') {
item.answers = [''];
}
this.quizList.push(item);
this.saveData();
},
removeQuestion: function (index) {
if (index < 0 || index >= this.quizList.length) {
return;
}
this.quizList.splice(index, 1);
this.saveData();
},
getQuizTypeLabel: function (type) {
if (type === 'choice') {
return '选择题';
}
if (type === 'text') {
return '问答题';
}
if (type === 'judge') {
return '判断题';
}
if (type === 'blank') {
return '填空题';
}
return '未知';
},
addChoiceOption: function (qIndex) {
var item = this.quizList[qIndex];
if (!item || item.type !== 'choice') {
return;
}
if (item.options.length >= 4) {
return;
}
item.options.push({ text: '', isCorrect: false });
this.saveData();
},
removeChoiceOption: function (qIndex, optIndex) {
var item = this.quizList[qIndex];
if (!item || item.type !== 'choice' || item.options.length <= 2) {
return;
}
item.options.splice(optIndex, 1);
this.saveData();
},
addAnswer: function (qIndex) {
var item = this.quizList[qIndex];
if (!item || !Array.isArray(item.answers)) {
return;
}
item.answers.push('');
this.saveData();
},
removeAnswer: function (qIndex, ansIndex) {
var item = this.quizList[qIndex];
if (!item || !Array.isArray(item.answers) || item.answers.length <= 1) {
return;
}
item.answers.splice(ansIndex, 1);
this.saveData();
},
onQuizDragStart: function (index, event) {
this.dragIndex = index;
if (event && event.dataTransfer) {
event.dataTransfer.effectAllowed = 'move';
event.dataTransfer.setData('text/plain', String(index));
}
},
onQuizDragOver: function (index, event) {
if (event) {
event.preventDefault();
}
},
onQuizDrop: function (index, event) {
if (event) {
event.preventDefault();
}
var fromIndex = this.dragIndex;
if (fromIndex < 0 || fromIndex === index) {
return;
}
var moved = this.quizList.splice(fromIndex, 1)[0];
this.quizList.splice(index, 0, moved);
this.dragIndex = -1;
this.saveData();
},
onQuizDragEnd: function () {
this.dragIndex = -1;
},
getUploadInput: function (refName, index) { getUploadInput: function (refName, index) {
var ref = this.$refs[refName]; var ref = this.$refs[refName];
if (!ref) { if (!ref) {
...@@ -437,6 +559,7 @@ new Vue({ ...@@ -437,6 +559,7 @@ new Vue({
audioUrl: this.audioPreviewUrl, audioUrl: this.audioPreviewUrl,
aiTagData: this.aiTagData, aiTagData: this.aiTagData,
aiImageContent: this.aiImageContent, aiImageContent: this.aiImageContent,
quizList: this.quizList,
scriptText: this.scriptText scriptText: this.scriptText
}; };
window.courseware.setData(data, function () {}, key); window.courseware.setData(data, function () {}, key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment