xiaohaizhao 1 anno fa
parent
commit
d02d2b992c

+ 3 - 1
app.json

@@ -27,7 +27,9 @@
         "pages/threadedTree/details/index",
         "pages/classroom/index",
         "pages/classroom/list",
-        "pages/classroom/detail"
+        "pages/classroom/detail",
+        "pages/exam/index",
+        "pages/exam/detail"
     ],
     "usingComponents": {
         "My_card": "/components/My_card/index",

+ 112 - 0
pages/exam/detail.js

@@ -0,0 +1,112 @@
+let sat_courseware_testid = null;
+
+const _Http = getApp().globalData.http;
+Page({
+    data: {
+        loading: false
+    },
+    onLoad(options) {
+        sat_courseware_testid = options.id;
+        this.getDetail();
+    },
+    getDetail() {
+        _Http.basic({
+            "classname": "saletool.courseware.coursewaretest",
+            "method": "queryTestMain",
+            "content": {
+                sat_courseware_testid
+            }
+        }).then(res => {
+            console.log("试卷详情", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            });
+            let count = [];
+            res.data.testitems = res.data.testitems.map(v => {
+                v.answer = JSON.parse(v.answer);
+                if (v.answer.length) count.push(v.sat_courseware_testitemsid);
+                return v
+            })
+            this.setData({
+                detail: res.data,
+                count
+            })
+        })
+    },
+    groupOnChange(e) {
+        const {
+            index,
+            item
+        } = e.currentTarget.dataset;
+        let count = this.data.count;
+        item.answer = e.detail;
+        this.setData({
+            [`detail.testitems[${index}]`]: item
+        })
+        if (item.answer.length) {
+            count.some(v => v == item.sat_courseware_testitemsid) ? '' : count.push(item.sat_courseware_testitemsid);
+        } else {
+            count = count.filter(v => v != item.sat_courseware_testitemsid);
+        };
+        this.setData({
+            count
+        })
+        _Http.basic({
+            "classname": "saletool.courseware.coursewaretest",
+            "method": "testAnswer",
+            "content": {
+                "sat_courseware_testid": item.sat_courseware_testid,
+                "sat_courseware_testitemsid": item.sat_courseware_testitemsid,
+                "answer": e.detail
+            }
+        }, false);
+    },
+    submit() {
+        if (this.data.loading) return;
+        let that = this;
+        wx.showModal({
+            title: '提示',
+            content: '一旦提交则无法修改,是否确认提交试卷',
+            complete: ({
+                confirm
+            }) => {
+                if (confirm) {
+                    that.setData({
+                        loading: true
+                    })
+                    _Http.basic({
+                        "accesstoken": "305def8607e623c06f118e94adcebaf1",
+                        "classname": "saletool.courseware.coursewaretest",
+                        "method": "testSubmit",
+                        "content": {
+                            sat_courseware_testid: that.data.detail.sat_courseware_testid,
+                            sat_coursewareid: that.data.detail.sat_coursewareid
+                        }
+                    }).then(res => {
+                        console.log("交卷", res)
+                        that.setData({
+                            loading: false
+                        });
+                        wx.showToast({
+                            title: res.msg != '成功' ? res.msg : "提交成功",
+                            icon: "none"
+                        });
+                        if (res.msg == '成功') that.setData({
+                            detail: res.data,
+                            dataShow: true
+                        })
+                    })
+                }
+            }
+        })
+    },
+    closeShowData() {
+        this.setData({
+            dataShow: false
+        })
+    },
+    onReady() {
+
+    },
+})

+ 7 - 0
pages/exam/detail.json

@@ -0,0 +1,7 @@
+{
+    "usingComponents": {
+        "van-checkbox": "@vant/weapp/checkbox/index",
+        "van-checkbox-group": "@vant/weapp/checkbox-group/index"
+    },
+    "navigationBarTitleText": "试卷"
+}

+ 247 - 0
pages/exam/detail.scss

@@ -0,0 +1,247 @@
+.head {
+    width: 100vw;
+    padding: 20rpx 30rpx;
+    background-color: #fff;
+    box-sizing: border-box;
+    margin-bottom: 20rpx;
+
+    .title {
+        display: flex;
+        justify-content: space-between;
+
+        .text {
+            width: 86% !important;
+            font-size: 32rpx;
+            font-family: PingFang SC-Bold, PingFang SC;
+            font-weight: bold;
+            color: #333333;
+        }
+    }
+
+    .exp {
+        display: flex;
+        align-items: center;
+        font-size: 20rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #999999;
+        margin-top: 10rpx;
+
+        .line-1 {
+            padding-right: 50rpx;
+            max-width: 230rpx;
+        }
+    }
+
+    .bottom {
+        display: flex;
+        justify-content: space-between;
+        height: 34rpx;
+        margin-top: 20rpx;
+
+        .left {
+            font-size: 24rpx;
+            font-family: PingFangSC-Regular-, PingFangSC-Regular;
+            font-weight: normal;
+            color: #333333;
+        }
+
+        .right {
+            font-size: 24rpx;
+            font-family: PingFangSC-Regular-, PingFangSC-Regular;
+            font-weight: normal;
+            color: #3874F6;
+        }
+    }
+}
+
+.item {
+    background-color: #fff;
+    width: 100vw;
+    box-sizing: border-box;
+    padding: 10rpx 30rpx;
+
+    .question {
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #333333;
+        margin-bottom: 10rpx;
+    }
+
+    .custom-class {
+        padding: 10rpx 0 !important;
+    }
+
+    .label-class {
+        font-size: 28rpx;
+        font-family: PingFangSC-Regular-, PingFangSC-Regular;
+        font-weight: normal;
+        color: #888888;
+        width: 100%;
+    }
+}
+
+.but-box {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    height: 130rpx;
+    width: 100vw;
+
+    .but {
+        width: 500rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 45rpx;
+        border: 0 !important;
+    }
+}
+
+.grid {
+    display: flex;
+    margin-top: 30rpx;
+
+    >view {
+        position: relative;
+        flex: 1;
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+
+        .title {
+            line-height: 34rpx;
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+        }
+
+        .count {
+            margin-top: 10rpx;
+            line-height: 40rpx;
+            width: 28rpx;
+            font-size: 28rpx;
+            font-family: PingFang SC-Medium, PingFang SC;
+            font-weight: 500;
+            color: #3874F6;
+        }
+    }
+
+    >view::before {
+        content: "";
+        position: absolute;
+        width: 1px;
+        height: 60rpx;
+        background-color: #DDDDDD;
+        right: 0;
+        top: 10rpx;
+        opacity: .6;
+    }
+
+    >view:last-child::before {
+        opacity: 0;
+    }
+}
+
+.popup {
+    position: relative;
+    width: 480rpx;
+    height: 750rpx;
+    border-radius: 50% !important;
+
+    image {
+        position: absolute;
+        width: 176rpx;
+        height: 176rpx;
+        top: -40rpx;
+        left: 152rpx;
+    }
+
+    .filter {
+        position: absolute;
+        left: 152rpx;
+        top: 130rpx;
+        width: 176rpx;
+        height: 22rpx;
+        background: rgba(227, 55, 17, 0.15);
+        filter: blur(6.4338297843933105px);
+    }
+
+    .main {
+        width: 360rpx;
+        margin: 0 auto;
+        padding-top: 192rpx;
+        box-sizing: border-box;
+
+        .label {
+            text-align: center;
+            line-height: 40rpx;
+            font-size: 28rpx;
+            font-family: Source Han Sans SC-Normal, Source Han Sans SC;
+            color: #222222;
+        }
+
+        .data-statis {
+            display: flex;
+            justify-content: space-between;
+            height: 130rpx;
+            width: 100%;
+            margin-top: 40rpx;
+            border-bottom: 1rpx solid #ddd;
+            box-sizing: border-box;
+
+            >view {
+                flex: 1;
+                text-align: center;
+
+                .count {
+                    line-height: 44rpx;
+                    font-size: 32rpx;
+                    font-family: PingFang HK-Medium, PingFang HK;
+                    font-weight: 500;
+                }
+
+                .name {
+                    line-height: 36rpx;
+                    font-size: 26rpx;
+                    font-family: PingFang HK-Regular, PingFang HK;
+                    color: #666666;
+                    margin-top: 10rpx;
+                }
+            }
+        }
+
+        .analyse {
+            text-align: center;
+            margin-top: 36rpx;
+
+            >view {
+                line-height: 44rpx;
+                font-size: 28rpx;
+                font-family: PingFang HK-Regular, PingFang HK;
+                font-weight: 400;
+                color: #666666;
+
+                text {
+                    font-size: 32rpx;
+                    font-family: PingFang HK-Medium, PingFang HK;
+                    font-weight: 500;
+                    color: #3874F6;
+                }
+            }
+        }
+
+        .but-box {
+            width: 100%;
+            text-align: center;
+            margin-top: 35rpx;
+
+            .but {
+                width: 320rpx;
+                height: 90rpx;
+                background: #FF5F3B;
+                border-radius: 45rpx;
+                color: #fff;
+            }
+        }
+    }
+}

+ 76 - 0
pages/exam/detail.wxml

@@ -0,0 +1,76 @@
+<view class="head">
+    <view class="title">
+        <view class="text">
+            {{detail.title}}
+        </view>
+        <van-tag color="#FA8C16">{{detail.status}}</van-tag>
+    </view>
+    <view class="exp">
+        <text class="line-1">发布人: --</text>
+        <text>发布时间:{{detail.createdate}}</text>
+    </view>
+    <view class="bottom" wx:if="{{detail.status=='未完成'}}">
+        <view class="left">试卷总分:{{detail.totalscore}}</view>
+        <view class="right">
+            答题进度:{{count.length||0}} / {{detail.testitems.length}}
+        </view>
+    </view>
+    <view wx:else class="grid">
+        <view>
+            <view class="title">答对题数</view>
+            <view class="count">{{detail.rightcount}}</view>
+        </view>
+        <view>
+            <view class="title">答错题数</view>
+            <view class="count">{{detail.errcount}}</view>
+        </view>
+        <view>
+            <view class="title">成绩(分)</view>
+            <view class="count">{{detail.score}}</view>
+        </view>
+    </view>
+</view>
+
+<view class="item" wx:for="{{detail.testitems}}" wx:key="sat_courseware_testitemsid">
+    <view class="question">
+        <text wx:if="{{detail.status=='未完成'}}">{{item.question}}</text>
+        <text wx:else style="{{item.result==1?'':'color:var(--error);'}}">{{item.question}}</text>
+    </view>
+    <van-checkbox-group disabled='{{detail.status=="已完成"}}' value="{{ item.answer }}" data-item="{{item}}" data-index="{{index}}" bind:change="groupOnChange">
+        <van-checkbox wx:for="{{item.options}}" wx:for-item="it" wx:key="option" name="{{it.option}}" shape='square' icon-size='14' custom-class='custom-class' label-class='label-class'>
+            <text wx:if="{{detail.status=='未完成'}}">{{it.content}}</text>
+            <text wx:else style="{{it.isfact==0?'text-decoration:line-through;':''}};color:{{item.result==0?it.isfact==0?'var(--error)':'var(--success)':''}}">{{it.content}}</text>
+        </van-checkbox>
+    </van-checkbox-group>
+</view>
+
+<view class="but-box" wx:if="{{detail.status!='已完成'}}">
+    <van-button custom-class='but' disabled='{{count.length!=detail.testitems.length}}' loading="{{loading}}" loading-text="提交中..." type="primary" bindtap="submit">提交试卷</van-button>
+</view>
+
+<van-popup show="{{ dataShow }}" custom-style='overflow: visible;  border-radius: 16rpx;' bind:close="onClose">
+    <view class="popup">
+        <image src="/static/image/exam3.png" mode="aspectFill" />
+        <view class="filter" />
+        <view class="main">
+            <view class="label">考试结果</view>
+            <view class="data-statis">
+                <view>
+                    <view class="count" style="color: #FF3B30;">{{detail.score}}</view>
+                    <view class="name">成绩(分)</view>
+                </view>
+                <view>
+                    <view class="count" style="color: #3874F6;">{{detail.testitems.length}}</view>
+                    <view class="name">总题数</view>
+                </view>
+            </view>
+            <view class="analyse">
+                <view>答对<text style="color: #52C41A;">{{detail.errcount||"0"}}</text>题</view>
+                <view style="margin-top: 20rpx;">答错<text style="color: #FF3B30; ">{{detail.rightcount||"0"}}</text>题</view>
+            </view>
+            <view class="but-box">
+                <van-button custom-class='but' bindtap="closeShowData">确定</van-button>
+            </view>
+        </view>
+    </view>
+</van-popup>

+ 80 - 0
pages/exam/index.js

@@ -0,0 +1,80 @@
+const getHeight = require("../../utils/getRheRemainingHeight"),
+    _Http = getApp().globalData.http;
+Page({
+    data: {
+        "content": {
+            "pageNumber": 1,
+            pageTotal: 1,
+            "pageSize": 20,
+            "sat_coursewareid": 0,
+            "where": {
+                "status": "未完成"
+            }
+        }
+    },
+    onLoad(options) {
+        this.getList()
+    },
+    getList(init = false) {
+        if (init.detail != undefined) init = init.detail;
+        let content = this.data.content;
+        if (init) content.pageNumber = 1;
+        if (content.pageNumber > content.pageTotal) return;
+        _Http.basic({
+            "classname": "saletool.courseware.coursewaretest",
+            "method": "queryTestList",
+            content
+        }).then(res => {
+            console.log("试卷列表", res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            })
+            content.pageNumber = res.pageNumber + 1;
+            content.pageTotal = res.pageTotal;
+            this.setData({
+                list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
+                total: res.total
+            })
+        })
+    },
+    onSearch({detail}) {
+        this.data.content.where.condition = detail;
+        this.getList(true);
+    },
+    startTest(e) {
+        const {
+            sat_coursewareid
+        } = e.currentTarget.dataset;
+        _Http.basic({
+            "classname": "saletool.courseware.coursewaretest",
+            "method": "createTest",
+            "content": {
+                sat_coursewareid
+            }
+        }).then(res => {
+            console.log("开始考试", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            })
+            this.getList(true);
+            wx.navigateTo({
+                url: '/pages/exam/detail?id=' + res.data.sat_courseware_testid,
+            })
+        })
+    },
+    tabChange(e) {
+        this.data.content.where.status = e.detail.title;
+        this.getList(true)
+    },
+    onReady() {
+        //滚动区域高度
+        getHeight.getHeight('.head', this).then(res => {
+            this.setData({
+                scrollHeight: res
+            })
+        })
+    },
+})

+ 4 - 0
pages/exam/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "考试中心"
+}

+ 54 - 0
pages/exam/index.scss

@@ -0,0 +1,54 @@
+page {
+    height: 100vh;
+    overflow: hidden;
+}
+
+.unread {
+    height: 64rpx;
+    line-height: 64rpx;
+    padding-left: 30rpx;
+    font-size: 24rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #666666;
+}
+
+.item {
+    background-color: #fff;
+    margin-bottom: 20rpx;
+
+    .top {
+        padding: 20rpx 30rpx;
+        box-sizing: border-box;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #333333;
+        border-bottom: 1rpx solid #ddd;
+
+        .time {
+            display: flex;
+            justify-content: space-between;
+            height: 34rpx;
+            font-size: 24rpx;
+            font-weight: normal;
+            color: #888888;
+            margin-top: 20rpx;
+        }
+    }
+
+    .bottom {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        width: 100vw;
+        height: 90rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #5C5C5C;
+
+        image {
+            height: 40rpx;
+            margin-right: 10rpx;
+        }
+    }
+}

+ 35 - 0
pages/exam/index.wxml

@@ -0,0 +1,35 @@
+<van-search shape="round" background="#085CDF" placeholder="请输入搜索关键词" bind:search='onSearch' bind:clear='onSearch' />
+<van-tabs sticky title-active-color='var(--assist)' color='var(--assist)' bind:change="tabChange">
+    <van-tab title="未完成" />
+    <van-tab title="已完成" />
+</van-tabs>
+<view class="head" style="height: 20rpx;" />
+
+<!-- 列表 -->
+<My_listBox id='ListBox' height='{{scrollHeight}}' bind:getlist='getList'>
+    <view class="item" wx:for="{{list}}" wx:key="sat_courseware_testid">
+        <view class="top">
+            <view>
+                {{item.title}}
+            </view>
+            <view class="time">
+                考试时间:{{item.submitdate || " --"}}
+                <van-tag wx:if="{{item.status=='未完成'}}" type="warning">未完成</van-tag>
+                <view wx:else>
+                    成绩(分):<text style="color: #3874F6;">{{item.score}}</text>
+                </view>
+            </view>
+        </view>
+        <view wx:if="{{item.status=='未完成'}}" class="bottom" hover-class="navigator-hover" data-sat_coursewareid="{{item.sat_coursewareid}}" bindtap="startTest">
+            <image src="/static/image/exam2.png" mode="heightFix" /> 进入考试
+        </view>
+
+        <navigator url="/pages/exam/detail?id={{item.sat_courseware_testid}}&readOnly=true" wx:else class="bottom">
+            <image src="/static/image/exam1.png" mode="heightFix" /> 查看试卷
+        </navigator>
+    </view>
+    <My_empty wx:if="{{!list.length}}" />
+    <view style="height: 40px;" />
+</My_listBox>
+
+<!--  -->

+ 6 - 0
pages/tabbar/home/index.js

@@ -120,6 +120,12 @@ Page({
                     subassembly: []
                 })
             }
+            gridList.push({
+                name: "考试",
+                path: "/pages/exam/index",
+                icon: "icon-xiaochengxu_xiaoshoumubiao",
+                apps: {}
+            })
             this.setData({
                 gridList,
                 subassembly

+ 2 - 1
project.config.json

@@ -48,7 +48,8 @@
         "disableUseStrict": false,
         "useCompilerPlugins": [
             "sass"
-        ]
+        ],
+        "condition": false
     },
     "compileType": "miniprogram",
     "libVersion": "2.19.4",

+ 21 - 0
project.private.config.json

@@ -98,6 +98,27 @@
                     "query": "id=1617&type=1",
                     "launchMode": "default",
                     "scene": null
+                },
+                {
+                    "name": "商学院",
+                    "pathName": "pages/classroom/index",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "商学院详情",
+                    "pathName": "pages/classroom/detail",
+                    "query": "id=106",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "考试中心",
+                    "pathName": "pages/exam/index",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
                 }
             ]
         }

BIN
static/image/exam1.png


BIN
static/image/exam2.png


BIN
static/image/exam3.png


+ 2 - 1
utils/Http.js

@@ -1,4 +1,5 @@
-const baseUrl = "https://meida.cnyunl.com/yos/rest/index";
+// const baseUrl = "https://meida.cnyunl.com/yos/rest/index";
+const baseUrl = "http://192.168.3.111:8100/yos/rest/index";
 class HTTP {
     request({
         url,