Skip to content

Commit

Permalink
考试
Browse files Browse the repository at this point in the history
  • Loading branch information
FinGet committed Apr 19, 2018
1 parent b908f4e commit 1e04253
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 84 deletions.
163 changes: 82 additions & 81 deletions src/components/fronttop.vue
Original file line number Diff line number Diff line change
@@ -1,81 +1,82 @@
<template>
<div class="fronttop">
<div class="top"></div>
<div class="top-user">
<ul class="user-info">
<li>欢迎!{{userData.userName}}同学</li>
<li>学号: {{userData.userId}}</li>
<li>年级: {{userData.grade}} 年级</li>
<li>班级: {{userData.class}} 班</li>
</ul>
<el-button type="danger" size="mini" class="login-out" @click="loginOut">退出</el-button>
<router-link class="person" :to="{name:'FrontStudentInfo'}">个人中心</router-link>
<router-link class="index" :to="{name:'FrontIndex'}">首页</router-link>
</div>
</div>
</template>

<script type="text/ecmascript-6">
export default{
props:{
userData: {
type: Object,
default: function () {
return {}
}
}
},
methods:{
// 退出登录
loginOut(){
this.$axios.post('/api/studentlogout').then(response => {
let res = response.data
if (res.status == 0) {
this.$message.success('退出成功')
this.$router.push({name:'FrontLogin'})
}
})
}
}
}
</script>

<style rel="stylesheet/scss" scoped="scoped" lang="scss">
.top {
width: 100%;
height:110px;
margin:0 auto;
background: url("../common/img/logobanner.png") center center;
}
.top-user{
width: 100%;
height: 30px;
line-height: 30px;
margin:0 auto;
font-size: 16px;
background: #08829f;
.user-info{
float: left;
color: #fff;
line-height:30px;
li {
float: left;
margin-left: 20px;
}
}
.person,.index{
color: #c2c2c4;
float: right;
margin-right: 30px;
cursor: pointer;
&:hover{
color: #fff;
}
}
.login-out{
float: right;
margin-right: 50px;
margin-top: 4px;
}
}
</style>
<template>
<div class="fronttop">
<div class="top"></div>
<div class="top-user">
<ul class="user-info">
<li>欢迎!{{userData.userName}}同学</li>
<li>学号: {{userData.userId}}</li>
<li>年级: {{userData.grade}} 年级</li>
<li>班级: {{userData.class}} 班</li>
</ul>
<el-button type="danger" size="mini" class="login-out" @click="loginOut">退出</el-button>
<router-link class="person" :to="{name:'FrontStudentInfo'}">个人中心</router-link>
<router-link class="index" :to="{name:'FrontIndex'}">首页</router-link>
</div>
</div>
</template>

<script type="text/ecmascript-6">
export default{
props:{
userData: {
type: Object,
default: function () {
return {}
}
}
},
methods:{
// 退出登录
loginOut(){
this.$axios.post('/api/studentlogout').then(response => {
let res = response.data
if (res.status == 0) {
this.$message.success('退出成功');
this.$router.push({name:'FrontLogin'});
this.$mySessionStorage.set('read',false);
}
})
}
}
}
</script>

<style rel="stylesheet/scss" scoped="scoped" lang="scss">
.top {
width: 100%;
height:110px;
margin:0 auto;
background: url("../common/img/logobanner.png") center center;
}
.top-user{
width: 100%;
height: 30px;
line-height: 30px;
margin:0 auto;
font-size: 16px;
background: #08829f;
.user-info{
float: left;
color: #fff;
line-height:30px;
li {
float: left;
margin-left: 20px;
}
}
.person,.index{
color: #c2c2c4;
float: right;
margin-right: 30px;
cursor: pointer;
&:hover{
color: #fff;
}
}
.login-out{
float: right;
margin-right: 50px;
margin-top: 4px;
}
}
</style>
48 changes: 46 additions & 2 deletions src/exam/pages/exam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,38 @@
<h3 class="text-center marginT10">{{paperData.name}}</h3>
<div class="text-center marginT10">考试时长:{{paperData.time}}分钟 总分:{{paperData.totalPoints}}分</div>
<hr>
<div class="main">
<div class="single">
<h4>单选题(只有一个正确答案)</h4>
<ul>
<li class="marginB10" v-for="(item,index) in singleQuestions" :key="item.id">
<p class="question-title">{{index+1}} 、{{item.name}} ()</p>
<span class="option"
v-if="item.type!='judgement'&&item.type!='Q&A'"item
v-for="(item1,index1) in item.selection" :key="item1.id">
{{options[index1]}}、{{item1}}</span>
</li>
</ul>
</div>
</div>
</div>
</template>
<script type="text/ecmascript-6">
export default{
data(){
return {
id: '',
paperData:''
paperData:{
name:'',
time:'',
totalPoints:''
},
singleQuestions:[],
multiQuestions:[],
QAQuestions:[],
judgeQuestions:[],
options:['A','B','C','D','E','F','G','H','I','J','K',
'L','M','N','O','P','Q','R','S','T'],
}
},
mounted(){
Expand All @@ -33,7 +57,20 @@
}).then(response => {
let res = response.data;
if(res.status == '0') {
this.paperData = res.result;
for(let key in this.paperData) {
this.paperData[key] = res.result[key];
}
res.result._questions.forEach(item => {
if(item.type=='single'){
this.singleQuestions.push(item);
} else if(item.type == 'multi'){
this.multiQuestions.push(item);
} else if(item.type == 'Q&A') {
this.QAQuestions.push(item);
} else if(item.type == 'judgement'){
this.judgeQuestions.push(item);
}
})
}
}).catch(err => {
this.$message.error(err);
Expand All @@ -46,5 +83,12 @@
<style scoped rel="stylesheet/scss" lang="scss">
.exam{
padding: 20px 0;
.main{
padding: 20px;
}
.question-title{
font-size: 16px;
margin-bottom: 5px;
}
}
</style>
2 changes: 1 addition & 1 deletion src/exam/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {
this.$router.push({path:'forntexamindex'});
},
readGo(){
if(this.isRead) {
if(this.isRead == 'true') {
this.$router.push({path:'forntexamindex'});
this.$message.success('已阅读考试规则并遵守!');
}
Expand Down

0 comments on commit 1e04253

Please sign in to comment.