IESM项目实训九——成绩提交和教务撤销

IESM项目实训九

在教师录入成绩完成后,点击确认提交将本课程成绩提交至临时学生成绩库。提交后该课程成绩表不可再进行修改。
在这里插入图片描述

教师提交成绩

前端组件:

<div class="table-operator">
     <a-button type="primary" @click="updateScoresPercent" >设置成绩录入参数</a-button>
     <a-button type="primary"  @click="submitList">确认提交</a-button>
     <a-button type="primary" @click="" >修改课程成绩申请</a-button>
</div>

按钮响应事件:
初步设置为某位固定教师信息,后期进行替换。

  submitList:function (){
      //let tea_id='200799013568';
      let tea_id='201154101146';
      let tea_name='董大伟';
      this.chooseLesson=true;
      this.getLessonList();
      if(this.inputState==="已提交"){
        alert("该课程成绩已提交,不可进行重复提交");
      }else {
        // if(this.inputId===""||this.inputState==="未提交") {
          getAction(this.url.submitScoresList, {tea_id: tea_id, tea_name: tea_name}).then((res) => {
            if (res.result === -1) {
              getAction(this.url.insertStuList, {cs_id: this.csId, les_ord: this.lesOrd,usual_percent:this.usualPercent,test_percent:this.testPercent,scores_type:this.scoresTypeValue}).then((re) => {
                if(re.result===true){
                  alert("成绩提交教务成功");
                }else{
                  this.$message.warning("成绩提交教务失败!");
              }
              })
            } else {
              let index = res.result + 1;
              alert("请检查序号为" + index + "同学的成绩" + "是否正确!!!");
            }
          })
        }

    },

后端代码:
ScoresController类中定义URL对应方法,先判断该课程是否所有学生成绩已录入,如果没有则返回未录入的第一个索引,否则更新临时班级成绩表中的录入人,工号和录入时间。

 @ResponseBody
    @RequestMapping(value = "/submitScoresList")
    public Result<Integer> submitScoresList(@RequestParam(name = "tea_id") String tea_id, @RequestParam(name = "tea_name") String tea_name) {
        //记录录入人信息
        Result<Integer> result = new Result<>();
        int judgement = this.checkScoresList();
        //说明成绩全部正确
        if (judgement == -1) {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date(System.currentTimeMillis());
            String d = formatter.format(date);
            scoresService.updateSubmitInfo(d, tea_id, tea_name, this.temporaryScores.getLesId(), this.temporaryScores.getLesOrd());
        } else {
            result.setMessage("学生" + this.stuList.get(judgement).getStuName() + "成绩录入有误");
        }
        result.setResult(judgement);
        return result;
    }

检查代码是否全部录入,如果比例为0,则该类型成绩可以为空。

//检查成绩是否全部录入
    public int checkScoresList() {
        int judgement = -1;
        double test_percent = this.temporaryScores.getTestPercent();
        double usual_percent = this.temporaryScores.getUsualPercent();
        for (int i = 0; i < this.stuList.size(); i++) {
            Scores temp = this.stuList.get(i);
            if (test_percent != 0 && usual_percent != 0) {
                if (temp.getExamScores() == null || temp.getTestScores() == null || temp.getUsualScores() == null) {
                    judgement = i;
                    break;
                }
            } else if (test_percent == 0 && usual_percent != 0) {
                if (temp.getExamScores() == null || temp.getUsualScores() == null) {
                    judgement = i;
                    break;
                }
            } else if (usual_percent == 0 && test_percent != 0) {
                if (temp.getExamScores() == null || temp.getTestScores() == null) {
                    judgement = i;
                    break;
                }
            } else if (test_percent == 0 && usual_percent == 0) {
                if (temp.getExamScores() == null) {
                    judgement = i;
                    break;
                }
            }
        }
        return judgement;
    }

修改临时班级成绩列表的数据库操作:
ScoresMapper.xml数据库操作

    <select id="updateSubmitInfo"  resultType="org.jeecg.modules.demo.ScoresInput.entity.TemporaryScores">
        update temporary_scores
        set input_id=#{input_id},
        input_name=#{input_name},
        submit_time=#{submit_time},
        input_state='已提交'
        WHERE
            les_id = #{les_id} and les_ord=#{les_ord}
    </select>

interface ScoresMapper接口

     public void updateSubmitInfo(@Param("submit_time") String submit_time,
                                 @Param("input_id" )String input_id,
                                 @Param("input_name" )String input_name,
                                 @Param("les_id") String cs_id,
                                 @Param("les_ord") String les_ord);

interface IScoresService接口

    public boolean updateSubmitInfo(String submit_time, String input_id, String input_name, String cs_id, String les_ord);

ScoresServiceImpl实现

@Override
    @Transactional
    public boolean updateSubmitInfo(String submit_time,String input_id, String input_name, String cs_id, String les_ord){
        scoresMapper.updateSubmitInfo(submit_time,input_id,input_name,cs_id,les_ord);
        return true;
    }

将学生成绩录入临时学生成绩库如下:
数据时间戳近似于成绩提交时间,后期按照时间戳可以查询对应录入时间的历史记录。

@ResponseBody
   @RequestMapping("/insertStuList")
   public Result<Boolean> insertStuList(@RequestParam(name="cs_id")String cs_id,
                                       @RequestParam(name="les_ord")String les_ord,
                                       @RequestParam(name="usual_percent")int usual_percent,
                                       @RequestParam(name="test_percent")int test_percent,
                                       @RequestParam(name="scores_type")String scores_type){
       List<Scores> stuList =temporaryStuScoresService.getStuList(cs_id,les_ord);
       List<TemporaryStuScores> temporaryStuScoresList=new ArrayList<>();
       for(int i=0;i<stuList.size();i++) {
           Scores s=stuList.get(i);
           String tempNum=scoresTypeToNum(scores_type,s.getScores());
           double gpa=getTempGPA(tempNum);
           String gpaLevel=getGpaLevel(tempNum);
           TemporaryStuScores temporaryStuScores = new TemporaryStuScores();
           temporaryStuScores.setScores(s.getScores());
           temporaryStuScores.setExamScores(s.getExamScores());
           double temp=(s.getUsualScores()*usual_percent*0.01+s.getTestScores()*test_percent*0.01)/((usual_percent+test_percent)*0.01);
           int usualScores=(int)ScoresController.myround(temp);
           temporaryStuScores.setUsualScores(usualScores);
           temporaryStuScores.setStuName(s.getStuName());
           temporaryStuScores.setGpa(gpa);
           temporaryStuScores.setGpaLevel(gpaLevel);
           temporaryStuScores.setStuId(s.getStuId());
           temporaryStuScores.setLesId(s.getCsId());
           temporaryStuScores.setLesOrd(s.getLesOrd());
           temporaryStuScores.setSchSem(s.getCsSem());
           temporaryStuScoresList.add(temporaryStuScores);
       }
       temporaryStuScoresService.saveBatch(temporaryStuScoresList);
       return Result.OK(true);

   }

录入临时库时,需要计算学生该课程的绩点和绩点水平等级。

private static double getTempGPA(String scores) {
       int x=Integer.parseInt(scores);
        double temp=0;
        if(x>=90 && x<100){
            temp = 4.0;
            temp=temp+x%10*0.1;
        }
        else if(x==100){
            temp=5.0;
            temp=temp+x%10*0.1;
        }
        else if(x>=80 && x<=89){
            temp = 3.0;
            temp=temp+x%10*0.1;
        }
        else if(x>=70 && x<=79){
            temp = 2.0;
            temp=temp+x%10*0.1;
        }
        else if(x>=60 && x<=69){
            temp = 1.0;
            temp=temp+x%10*0.1;
        }
        else if(x<60)
            temp = 0;

        return temp;
    }


    private String getGpaLevel(String scores){
        int x=Integer.parseInt(scores);
        String temp="";
        if(x>=95 && x<100)
            temp = "A+";
        else if(x>=90&&x<95)
            temp="A";
        else if(x>=85 && x<=89)
            temp = "A-";
        else if(x>=82 && x<85)
            temp ="B+";
        else if(x>=78 && x<82){
            temp="B";
        }else if(x>=75 && x<78){
            temp="B-";
        }
        else if(x>=71 && x<75){
            temp="C+";
        }
        else if(x>=66 && x<71){
            temp="C";
        }
        else if(x>=62 && x<66){
            temp="C-";
        }
        else if(x>=60 && x<62){
            temp="D";
        }else{
            temp="E";
        }

        return temp;
    }

    public static  String scoresTypeToNum(String scores_type,String scores){
       String temp="";
       if(scores_type.equals("百分制")){
           temp=scores;

       }else if(scores_type.equals("评级制")){
           if(scores.equals("优")){
               temp=95+"";
           }else if(scores.equals("良")){
               temp=85+"";
           }else if(scores.equals("中")){
               temp=75+"";
           }else if(scores.equals("及格")){
               temp=65+"";
           }else if(scores.equals("不及格")){
               temp=55+"";
           }
       }
        return temp;

教务端撤销最新提交的课程成绩

撤销不会删除已存在的学生成绩,只将该课程录入成绩人、工号和录入时间修改,使教师可以再次提交成绩。原提交记录存入提交记录表中。
在这里插入图片描述

前端组件:

 <a @click="undoSubmitRecord(record)">撤销</a>

按钮事件响应:
首先判断该课程是否已提交至总库,如果提交至总库则不可进行该操作,修改后实时刷新列表数据。

undoSubmitRecord(record){
        getAction(this.url.lessonExit,{les_id: record.lesId, les_ord: record.lesOrd,les_sem:record.lesSem}).then((res)=>{
          if(res.result==="课程已经提交至总库"){
            this.$message.success("课程已经提交至总库,不可执行该操作!");
          }else{
              if (record.inputState == "未提交" || record.inputState == '') {
                alert("该课程成绩未提交,不能执行撤回操作!");
              } else {
                this.superFieldList = this.dataSource;
                getAction(this.url.undoSubmitRecord, {les_id: record.lesId, les_ord: record.lesOrd}).then((res) => {
                  for (let i = 0, len = this.dataSource.length; i < len; i++) {
                    const element = this.dataSource[i];
                    if (element.id === record.id) {
                      this.superFieldList[i].inputState = "未提交";
                      this.superFieldList[i].inputName = "";
                      this.superFieldList[i].inputId = "";
                      this.superFieldList[i].submitTime = "";
                      this.dataSource = this.superFieldList;
                      this.$message.success("撤销操作成功!");
                    }
                  }
                })
            }
          }
        })
        console.log(this.optionJudge);
      },

后端URL对应方法:
AllScoresController判断该课程是否已经提交总库:

 @GetMapping(value ="lessonExit")
   public Result<?> lessonExit(@RequestParam(name = "les_id") String les_id, @RequestParam(name = "les_ord") String les_ord,@RequestParam(name="les_sem")String les_sem){
       List<AllScores> exit=allScoresService.getLessonExit(les_id,les_ord,les_sem);
       if(exit.size()==0) {
           return Result.OK("课程未提交至总库");
       }else{
           return Result.OK("课程已经提交至总库");
       }
   }

AllScoresMapper.xml数据库语句

<select id="getLessonExit" parameterType="java.lang.String" resultType="org.jeecg.modules.demo.ScoresInput.entity.AllScores">-->
    SELECT *
    FROM all_scores
    where   les_id = #{les_id} and les_ord=#{les_ord} and les_sem=#{les_sem}
    </select>

AllScoresMapper接口

    public List<AllScores> getLessonExit(@Param("les_id")String les_id, @Param("les_ord")String les_ord, @Param("les_sem")String les_sem);

interface IAllScoresService接口

    public List<AllScores> getLessonExit(String les_id, String les_ord, String les_sem);

AllScoresServiceImpl接口实现

	@Override
    @Transactional
    public List<AllScores> getLessonExit(String les_id, String les_ord, String les_sem){
        List<AllScores> list;
        list=allScoresMapper.getLessonExit(les_id,les_ord,les_sem);
        return list;
    }

TemporaryScoresController将记录修改,并将原记录放入历史提交记录表。

@RequestMapping(value="/undoSubmitRecord")
    public  Result<?> undoSubmitRecord(@RequestParam(name="les_id")String les_id,
                                       @RequestParam(name="les_ord")String les_ord){
       Result<Integer> result = new Result<>();
       List<TemporaryScores> temporaryScoresList=this.getLessonInfo(les_id,les_ord);
       TemporaryScores temporaryScores=temporaryScoresList.get(0);
       SubmitRecord submitRecord=new SubmitRecord();
       submitRecord=setASubmitRecord(temporaryScores);
       temporaryScoresService.insertSubmitInfo(submitRecord);
       //将原有的删除,插入新的,与原记录不再相同
       this.delete(temporaryScores.getId());
       temporaryScores.setInputId(null);
       temporaryScores.setInputName(null);
       temporaryScores.setId(null);
       temporaryScores.setSubmitTime(null);
       temporaryScores.setCreateTime(null);
       temporaryScores.setInputState("未提交");
       temporaryScoresService.save(temporaryScores);
       return Result.OK("撤销成功!");

    }

//复制原纪录信息至历史记录对象
	public static SubmitRecord setASubmitRecord(TemporaryScores temporaryScores){
       	SubmitRecord submitRecord=new SubmitRecord();
        submitRecord.setCreateTime(temporaryScores.getCreateTime());
        submitRecord.setId(temporaryScores.getId());
        submitRecord.setInputId(temporaryScores.getInputId());
        submitRecord.setInputName(temporaryScores.getInputName());
        submitRecord.setInputState("已提交");
        submitRecord.setSubmitTime(temporaryScores.getSubmitTime());
        submitRecord.setLesId(temporaryScores.getLesId());
        submitRecord.setLesOrd(temporaryScores.getLesOrd());
        submitRecord.setLesName(temporaryScores.getLesName());
        submitRecord.setTestPercent(temporaryScores.getTestPercent());
        submitRecord.setUsualPercent(temporaryScores.getUsualPercent());
        submitRecord.setLesSem(temporaryScores.getLesSem());
        submitRecord.setTeaId(temporaryScores.getTeaId());
        submitRecord.setTeaName(temporaryScores.getTeaName());
        submitRecord.setScoresType(temporaryScores.getScoresType());
        submitRecord.setCoursenum(temporaryScores.getCoursenum());
        System.out.println(submitRecord.getCoursenum());
        return submitRecord;

    }

TemporaryScoresMapper插入历史记录表和获取撤销的课程信息数据库操作:

	<select id="insertSubmitInfo"  resultType="org.jeecg.modules.demo.ScoresInput.entity.SubmitRecord">
        INSERT INTO submit_record
            (`id`, `les_id`, `les_name`, `les_sem`, `tea_id`, `tea_name`, `create_time`, `les_ord`, `input_name`, `input_id`, `input_state`, `usual_percent`, `test_percent`, `submit_time`,`coursenum`)
            VALUES
            (#{id}, #{les_id}, #{les_name}, #{les_sem}, #{tea_id}, #{tea_name}, #{create_time}, #{les_ord}, #{input_name}, #{input_id}, #{input_state}, #{usual_percent}, #{test_percent}, #{submit_time},#{coursenum})
    </select>
    <select id="getLessonInfo" parameterType="java.lang.String" resultType="org.jeecg.modules.demo.ScoresInput.entity.TemporaryScores">
        SELECT *
        FROM temporary_scores
        WHERE
            les_id = #{les_id} and les_ord=#{les_ord}
        ORDER BY create_time desc
    </select>
    

TemporaryScoresMapper接口

public void insertSubmitInfo(@Param("les_id") String les_id,
                                 @Param("id") String id,
                                 @Param("les_ord") String les_ord,
                                 @Param("les_name")String les_name,
                                 @Param("les_sem")String les_sem,
                                 @Param("input_name")String input_name,
                                 @Param("input_id")String input_id,
                                 @Param("input_state")String input_state,
                                 @Param("tea_name")String tea_name,
                                 @Param("tea_id")String tea_id,
                                 @Param("create_time")String create_time,
                                 @Param("submit_time")String submit_time,
                                 @Param("usual_percent") int usual_percent,
                                 @Param("test_percent") int test_percent,
                                 @Param("coursenum")int coursenum);
public List<TemporaryScores> getLessonInfo(@Param("les_id")String les_id,@Param("les_ord")String les_ord);

interface ITemporaryScoresService接口

    public void insertSubmitInfo(SubmitRecord s);
    public List<TemporaryScores> getLessonInfo(String les_id,String les_ord);

TemporaryScoresServiceImpl接口实现

	@Override
    @Transactional
    public void undoSubmitState(String les_id,String les_ord,String input_state){
        temporaryScoresMapper.undoSubmitState(les_id,les_ord,input_state);
    }
    @Override
    @Transactional
    public List<TemporaryScores> getLessonInfo(String les_id,String les_ord){
        List<TemporaryScores> list;
        list=temporaryScoresMapper.getLessonInfo(les_id,les_ord);
        return list;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值