微信小程序(评教系统--教师列表,评教方式,评教问题)

评教中,当学生陆后显示需要评教的教师列表,选择评教老师,再选择是常规评教还是统一评教,进入后选择每道题目所选的选项提交后得到总分数。流程如下:

微信小程序(评教系统--教师列表,评教方式,评教问题)_第1张图片微信小程序(评教系统--教师列表,评教方式,评教问题)_第2张图片微信小程序(评教系统--教师列表,评教方式,评教问题)_第3张图片微信小程序(评教系统--教师列表,评教方式,评教问题)_第4张图片

教师列表:再建一个teacher目录,分别写js和wxml:

wxml中:用wx:for循环teachers,分别取teachers中用到的数据,用{{item.name}},等显示


教师列表

  
    
   
    
      {{item.teachername}}
    
     
       {{item.course}} 
     
   
 

js中:调用teachers接口,读取学生缓存,根据classid参数,存储teachers中的数据

 

// pages/teachers/teachers.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
  //页面的变量存放位置
  teachers: null,
  src: '../images/9.jpg'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  // var url = "https://www.lishuming.top/pj/index.php/student/api/teachers";
    var url = app.globalData.url.teachers;
  //读取缓存
  var student = wx.getStorageSync('student');
  // console.log(student);
  var classid = student.classid;
  // console.log(classid);
  wx.request({
    url:url,
    data:{
      classid:classid
    },
    header: {
      'content-type': 'application/json' // 默认值
    },
    success:(res)=> {
      console.log(res.data)
      this.setData({teachers:res.data});
    }
  })
  },
  selectTeacher: function (e) {
    var teacherid = e.currentTarget.dataset.teacherid;
    wx.navigateTo({
      url: '../testpaper/testpaper?teacherid=' + teacherid,
    })
  }
})

评教方式:再建一个testpaper目录,分别写js和wxml:调用testpaper接口,

// pages/testpaper/testpaper.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    src:'../images/9.jpg',
    teacher:null,
    testpaper:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // var url = "https://www.lishuming.top/pj/index.php/student/api/testpaper";
    var url = app.globalData.url.testpaper;
    var teacherid = options.teacherid;
    // console.log(teacherid);
    wx.request({
      url: url,
      data:{
        teacherid:teacherid
      },
      header:{
        'content-type': 'application/json'
      },
      success: (res) => {
        console.log(res.data);
        this.setData({
          testpaper: res.data.testpaper,
          teacher: res.data.teacher
        });
      }
    })
  },
  selectTeacher: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../paperdetails/paperdetails?id=' + id,
    })
  }
})

wxml中:循环testpaper数组,取用到的数据


  
    {{teacher.name}}
    
      {{teacher.sex}}
      {{teacher.zhicheng}}
    
  
  
    
   



  
    
      {{item.type}}
      {{item.start}}至{{item.end}}
    
      {{item.name}} 
  

再建一个paperdetails目录写题目的js和wxml:

js中:调用paperdetails,pj接口,代码及解释如下:

// pages/paperdetails/paperdetails.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentid:0,
    count:0,
    pj:null,
    testpaperid:null,
    paperdetails:null,
    teachername:null,
    message:'',
    answer:{},
    score:{},
    student:{},
    btn_disabled:true,
    show_swiper:true,
    show_message:false
  },
  change:function(e){
    console.log(e);
    if(e.detail.source=='touch'){
      this.setData({currentid:e.detail.current})
    }
  },
// 写留言
write_message:function(e){
  // console.log(e.detail.value);
  this.setData({message:e.detail.value})
},
// 到下一题
  next:function(e){
    var index = this.data.currentid;
    index++;
    if(index>=this.data.count){
      index=this.data.count-1;
    }
    this.setData({currentid:index});
  },
// 选中选项
  radioChange:function(e){
  //获取选项及对应分值  
    var value = e.detail.value;//选项及分数
    // console.log(value);
    var id = e.currentTarget.dataset.id;//题目id
    // console.log(id);
    var arr = value.split("#");//分割字符串
    // console.log(arr);
    var _answer = this.data.answer;//题目id对应的选项
    _answer[id] = arr[0];
    // console.log(_answer);
    var _score = this.data.score;//题目id及对应的选项分数
    _score[id] = arr[1];
    // console.log(_score);
    this.setData({answer:_answer,
                  score: _score
    });

    var len = 0;
    for(var i in _answer){
      len++;
    }
    if(len{
      console.log(res.data);
      wx.showToast({
        title: res.data[0],
        icon: 'success',
        duration: 2000,
        success: function () {
          setTimeout(function () {
            wx.navigateBack({
              delta: 1
            })
          }, 2000)
        }
      })
    }
  })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // var url = "https://www.lishuming.top/pj/index.php/student/api/paperdetails";
    var url = app.globalData.url.paperdetails;
    var id = options.id;
    // consol.log(id);
    //读取缓存
    var no = wx.getStorageSync('student').no;
    wx.request({
      url: url,
      data: {
        // no:1635050238,
        no:no,
        id:id
      },
      header: {
        'content-type': 'application/json'
      },
      success: (res) => {
        console.log(res.data);
        if(res.data.error){
          wx.showToast({
            title: res.data.errormsg,
            icon:'none',
            duration:2000,
            success:function(){
              setTimeout(function(){
                wx.navigateBack({
                  delta:1
                })
              }, 2000)
            }
          })
        }else{ 
          this.setData({
            show:true,
            pj:res.data.pj,
            paperdetails: res.data.data,
            teachername: res.data.pj.teachername,
            count:res.data.data.length
          });
        }
      }
    })
  },
})

wxml中:




  被评老师:{{teachername}}

{{index+1}}.{{item.content}}






你可能感兴趣的:(微信小程序(评教系统--教师列表,评教方式,评教问题))