Example #1
0
 def test_exam_unset(self):
     """
     Tests that when an exam is unset in the output condition
     that a gift_card is created with appropriate points.
     """
     set_current_unit_settings_value(
         self.facility.id,
         self.unit)  # make sure the unit and grade we are in match the test
     test_object = Test.all().get(self.exam_id, None)
     self.assertTrue(test_object)
     testlog = TestLog(user=self.student,
                       test=self.exam_id,
                       index=20,
                       started=True,
                       complete=True,
                       total_correct=15,
                       total_number=21)
     testlog.save()
     set_current_unit_settings_value(self.facility.id, self.unit)
     # Set and unset exam mode to trigger signal.
     set_exam_mode_on(test_object)
     set_exam_mode_on(test_object)
     transactionlogs = StoreTransactionLog.objects.filter(
         user=self.student,
         context_id=str(self.unit),
         context_type="output_condition",
         item="gift_card")
     self.assertTrue(len(transactionlogs))
     for transactionlog in transactionlogs:
         self.assertTrue(transactionlog.value == int(
             round(settings.UNIT_POINTS * float(testlog.total_correct) /
                   testlog.total_number)))
Example #2
0
    def setUp(self):
        """
        Create a student, log the student in, and go to the test page.
        """
        super(StudentTestTest, self).setUp()
        self.facility_name = "fac"
        self.facility = self.create_facility(name=self.facility_name)
        self.student = self.create_student(username=self.student_username,
                                           password=self.student_password,
                                           facility=self.facility)
        self.browser_login_student(
            self.student_username,
            self.student_password,
            facility_name=self.facility_name,
        )

        set_exam_mode_on(TEST_ID)
        self.browse_to(self.live_server_url +
                       reverse("test", kwargs={"test_id": TEST_ID}))
        self.browser_check_django_message(num_messages=0)
        self.browser.find_element_by_id('start-test').click()
Example #3
0
 def test_get_exercise_load_status(self):
     for testfile in glob.iglob(STUDENT_TESTING_DATA_PATH + "/*.json"):
         with open(testfile) as f:
             test_id = os.path.splitext(os.path.basename(f.name))[0]
             set_exam_mode_on(test_id)
             logging.debug("Testing test : " + test_id)
             self.browse_to(self.live_server_url +
                            reverse("test", kwargs={"test_id": test_id}))
             self.browser.find_element_by_id('start-test').click()
             error_list = self.browser.execute_script(
                 "return window.js_errors;")
             if error_list:
                 logging.error("Found JS error(s) while loading path: " +
                               path)
                 for e in error_list:
                     logging.error(e)
             self.assertFalse(error_list)
             testlog = TestLog.objects.get(test=test_id, user=self.student)
             self.assertTrue(testlog.started,
                             "Student has not started the test.")
             time.sleep(1)
Example #4
0
    def setUp(self):
        """
        Create a student, log the student in, and go to the test page.
        """
        super(StudentTestTest, self).setUp()
        self.facility_name = "fac"
        self.facility = self.create_facility(name=self.facility_name)
        self.student = self.create_student(username=self.student_username,
                                           password=self.student_password,
                                           facility=self.facility)
        self.browser_login_student(
            self.student_username,
            self.student_password,
            facility_name=self.facility_name,
        )

        set_exam_mode_on(TEST_ID)
        self.browse_to(
            self.live_server_url +
            reverse("test", kwargs={"test_id": TEST_ID}))
        self.browser_check_django_message(num_messages=0)
        self.browser.find_element_by_id('start-test').click()
Example #5
0
 def test_get_exercise_load_status(self):
     for testfile in glob.iglob(STUDENT_TESTING_DATA_PATH + "/*.json"):
         with open(testfile) as f:
             test_id = os.path.splitext(os.path.basename(f.name))[0]
             set_exam_mode_on(test_id)
             logging.debug("Testing test : " + test_id)
             self.browse_to(
                 self.live_server_url +
                 reverse("test", kwargs={"test_id": test_id}))
             self.browser.find_element_by_id('start-test').click()
             error_list = self.browser.execute_script(
                 "return window.js_errors;")
             if error_list:
                 logging.error(
                     "Found JS error(s) while loading path: " + path)
                 for e in error_list:
                     logging.error(e)
             self.assertFalse(error_list)
             testlog = TestLog.objects.get(test=test_id, user=self.student)
             self.assertTrue(
                 testlog.started, "Student has not started the test.")
             time.sleep(1)