public Boolean learnBad(int studentId, int courseId) { List <ChapterNode> chapterNodes = ChapterContentApi.findByCourseID(courseId); List <StudentChapter> studentChapters = StudentChapterApi.findByChapterIDBetweenAndStudentIDOrderByChapterIDDesc(chapterNodes[0].id, chapterNodes[chapterNodes.Count - 1].id, studentId); int?chapterId1 = 0; int?chapterId2 = 0; for (int i = 0; i < studentChapters.Count; i++) { if (studentChapters[i].comment != null) { chapterId1 = studentChapters[i].chapterID; chapterId2 = chapterId1; for (int j = i + 1; j < studentChapters.Count; j++) { if (studentChapters[j].comment != null) { chapterId2 = studentChapters[j].chapterID; break; } } break; } } if (chapterId1 == 0) { return(false); } List <StudentChapter> temp1 = StudentChapterApi.findByChapterID(chapterId1); List <int?> scores1 = new List <int?>(); foreach (StudentChapter i in temp1) { scores1.Add(i.totalScore_2); } List <StudentChapter> temp2 = StudentChapterApi.findByChapterID(chapterId2); List <int?> scores2 = new List <int?>(); foreach (StudentChapter i in temp2) { scores2.Add(i.totalScore_2); } //fragile scores1.Sort(); scores2.Sort(); if (scores1[(int)(0.4 * temp1.Count)] > StudentChapterApi.findByChapterIDAndStudentID(chapterId1, studentId).totalScore_2&& scores2[(int)(0.4 * temp2.Count)] > StudentChapterApi.findByChapterIDAndStudentID(chapterId2, studentId).totalScore_2) { return(true); } return(false); }
//fragile public Dictionary <String, float?> userLabel(int studentId) { List <Takes> takesList = TakesApi.findByStudentID(studentId); List <List <int?> > courseList = new List <List <int?> >(); List <float?> scores = new List <float?>(); TypeMapper typeMapper = new TypeMapper(); for (int i = 0; i < 4; i++) { courseList.Add(new List <int?>()); } foreach (Takes takes in takesList) { int?temp = CourseClassApi.getByID(takes.courseClassID).courseID; int anotherTemp = int.Parse(CourseInfoApi.findByCourseID(temp).courseName); if (typeMapper.mapper.ContainsKey(anotherTemp)) { courseList[typeMapper.mapper[anotherTemp].Value - 1].Add(temp); } } for (int i = 0; i < 4; i++) { if (courseList[i].Count == 0) { scores.Add(-1.0f); continue; } List <int?> chapterList = new List <int?>(); foreach (int?courseId in courseList[i]) { List <ChapterNode> chapterNodes = ChapterContentApi.findByCourseID(courseId); foreach (ChapterNode chapterNode in chapterNodes) { chapterList.Add(chapterNode.id); } } float count = 0; float?total = 0; foreach (int?integer in chapterList) { StudentChapter studentChapter = StudentChapterApi.findByChapterIDAndStudentID(integer, studentId); if (studentChapter != null && studentChapter.scored_2 != null && studentChapter.scored_2 == 1) { count++; total += 100 * studentChapter.totalScore_2 / ChapterContentApi.getByID(integer).exerciseTotal_2; } } if (count == 0) { scores.Add(-1.0f); } else { scores.Add(total / count); } } Dictionary <String, float?> label = new Dictionary <string, float?>(); label.Add("软件工程理论能力", scores[0]); label.Add("基本编程能力", scores[0]); label.Add("实践能力", scores[0]); label.Add("专业方向能力", scores[0]); return(label); }