IESM project training IX
After the teacher enters the grades, click OK to submit the course grades to the temporary student grade bank. The course transcript cannot be modified after submission.
Teachers submit scores
Front end components:
<div class="table-operator"> <a-button type="primary" @click="updateScoresPercent" >Set score entry parameters</a-button> <a-button type="primary" @click="submitList">Confirm submission</a-button> <a-button type="primary" @click="" >Modify course grade application</a-button> </div>
Button response event:
It is initially set as a fixed teacher information, which will be replaced later.
submitList:function (){ //let tea_id='200799013568'; let tea_id='201154101146'; let tea_name='Dongdawei'; this.chooseLesson=true; this.getLessonList(); if(this.inputState==="Submitted"){ alert("The course grade has been submitted,Duplicate submission is not allowed"); }else { // if(this.inputId===""||this.inputState=== "not submitted"){ 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("Successful submission of academic achievements"); }else{ this.$message.warning("Failed to submit the results to the educational administration!"); } }) } else { let index = res.result + 1; alert("Please check that the serial number is" + index + "Students' achievements" + "Correct!!!"); } }) } },
Backend code:
The corresponding URL method is defined in the ScoresController class. First, judge whether all student grades of the course have been entered. If not, return the first index that has not been entered. Otherwise, update the entry person, job number and entry time in the temporary class grade table.
@ResponseBody @RequestMapping(value = "/submitScoresList") public Result<Integer> submitScoresList(@RequestParam(name = "tea_id") String tea_id, @RequestParam(name = "tea_name") String tea_name) { //Record the input information Result<Integer> result = new Result<>(); int judgement = this.checkScoresList(); //Explain that the scores are all correct 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("student" + this.stuList.get(judgement).getStuName() + "Incorrect score entry"); } result.setResult(judgement); return result; }
Check whether all codes are entered. If the proportion is 0, the grade of this type can be blank.
//Check whether all scores are entered 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; }
Modify the database operation of temporary class grade list:
ScoresMapper.xml database operation
<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='Submitted' WHERE les_id = #{les_id} and les_ord=#{les_ord} </select>
interface ScoresMapper interface
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 interface
public boolean updateSubmitInfo(String submit_time, String input_id, String input_name, String cs_id, String les_ord);
ScoresServiceImpl implementation
@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; }
Enter student scores into the temporary student grade library as follows:
The data timestamp is similar to the score submission time. In the later stage, you can query the history of the corresponding entry time according to the timestamp.
@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); }
When entering the temporary library, you need to calculate the student's grade point and grade level of the course.
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("Percentage system")){ temp=scores; }else if(scores_type.equals("Rating system")){ if(scores.equals("excellent")){ temp=95+""; }else if(scores.equals("good")){ temp=85+""; }else if(scores.equals("in")){ temp=75+""; }else if(scores.equals("pass")){ temp=65+""; }else if(scores.equals("fail,")){ temp=55+""; } } return temp;
The educational administration end cancels the newly submitted course scores
Revoking will not delete the existing student scores, but only modify the score entered by, job No. and entry time of the course, so that teachers can submit scores again. The original submission record shall be stored in the submission record form.
Front end components:
<a @click="undoSubmitRecord(record)">revoke</a>
Button event response:
First, judge whether the course has been submitted to the master library. If it has been submitted to the master library, the operation cannot be performed. After modification, the list data will be refreshed in real time.
undoSubmitRecord(record){ getAction(this.url.lessonExit,{les_id: record.lesId, les_ord: record.lesOrd,les_sem:record.lesSem}).then((res)=>{ if(res.result==="Courses have been submitted to the master library"){ this.$message.success("Courses have been submitted to the master library,The operation cannot be performed!"); }else{ if (record.inputState == "Not submitted" || record.inputState == '') { alert("The course score has not been submitted. You cannot withdraw it!"); } 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 = "Not submitted"; this.superFieldList[i].inputName = ""; this.superFieldList[i].inputId = ""; this.superFieldList[i].submitTime = ""; this.dataSource = this.superFieldList; this.$message.success("Undo operation succeeded!"); } } }) } } }) console.log(this.optionJudge); },
Corresponding method of backend URL:
AllScoresController determines whether the course has been submitted to the master library:
@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("Course not submitted to master library"); }else{ return Result.OK("Courses have been submitted to the master library"); } }
AllScoresMapper.xml database statement
<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 interface
public List<AllScores> getLessonExit(@Param("les_id")String les_id, @Param("les_ord")String les_ord, @Param("les_sem")String les_sem);
interface IAllScoresService interface
public List<AllScores> getLessonExit(String les_id, String les_ord, String les_sem);
AllScoresServiceImpl interface implementation
@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 modifies the record and puts the original record into the history submission record table.
@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); //Delete the original record and insert a new one, which is no longer the same as the original record this.delete(temporaryScores.getId()); temporaryScores.setInputId(null); temporaryScores.setInputName(null); temporaryScores.setId(null); temporaryScores.setSubmitTime(null); temporaryScores.setCreateTime(null); temporaryScores.setInputState("Not submitted"); temporaryScoresService.save(temporaryScores); return Result.OK("Cancellation succeeded!"); } //Copy the original record information to the history object 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("Submitted"); 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 insert history table and obtain revoked course information database operations:
<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 interface
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 interface
public void insertSubmitInfo(SubmitRecord s); public List<TemporaryScores> getLessonInfo(String les_id,String les_ord);
TemporaryScoresServiceImpl interface implementation
@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; }