smart_class
educoder_weapp 5 years ago
parent b9cf792f7f
commit 778197468f

@ -1,9 +1,9 @@
<!--pages/addclass/addclass.wxml--> <!--pages/addclass/addclass.wxml-->
<view class="container"> <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> <mp-searchbar bindinput="search_courses" style="width:100%"></mp-searchbar>
</view> </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> <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> <text wx:if="{{courses.length==0 && !loading}}" class="none-content">没有可以加入的课程了</text>
<block wx:for="{{courses}}" wx:for-item="course" wx:key="id"> <block wx:for="{{courses}}" wx:for-item="course" wx:key="id">

@ -6,7 +6,8 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
grades:[] grades:[],
page_status:0
}, },
/** /**
@ -17,7 +18,7 @@ Page({
app.client.get_exercise_grade({exercise_id: this.exercise_id}) app.client.get_exercise_grade({exercise_id: this.exercise_id})
.then(res=>{ .then(res=>{
console.log(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"> <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"> <view wx:if="{{grade.edu_account_login==navItem.login||navItem.login=='*'}}" class="grade flex-wrap">
<text class="name">{{grade.user_name}}</text> <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> </view>
</block> </block>
</view> </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> <text class="error">分数未公布</text>
</view> </view>
</view> </view>

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

@ -16,7 +16,7 @@
<button bindtap="create_question" data-type="0">+选择题</button> <button bindtap="create_question" data-type="0">+选择题</button>
</view> </view>
</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"> <block wx:for="{{exercise_questions}}" wx:for-item="question" wx:key="question_id">
<view class="question"> <view class="question">
<text class="hint">第{{question.q_position}}题</text> <text class="hint">第{{question.q_position}}题</text>

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

@ -11,13 +11,23 @@ Page({
create_question: function({detail:{value}}){ create_question: function({detail:{value}}){
console.log(value); console.log(value);
let data = { 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}) app.client.create_question({exercise_id: this.exercise_id, data})
.then(res=>{ .then(res=>{
console.log(res); console.log(res);
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1
}) })
}).catch(error=>{
wx.showToast({
title: error.toString(),
icon: "none"
})
}) })
}, },
/** /**

@ -5,10 +5,10 @@
</view> </view>
<checkbox-group name="standard_answers"> <checkbox-group name="standard_answers">
<view wx:for="{{4-0}}" class="flex-wrap"> <view wx:for="{{4-0}}" class="flex-wrap">
<checkbox value="{{index}}"></checkbox> <checkbox value="{{index+1}}"></checkbox>
<input name="{{'question_choices_'+index}}" placeholder="输入选项文字"></input> <input name="{{'question_choices_'+index}}" placeholder="输入选项文字"></input>
</view> </view>
</checkbox-group> </checkbox-group>
<button type="primary" size="mini" form-type="submit">保存</button> <button type="primary" size="mini" form-type="submit">保存</button>
</form> </form>
</view> </view>

@ -14,6 +14,22 @@ export function getNowFormatDate() {
return currentdate; 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(){ export function getNowFormatTime(){
var now = new Date(); var now = new Date();
var hour = now.getHours();//得到小时 var hour = now.getHours();//得到小时

Loading…
Cancel
Save