smart_class
educoder_weapp 5 years ago
parent b9cf792f7f
commit 778197468f

@ -1,9 +1,9 @@
<!--pages/addclass/addclass.wxml-->
<view class="container">
<view class="top" style="position:fixed; top:0; width:100%; margin:0 -12px;">
<view class="top" style="position:fixed; top:0; width:100%; margin:0 -12px;z-index:9">
<mp-searchbar bindinput="search_courses" style="width:100%"></mp-searchbar>
</view>
<view class="course-list form-wrap" style="margin-top:50px;">
<view class="course-list form-wrap" style="padding-top:50px;">
<image wx:if="{{courses.length==0 && !loading}}" src="../../images/none2.png" class="none-content"></image>
<text wx:if="{{courses.length==0 && !loading}}" class="none-content">没有可以加入的课程了</text>
<block wx:for="{{courses}}" wx:for-item="course" wx:key="id">

@ -6,7 +6,8 @@ Page({
* 页面的初始数据
*/
data: {
grades:[]
grades:[],
page_status:0
},
/**
@ -17,7 +18,7 @@ Page({
app.client.get_exercise_grade({exercise_id: this.exercise_id})
.then(res=>{
console.log(res);
this.setData({ grades: res.data.exercise_users})
this.setData({ grades: res.data.exercise_users, page_status: 1})
})
},

@ -1,3 +1,4 @@
{
"usingComponents": {}
"usingComponents": {},
"navigationBarTitleText": "分数列表"
}

@ -3,11 +3,11 @@
<block wx:for="{{grades}}" wx:for-item="grade" wx:key="objectId">
<view wx:if="{{grade.edu_account_login==navItem.login||navItem.login=='*'}}" class="grade flex-wrap">
<text class="name">{{grade.user_name}}</text>
<text class="mark">{{grade.score||'--'}}</text>
<text class="mark">{{grade.score==0?grade.score:grade.score||'--'}}</text>
</view>
</block>
</view>
<view wx:if="{{grades.length==0}}" style="text-align: center">
<view wx:if="{{grades.length==0&&page_status==1}}" style="text-align: center">
<text class="error">分数未公布</text>
</view>
</view>

@ -1,5 +1,5 @@
// pages/exercise_setting/exercise_setting.js
import { getNowFormatDate, getNowFormatTime} from "../../utils/dateutils"
import { getNowFormatDate, getNowFormatTime, getNextWeekFormatDate} from "../../utils/dateutils"
const app = getApp();
Page({
@ -7,23 +7,22 @@ Page({
* 页面的初始数据
*/
data: {
exercise_id: null,
exercise: {},
exercise_questions:[],
},
start_publish: function(){
if (!this.data.exercise_id) {
if (!this.exercise_id) {
console.error("请先保存试卷");
return;
}
console.log({
course_id: this.course_id, exercise_ids: [this.data.exercise_id],
end_time: getNowFormatDate() + " " + getNowFormatTime()
course_id: this.course_id, exercise_ids: [this.exercise_id],
end_time: getNextWeekFormatDate() + " " + getNowFormatTime()
});
let end_time = getNowFormatDate() + " " + getNowFormatTime();
end_time = end_time.replace("-11", "-12");
let end_time = getNextWeekFormatDate() + " " + getNowFormatTime();
//end_time = end_time.replace("-11", "-12");
app.client.publish_exercise({
course_id: this.course_id, exercise_ids: [this.data.exercise_id],
course_id: this.course_id, exercise_ids: [this.exercise_id],
end_time: end_time
}).then(res=>{
console.log(res);
@ -34,24 +33,53 @@ Page({
)
},
create_question: function(){
if(!this.data.exercise_id){
if(!this.exercise_id){
console.error("请先保存试卷");
wx.showToast({
title: '请先保存试卷',
icon:"none"
})
return;
}
wx.navigateTo({
url: `../question_setting/question_setting?exercise_id=${this.data.exercise_id}`,
url: `../question_setting/question_setting?exercise_id=${this.exercise_id}`,
})
},
create_exercise: function({detail:{value}}){
console.log(value);
if(this.exercise_id){
app.client.update_exercise({...value, exercise_id: this.exercise_id})
.then(res => {
console.log(res);
wx.showToast({
title: res.data.message,
})
})
.catch(error => {
console.error(error);
wx.showToast({
title: error.toString(),
icon: "none"
})
});
}else{
app.client.create_exercise({ ...value, course_id: this.course_id })
.then(res => {
console.log(res);
this.setData({ exercise_id: res.data.data.exercise_id});
this.exercise_id = res.data.data.exercise_id
wx.showToast({
title: '创建成功',
})
})
.catch(error => {
console.error(error);
wx.showToast({
title: error.toString(),
icon: "none"
})
});
}
},
/**
* 生命周期函数--监听页面加载
@ -60,7 +88,7 @@ Page({
this.course_id = options.course_id;
this.intent=options.intent;
if(options.exercise_id){
this.setData({exercise_id: options.exercise_id});
this.exercise_id = options.exercise_id;
}
},
@ -74,8 +102,8 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
if(this.data.exercise_id){
app.client.get_exercise_edit({exercise_id: this.data.exercise_id})
if(this.exercise_id){
app.client.get_exercise_edit({exercise_id: this.exercise_id})
.then(res=>{
console.log(res);
this.setData(

@ -16,7 +16,7 @@
<button bindtap="create_question" data-type="0">+选择题</button>
</view>
</view>
<scroll-view class="questions" scroll-y="true" wx:if="{{exercise_id}}">
<scroll-view class="questions" scroll-y="true">
<block wx:for="{{exercise_questions}}" wx:for-item="question" wx:key="question_id">
<view class="question">
<text class="hint">第{{question.q_position}}题</text>

@ -42,6 +42,11 @@ text.start-answer{
position: fixed;
right: 8rpx;
}
text.edit-exercise{
position: fixed;
right: 8rpx;
}
.exercise{
background: white;
padding: 15rpx 15rpx;
@ -65,12 +70,13 @@ text.start-answer{
view.no-content{
display: flex;
flex-direction: column;
flex-direction: row;
justify-content: center;
}
image.no-content{
width: 300rpx;
height: 300rpx;
width: 200rpx;
height: 200rpx;
}
.require-login{

@ -11,13 +11,23 @@ Page({
create_question: function({detail:{value}}){
console.log(value);
let data = {
question_title:value.question_title,question_type:0,question_score:5,question_choices:[value.question_choices_0, value.question_choices_1, value.question_choices_2, value.question_choices_3],standard_answers:value.standard_answers}
question_title:value.question_title,
question_type:0,
question_score:5,
question_choices:[value.question_choices_0, value.question_choices_1, value.question_choices_2, value.question_choices_3],
standard_answers:value.standard_answers
}
app.client.create_question({exercise_id: this.exercise_id, data})
.then(res=>{
console.log(res);
wx.navigateBack({
delta: 1
})
}).catch(error=>{
wx.showToast({
title: error.toString(),
icon: "none"
})
})
},
/**

@ -5,7 +5,7 @@
</view>
<checkbox-group name="standard_answers">
<view wx:for="{{4-0}}" class="flex-wrap">
<checkbox value="{{index}}"></checkbox>
<checkbox value="{{index+1}}"></checkbox>
<input name="{{'question_choices_'+index}}" placeholder="输入选项文字"></input>
</view>
</checkbox-group>

@ -14,6 +14,22 @@ export function getNowFormatDate() {
return currentdate;
}
export function getNextWeekFormatDate(){
var now = new Date();
var date = new Date(now.getTime() + 7 * 24 * 3600 * 1000);
var seperator1 = "-";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate;
}
export function getNowFormatTime(){
var now = new Date();
var hour = now.getHours();//得到小时

Loading…
Cancel
Save