Commit 575607aa authored by 晏成浩's avatar 晏成浩

Merge branch 'feature/20201222_show_student_answer' into 'master'

Feature/20201222 show student answer See merge request !3
parents 18fe370c 8c73ca80
<template>
<div class="answer-dialog-box">
<div class="answer-dialog" @click="$event.stopPropagation()">
<div class="as-tool-box" @click="$event.stopPropagation()">
<div class="total" @click="isShowContent = !isShowContent">
<span>{{ replyList.filter(item => item.answer).length }}</span>
<span>/{{ replyList.length }}</span>
<i :class="[isShowContent ? 'el-icon-d-arrow-left':'el-icon-d-arrow-right']" class="icon"></i>
</div>
<el-button @click="handleQuestionStop">结束答题</el-button>
<el-button type="danger" @click="$emit('question-exit',false)">退出</el-button>
</div>
<div v-if="quickResponse">
<div v-if="isShowQuickResponse" class="student-as-box">
<img :src="require('@/assets/images/icon-student-avator.png')" alt="">
<div class="info-box">
<p>学生:{{ quickResponse.username }}</p>
<div class="answer-box">
<span>答案:{{quickResponse.answer}}</span>
</div>
</div>
</div>
</div>
<div v-if="isShowContent" class="answer-dialog" @click="$event.stopPropagation()">
<div v-for="(item,idx) in replyList" :key="idx" class="student-as-box">
<img :src="require('@/assets/images/icon-student-avator.png')" alt="">
<div class="info-box">
......@@ -14,33 +35,57 @@
</div>
</div>
</div>
<div v-if="imgSrc" class="img-pre-box" @click="handleImgClick">
<img :src="imgSrc" alt="">
<div v-if="imgSrc" class="img-pre-box" @click="handleImgClick" ref="imgBox">
<img :src="imgSrc" class="as-img" alt="">
<img :src="require('@/assets/images/icon-close.png')" @click="imgSrc = ''" class="close-img" alt="">
</div>
</div>
</template>
<script>
import socket from '@/utils/socket';
export default {
name: 'answer-dialog',
props: {
replyList: {required: true, default: () => []}
replyList: {required: true, default: () => []},
quickResponse: {}
},
data() {
return {
// 放大展示的img Src
imgSrc: ''
imgSrc: '',
isShowContent: false,
isShowQuickResponse: false
}
},
mounted() {
console.log('answerList', this.replyList)
},
watch: {
quickResponse(newVal,oldVal) {
if (newVal) {
this.isShowContent = true
}
}
},
methods: {
handleQuestionStop() {
console.log('eventId: this.$parent.eventId',this.$parent.eventId)
socket.sendGroupMsg({
type: 'question-stop',
payload: {
eventId: this.$parent.eventId
}
}, (res) => {
console.log('teacher-stop-answer success: ', res);
})
},
handleShowImg(imgSrc) {
this.imgSrc = imgSrc
},
handleImgClick(e) {
this.imgSrc = ''
// this.imgSrc = ''
e.stopPropagation()
}
}
......@@ -50,17 +95,51 @@ export default {
<style scoped lang="scss">
.answer-dialog-box {
position: fixed;
width: 100vw;
height: 100vh;
left: 0;
top: 0;
}
.as-tool-box{
position: fixed;
left: 110px;
top: 20px;
border-radius: 20px;
padding: 20px;
background:white;
box-shadow: 0 0 8px 0 rgba(176, 176, 176, 0.5);
width: 200px;
.total{
cursor: pointer;
display: flex;
align-items: flex-end;
justify-content: center;
position: relative;
margin-bottom: 20px;
.icon{
position: absolute;
right: 0px;
font-size: 20px;
border-radius: 50%;
border: 1px solid rgba(0,0,0,03);
padding: 5px;
top: 50%;
transform: translateY(-50%);
}
span:nth-child(1){
font-size: 45px;
color: #42b983;
font-weight: bold;
}
span:nth-child(2){
font-size: 25px;
font-weight: bold;
margin-bottom: 7px;
}
}
}
.answer-dialog {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
position: fixed;
top: 20px;
left: 365px;
background: white;
border-radius: 20px;
width: 900px;
......@@ -73,45 +152,44 @@ export default {
justify-content: space-between;
align-items: flex-start;
.student-as-box {
width: 240px;
height: 100px;
margin-right: 10px;
border-radius: 10px;
border: 2px solid rgba(70, 131, 230, .3);
align-items: center;
display: flex;
padding: 10px;
margin-bottom: 10px;
}
.student-as-box {
width: 240px;
height: 100px;
margin-right: 10px;
border-radius: 10px;
border: 2px solid rgba(70, 131, 230, .3);
align-items: center;
display: flex;
padding: 10px;
margin-bottom: 10px;
img {
display: inline-block;
line-height: 100px;
width: 60px;
height: 60px;
margin-right: 20px;
}
img {
display: inline-block;
line-height: 100px;
width: 60px;
height: 60px;
margin-right: 20px;
}
.info-box {
flex: 1;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-around;
.info-box {
flex: 1;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-around;
.answer-box {
display: flex;
align-items: center;
.answer-box {
display: flex;
align-items: center;
img {
height: 30px;
width: 30px;
border-radius: 3px;
cursor: pointer;
}
img {
height: 30px;
width: 30px;
border-radius: 3px;
cursor: pointer;
}
}
}
}
......@@ -119,18 +197,29 @@ export default {
.img-pre-box {
height: 100vh;
width: 100vw;
background: rgba(0, 0, 0, .3);
position: absolute;
//background: rgba(0, 0, 0, .3);
background-size: 100% 100%;
background-image: url("//test-static-1257124244.cos.ap-chengdu.myqcloud.com/gk-online-static/courseware/demo/1.png");
position: fixed;
left: 0;
top: 0;
img {
height: 800px;
width: 800px;
.as-img {
height: 100vh;
width: 100vw;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.close-img{
cursor: pointer;
width: 50px;
height: 50px;
position: absolute;
top: 20px;
right: 20px;
}
}
</style>
......@@ -50,21 +50,21 @@
v-for="opt in itm.options" :key="opt.title">{{ opt.title }}</span>
</div> -->
<div class="reply-tips">
<el-badge :value="(replyList || []).length" class="item">
<el-button @click.stop="showAnsModal = !showAnsModal" size="small">回答</el-button>
</el-badge>
<div class="std-ans" v-if="showAnsModal">
<!-- <template v-for="(itm, index) in replyList">-->
<!-- <div class="reply-tips">-->
<!-- <el-badge :value="(replyList || []).length" class="item">-->
<!-- <el-button @click.stop="showAnsModal = !showAnsModal" size="small">回答</el-button>-->
<!-- </el-badge>-->
<!-- <div class="std-ans" v-if="showAnsModal">-->
<!-- <template v-for="(itm, index) in replyList">-->
<!-- <p class="st-itm" v-if="itm.type === 1 || itm.type === 2" :key="index">-->
<!-- <span>{{ itm.username }} 回答</span>-->
<!-- <img class="img" :src="itm.answer" alt="" />-->
<!-- </p>-->
<!-- <p class="st-itm" v-else :key="index">{{ itm.username }} 回答: {{ itm.answer }}</p>-->
<!-- </template>-->
</div>
</div>
<answer-dialog v-if="showAnsModal" :reply-list="replyList"/>
<!-- </div>-->
<!-- </div>-->
<answer-dialog v-if="showAnsModal" :quick-response="quickResponseData" @question-exit="handleQuestionExit" :reply-list="replyList"/>
</div>
</template>
......@@ -102,7 +102,7 @@ const paintTypes = [
// { title: '填空题', value: 2 } // 暂时屏蔽简答题
]
},
{ title: 'question-stop', name: '停止答题' },
// { title: 'question-stop', name: '停止答题' },
{ title: 'full', name: '全屏' },
]
......@@ -174,6 +174,7 @@ export default {
currentIndex: 0,
ansModal: false,
showAnsModal: false,
quickResponseData: null
};
},
computed: {
......@@ -200,17 +201,6 @@ export default {
// eslint-disable-next-line no-unused-expressions
this.$refs.pain_main && this.$refs.pain_main.requestFullscreen();
}
if (title === 'question-stop') {
// this.eventId = `${new Date().getTime()}`
socket.sendGroupMsg({
type: 'question-stop',
payload: {
eventId: this.eventId
}
}, (res) => {
console.log('teacher-stop-answer success: ', res);
})
}
},
handleToolItm(opt) {
this.ansModal = false
......@@ -232,6 +222,7 @@ export default {
this.replyList = []
// 唯一时间戳 判断事件是否有效
this.eventId = `${new Date().getTime()}`
this.quickResponseData = null
socket.sendGroupMsg({
type: 'question',
payload: {
......@@ -257,27 +248,42 @@ export default {
const { type, payload } = data || {}
const { username = '' } = payload || {}
// 根据eventId 来判断当前事件有效性
// if (type === 'answer' && this.eventId === payload.eventId) {
if (type === 'answer') {
// // 处理假数据
const newAnswerList = JSON.parse(JSON.stringify(this.replyList))
if (type === 'answer' && this.eventId === payload.eventId) {
// 抢答题
if (`${payload.type}` === '2' && !this.quickResponseData) {
console.log('asdfffff')
this.quickResponseData = payload
newAnswerList.forEach((item) => {
if (!item.answer && item.username === username) {
item.type = payload.type
item.answer = '抢答成功'
// flag = false
}
})
} else {
// 非抢答题
this.$notify({
dangerouslyUseHTMLString: true,
message: `<h1>${username} 提交了答案</h1>`
});
// 保证 只赋值一次
// let flag = true
newAnswerList.forEach((item) => {
if (!item.answer && item.username === username) {
item.type = payload.type
item.answer = payload.answer
// flag = false
}
})
}
// this.$notify.info({
// title: `${username}`,
// message: '提交了答案'
// });
this.$notify({
dangerouslyUseHTMLString: true,
message: `<h1>${username} 提交了答案</h1>`
});
// // 处理假数据
const newAnswerList = JSON.parse(JSON.stringify(this.replyList))
// 保证 只赋值一次
// let flag = true
newAnswerList.forEach((item) => {
if (!item.answer && item.username === username) {
item.type = payload.type
item.answer = payload.answer
// flag = false
}
})
// if ()
// 更新视图
this.replyList = newAnswerList
// this.replyList.push(payload);
......@@ -302,6 +308,18 @@ export default {
},
drawChange(actions) {
this.paints[this.currentIndex] = actions
},
handleQuestionExit() {
socket.sendGroupMsg({
type: 'question-exit',
payload: {
eventId: this.eventId,
}
},() => {
console.log('退出成功')
this.showAnsModal = false
})
}
},
async mounted() {
......
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