@RequestMapping(value = "/addLesson") public String addLesson(Model model) { System.out.println("lesson added"); Lesson lesson = js.addLesson(); return "redirect:/editLesson/" + lesson.getId(); }
/** * Function to analyse if user input is correct * * @param index Index of curson in texbox * @param input Current inputed char * @return */ public boolean Analyse(int index, String input) { // if Lesson is ready if (Lesson.isReady()) { // get text of Lesson String lessonText = Lesson.getText(); /** * Compare user's input to what should be at index position in text of Lesson 1. Check if char * at desired index in Lesson is equal to user's input */ return Objects.equals("" + lessonText.charAt(index - 1), input); } return false; }
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(); }
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(); }
public void init(final Lesson lesson) { mTextViewTitle = (TextView) findViewById(R.id.tvViewTitle); mTextViewCreator = (TextView) findViewById(R.id.tvViewCreator); mTextViewBody = (TextView) findViewById(R.id.tvViewBody); mButtonComment = (Button) findViewById(R.id.btnComment); mButtonComment.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { UUID lessons_comment_id = mLesson.getId(); Intent intent = CommentActivity.newIntent(LessonActivity.this, lessons_comment_id); startActivity(intent); } }); mTextViewTitle.setText(lesson.getTitle()); mTextViewCreator.setText( OlsenDB.get(LessonActivity.this) .getUser(UUID.fromString(lesson.getCreator_id())) .getNickname()); mTextViewBody.setText(lesson.getBody()); setTitle(lesson.getTitle()); }
/** * Funtion to get Lesson's text * * @return */ public String GetLessonText() { return Lesson.getText(); }
/** Initializes state of course */ public void initCourse(boolean isRestarted) { for (Lesson lesson : getLessons()) { lesson.initLesson(this, isRestarted); } }
public int getFitness() { int res = 0; ArrayList<Lesson> pre = new ArrayList<Lesson>(); HashMap<Lesson, Integer> perWeek = new HashMap<Lesson, Integer>(); for (int j = 0; j < slots.length; j++) { for (int k = 0; k < slots[j].length; k++) { try { if (slots[j][k].isFree()) { // System.out.println("bbooa"); } } catch (Exception e) { System.out.println("buu"); } if (k % 2 == 0) { pre = slots[j][k].getL(); } else { if (slots[j][k].getL() == pre) { res += 5; } } String[] teachers = new String[slots[j][k].getL().size()]; for (int i = 0; i < slots[j][k].getL().size(); i++) { teachers[i] = slots[j][k].getL().get(i).getTeacher(); } res += (!repeat(teachers) ? 5 : 0); Integer[] rooms = new Integer[slots[j][k].getL().size()]; for (int i = 0; i < slots[j][k].getL().size(); i++) { rooms[i] = slots[j][k].getL().get(i).getRoom(); } res += (!repeat(rooms) ? 5 : 0); for (Lesson l : slots[j][k].getL()) { if (Const.teachersAndLessons.containsKey(l.getSubject())) { if (contains(Const.teachersAndLessons.get(l.getSubject()), l.getTeacher())) { res += 5; } } if (Const.roomSpecific.containsKey(l.getTeacher())) { if (Const.roomSpecific.get(l.getTeacher()) == l.getRoom()) { res++; } } if (perWeek.containsKey(l)) { int count = perWeek.get(l); perWeek.remove(l); perWeek.put(l, count + 1); } else { perWeek.put(l, 1); } if (teachersAndLessons.containsKey(l.getSubject())) { if (l.getTeacher() == teachersAndLessons.get(l.getSubject())) { res += 5; } } else { teachersAndLessons.put(l.getSubject(), l.getTeacher()); } } if (slots[j][k] == after(j, k) && slots[j][k] != before(j, k)) { res += 10; } } } for (Entry<Lesson, Integer> entry : perWeek.entrySet()) { if (entry.getKey().getSubject() == "Homeroom" && entry.getValue() == 1) { res += 5; } if (entry.getKey().getSubject() != "Majors") { if (entry.getValue() == Const.perWeek.get(entry.getKey())) res += 5; } else { if (entry.getValue() == Const.majorsPerWeek.get(entry.getKey())) res += 10; } } if (lessonCount() == 44) { res += 10; } this.fitness = res; return res; }