Untitled
unknown
plain_text
2 years ago
5.1 kB
2
Indexable
package pt.ulisboa.tecnico.socialsoftware.tutor.teacherdashboard.domain import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest import org.springframework.boot.test.context.TestConfiguration import pt.ulisboa.tecnico.socialsoftware.tutor.BeanConfiguration import pt.ulisboa.tecnico.socialsoftware.tutor.SpockTest import pt.ulisboa.tecnico.socialsoftware.tutor.exceptions.ErrorMessage import pt.ulisboa.tecnico.socialsoftware.tutor.exceptions.TutorException import pt.ulisboa.tecnico.socialsoftware.tutor.teacherdashboard.domain.StudentStats import pt.ulisboa.tecnico.socialsoftware.tutor.user.domain.Teacher import pt.ulisboa.tecnico.socialsoftware.tutor.user.domain.Student import pt.ulisboa.tecnico.socialsoftware.tutor.execution.domain.CourseExecution import pt.ulisboa.tecnico.socialsoftware.tutor.question.domain.Course import pt.ulisboa.tecnico.socialsoftware.tutor.auth.domain.AuthUser import pt.ulisboa.tecnico.socialsoftware.tutor.quiz.domain.Quiz import pt.ulisboa.tecnico.socialsoftware.tutor.answer.domain.QuizAnswer import pt.ulisboa.tecnico.socialsoftware.tutor.answer.domain.QuestionAnswer import spock.lang.Unroll @DataJpaTest class numStudentStatsTest extends SpockTest { def teacherDashboard def teacher def student def studentStats def weeklyScore def studentDashboard def quiz def quizAnswser def questionAnswer def setup() { createExternalCourseAndExecution() teacher = new Teacher(USER_1_NAME, false) userRepository.save(teacher) quiz = new Quiz() quizAnswser = new QuizAnswer() questionAnswer = new QuestionAnswer() } def createTeacherDashboardAndPersist() { teacherDashboard = new TeacherDashboard(externalCourseExecution, teacher) teacherDashboardRepository.save(teacherDashboard) return teacherDashboard } def createActiveStudent() { student = new Student(USER_1_NAME, USER_1_USERNAME, USER_1_EMAIL, false, AuthUser.Type.TECNICO) userRepository.save(student) return student } def createInactiveStudent() { student = new Student(USER_1_NAME, USER_1_USERNAME, USER_1_EMAIL, false, AuthUser.Type.EXTERNAL) userRepository.save(student) return student } def createStudentStats() { studentStats = new StudentStats(externalCourseExecution, teacherDashboard) studentStatsRepository.save(studentStats) return studentStats } def createStudentDashboard(Student student) { studentDashboard = new StudentDashboard(externalCourseExecution, student) studentDashboardRepository.save(studentDashboard) return studentDashboard } def createWeeklyScore(StudentDashboard studentDashboard) { LocalDate week = LocalDateTime.of(2023, 1, 1, 11, 0) weeklyScore = new WeeklyScore(studentDashboard, week) weeklyScoreRepository.save(weeklyScore) return weeklyScore } def createAndPersistQuiz() { quiz.setCourseExecution(externalCourseExecution) quiz.setType("TOURNAMENT") quizRepository.save(quiz) } def createAndPersistQuizAnswer() { quizAnwser.setQuiz(quiz) quizAnwser.setStudent(createActiveStudent()) quiz.setCourseExecution(externalCourseExecution) quiz.setType("TOURNAMENT") quizRepository.save(quiz) } def createAndPersistQuestionAnswer() { questionAnswer.setQuizAnswer(createAndPersistQuizAnswer()); } def ""() { given: "" student1 = createActiveStudent() student2 = createActiveStudent() student3 = createActiveStudent() studentDashboard1 = createStudentDashboard(student1) studentDashboard2 = createStudentDashboard(student2) studentDashboard3 = createStudentDashboard(student3) quiz = createAndPersistQuiz() } //1 alunos < 75 - 2 aluno > 75 /*def ""() { given: "an empty dashboard for the teacher" student1 = createActiveStudent() student2 = createActiveStudent() student3 = createActiveStudent() studentDashboard1 = createStudentDashboard(student1) studentDashboard2 = createStudentDashboard(student2) studentDashboard3 = createStudentDashboard(student3) //qA = 100 //qC = 75 when: "" questionA1 = studentDashboard1.getNumberOfStudentAnswers() + 4 questionC1 = studentDashboard2.getNumberOfCorrectStudentAnswers() + 3 questionA2 = studentDashboard1.getNumberOfStudentAnswers() + 4 questionC2 = studentDashboard2.getNumberOfCorrectStudentAnswers() + 3 questionA3 = studentDashboard1.getNumberOfStudentAnswers() + 4 questionC3 = studentDashboard2.getNumberOfCorrectStudentAnswers() + 3 studentStats = createStudentStats() studentStats.setNumMore75CorrectQuestions() then: "" }*/ @TestConfiguration static class LocalBeanConfiguration extends BeanConfiguration {} }
Editor is loading...