Esempio n. 1
0
 public static void updateLessonsDictated(Teacher teacher) {
   Date today = new Date();
   int lessonsDictated = 0;
   for (Lesson lesson : Lesson.list()) {
     if (Objects.equals(lesson.getTeacher().getId(), teacher.getId())
         && lesson.getLessonState() == 1
         && lesson.getDateTime().before(today)) {
       lessonsDictated++;
     }
   }
   teacher.setLessonsDictated(lessonsDictated);
   teacher.save();
 }
Esempio n. 2
0
 public static void updateRating(Teacher teacher) {
   float lessonsRated = 0;
   float totalScore = 0;
   for (Lesson lesson : Lesson.list()) {
     if (Objects.equals(lesson.getTeacher().getId(), teacher.getId())
         && lesson.getTeacherReview() != null) {
       lessonsRated++;
       totalScore += lesson.getTeacherReview().getStars();
     }
   }
   float temp =
       lessonsRated == 0
           ? 0
           : (((float) ((long) (((totalScore / lessonsRated) * 100) + 0.5))) / 100);
   teacher.setRanking(temp);
   teacher.save();
 }