Exemple #1
0
    def test_render(self):
        myregistry = GradingSystemPluginRegistry()
        myregistry.add(MockPointsPluginApi)
        self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id)
        with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
            response = self.get_as(self.admin1)
            self.assertEquals(response.status_code, 200)
            html = response.content
            self.assertEquals(cssGet(html, '.page-header h1').text.strip(),
                'How are results presented to the student?')
            self.assertEquals(len(cssFind(html, '.devilry_gradingsystem_verbose_selectbox')), 3)

            self.assertEquals(cssGet(html, '.passed-failed_points_to_grade_mapper_box h2').text.strip(),
                'As passed or failed')
            self.assertEquals(cssGet(html, '.passed-failed_points_to_grade_mapper_box a.btn')['href'],
                '?points_to_grade_mapper=passed-failed')

            self.assertEquals(cssGet(html, '.raw-points_points_to_grade_mapper_box h2').text.strip(),
                'As points')
            self.assertEquals(cssGet(html, '.raw-points_points_to_grade_mapper_box a.btn')['href'],
                '?points_to_grade_mapper=raw-points')

            self.assertEquals(cssGet(html, '.custom-table_points_to_grade_mapper_box h2').text.strip(),
                'As a text looked up in a custom table')
            self.assertEquals(cssGet(html, '.custom-table_points_to_grade_mapper_box a.btn')['href'],
                '?points_to_grade_mapper=custom-table')
Exemple #2
0
 def test_render_default_to_current_value(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id, max_points=2030)
     with patch("devilry.apps.core.models.assignment.gradingsystempluginregistry", myregistry):
         response = self.get_as(self.admin1)
         html = response.content
         self.assertEquals(cssGet(html, "#id_max_points")["value"], "2030")
Exemple #3
0
 def test_next_page_invalid_pluginid(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch('devilry_gradingsystem.views.admin.selectplugin.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1, {
             'grading_system_plugin_id': 'doesnotexist'
         })
         self.assertEquals(response.status_code, 200)
         self.assertIn('Invalid grading system plugin ID: doesnotexist', response.content)
Exemple #4
0
 def test_render(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id)
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1)
         self.assertEquals(response.status_code, 200)
         html = response.content
         self.assertEquals(cssGet(html, '.page-header h1').text.strip(),
             'Grading system')
Exemple #5
0
 def test_post_negative_value_shows_error(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id, max_points=10)
     with patch("devilry.apps.core.models.assignment.gradingsystempluginregistry", myregistry):
         response = self.post_as(self.admin1, {"max_points": -1})
         self.assertEquals(response.status_code, 200)
         self.assertEquals(self.assignmentbuilder.assignment.max_points, 10)  # Unchanged
         html = response.content
         self.assertIn("Ensure this value is greater than or equal to 0", html)
Exemple #6
0
 def test_get_not_admin_404_with_pluginselected(self):
     nobody = UserBuilder('nobody').user
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch('devilry_gradingsystem.views.admin.selectplugin.gradingsystempluginregistry', myregistry):
         self.assertIn(MockPointsPluginApi.id, myregistry)
         response = self.get_as(nobody, {
             'grading_system_plugin_id': MockPointsPluginApi.id
         })
         self.assertEquals(response.status_code, 404)
Exemple #7
0
 def test_render(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id)
     with patch("devilry.apps.core.models.assignment.gradingsystempluginregistry", myregistry):
         response = self.get_as(self.admin1)
         self.assertEquals(response.status_code, 200)
         html = response.content
         self.assertEquals(cssGet(html, ".page-header h1").text.strip(), "Set the maximum possible number of points")
         self.assertTrue(cssExists(html, "#id_max_points"))
         self.assertEquals(cssGet(html, "#id_max_points")["value"], "1")  # The default value
Exemple #8
0
 def test_render_default_to_current_value(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(
         grading_system_plugin_id=MockPointsPluginApi.id,
         passing_grade_min_points=2030
     )
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1)
         html = response.content
         self.assertEquals(cssGet(html, '#id_passing_grade_min_points')['value'], '2030')
Exemple #9
0
 def test_render(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     myregistry.add(MockApprovedPluginApi)
     with patch('devilry_gradingsystem.views.admin.selectplugin.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1)
         self.assertEquals(response.status_code, 200)
         html = response.content
         self.assertEquals(cssGet(html, '.page-header h1').text.strip(),
             'How would you like to provide feedback to your students?')
         self.assertEquals(len(cssFind(html, '.devilry_gradingsystem_verbose_selectbox')), 2)
Exemple #10
0
    def test_has_valid_grading_setup_valid_by_default(self):
        assignment1 = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_assignment('assignment1').assignment

        # Mock the gradingsystempluginregistry
        myregistry = GradingSystemPluginRegistry()
        class MockApprovedPluginApi(GradingSystemPluginInterface):
            id = 'devilry_gradingsystemplugin_approved'
        myregistry.add(MockApprovedPluginApi)

        with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
            self.assertTrue(assignment1.has_valid_grading_setup())
Exemple #11
0
 def test_invalid_grading_setup(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         self.assignmentbuilder.update(
             grading_system_plugin_id=MockPointsPluginApi.id,
             max_points=None
         )
         response = self.get_as(self.admin1)
         self.assertEquals(response.status_code, 200)
         html = response.content
         self.assertIn('The grading system is not configured correctly.', html)
Exemple #12
0
 def test_render(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id)
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1)
         self.assertEquals(response.status_code, 200)
         html = response.content
         self.assertEquals(cssGet(html, '.page-header h1').text.strip(),
             'Set the minumum number of points required to pass')
         self.assertTrue(cssExists(html, '#id_passing_grade_min_points'))
         self.assertEquals(cssGet(html, '#id_passing_grade_min_points')['value'], '1')  # The default value
Exemple #13
0
 def test_sets_passing_grade_min_points_automatically(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockApprovedPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockApprovedPluginApi.id)
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1)
         self.assertEquals(response.status_code, 302)
         self.assertTrue(response["Location"].endswith(
             reverse('devilry_gradingsystem_admin_summary', kwargs={
                 'assignmentid': self.assignmentbuilder.assignment.id})))
         self.assignmentbuilder.reload_from_db()
         self.assertEquals(self.assignmentbuilder.assignment.passing_grade_min_points,
             MockApprovedPluginApi(self.assignmentbuilder.assignment).get_passing_grade_min_points())
Exemple #14
0
 def test_next_page_no_configuration_required(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch('devilry_gradingsystem.views.admin.selectplugin.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1, {
             'grading_system_plugin_id': MockPointsPluginApi.id
         })
         self.assertEquals(response.status_code, 302)
         self.assertTrue(response["Location"].endswith(
             reverse('devilry_gradingsystem_admin_setmaxpoints', kwargs={
                 'assignmentid': self.assignmentbuilder.assignment.id})))
         self.assignmentbuilder.reload_from_db()
         self.assertEquals(self.assignmentbuilder.assignment.grading_system_plugin_id,
             MockPointsPluginApi.id)
Exemple #15
0
 def test_next_page_requires_configuration(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockRequiresConfigurationPluginApi)
     with patch('devilry_gradingsystem.views.admin.selectplugin.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1, {
             'grading_system_plugin_id': MockRequiresConfigurationPluginApi.id
         })
         self.assertEquals(response.status_code, 302)
         self.assertEquals(response["Location"],
             'http://testserver/mock/requiresconfiguration/configure/{}'.format(
                 self.assignmentbuilder.assignment.id))
         self.assignmentbuilder.reload_from_db()
         self.assertEquals(self.assignmentbuilder.assignment.grading_system_plugin_id,
             MockRequiresConfigurationPluginApi.id)
Exemple #16
0
 def test_next_page_custom_table(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id)
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1, {
             'points_to_grade_mapper': 'custom-table'
         })
         self.assertEquals(response.status_code, 302)
         self.assertTrue(response["Location"].endswith(
             reverse('devilry_gradingsystem_admin_setup_custom_table', kwargs={
                 'assignmentid': self.assignmentbuilder.assignment.id,
             })))
         self.assignmentbuilder.reload_from_db()
         self.assertEquals(self.assignmentbuilder.assignment.points_to_grade_mapper, 'custom-table')
Exemple #17
0
 def test_post_valid_form(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(
         grading_system_plugin_id=MockPointsPluginApi.id,
         max_points=200 )
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.post_as(self.admin1, {
             'passing_grade_min_points': 100
         })
         self.assertEquals(response.status_code, 302)
         self.assertTrue(response["Location"].endswith(
             reverse('devilry_gradingsystem_admin_summary', kwargs={
                 'assignmentid': self.assignmentbuilder.assignment.id})))
         self.assignmentbuilder.reload_from_db()
         self.assertEquals(self.assignmentbuilder.assignment.passing_grade_min_points, 100)
Exemple #18
0
 def test_next_page_finished(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockApprovedPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockApprovedPluginApi.id)
     self.assertTrue(MockApprovedPluginApi.sets_passing_grade_min_points_automatically)
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1, {
             'points_to_grade_mapper': 'passed-failed'
         })
         self.assertEquals(response.status_code, 302)
         self.assertTrue(response["Location"].endswith(
             reverse('devilry_gradingsystem_admin_setpassing_grade_min_points', kwargs={
                 'assignmentid': self.assignmentbuilder.assignment.id,
             })))
         self.assignmentbuilder.reload_from_db()
         self.assertEquals(self.assignmentbuilder.assignment.points_to_grade_mapper, 'passed-failed')
Exemple #19
0
 def test_post_larger_than_max_points_shows_error(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(
         grading_system_plugin_id=MockPointsPluginApi.id,
         max_points=100,
         passing_grade_min_points=10
     )
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.post_as(self.admin1, {
             'passing_grade_min_points': 200
         })
         self.assertEquals(response.status_code, 200)
         self.assertEquals(self.assignmentbuilder.assignment.passing_grade_min_points, 10) # Unchanged
         html = response.content
         self.assertIn('The minumum number of points required to pass must be less than the maximum number of points possible on the assignment', html)
Exemple #20
0
 def test_post_valid_form(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(grading_system_plugin_id=MockPointsPluginApi.id)
     with patch("devilry.apps.core.models.assignment.gradingsystempluginregistry", myregistry):
         response = self.post_as(self.admin1, {"max_points": 100})
         self.assertEquals(response.status_code, 302)
         self.assertTrue(
             response["Location"].endswith(
                 reverse(
                     "devilry_gradingsystem_admin_select_points_to_grade_mapper",
                     kwargs={"assignmentid": self.assignmentbuilder.assignment.id},
                 )
             )
         )
         self.assignmentbuilder.reload_from_db()
         self.assertEquals(self.assignmentbuilder.assignment.max_points, 100)
Exemple #21
0
class TestSetupCustomTableView(TestCase, AdminViewTestMixin):

    def setUp(self):
        self.admin1 = UserBuilder('admin1').user
        self.myregistry = GradingSystemPluginRegistry()
        self.myregistry.add(MockPointsPluginApi)
        self.assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_assignment('assignment1',
                grading_system_plugin_id=MockPointsPluginApi.id,
                max_points=100,
                points_to_grade_mapper='custom-table'
            )\
            .add_admins(self.admin1)
        self.url = reverse('devilry_gradingsystem_admin_setup_custom_table', kwargs={
            'assignmentid': self.assignmentbuilder.assignment.id,
        })

    # def test_render(self):
    #     myregistry = GradingSystemPluginRegistry()
    #     myregistry.add(MockPointsPluginApi)
    #     myregistry.add(MockApprovedPluginApi)
    #     with patch('devilry_gradingsystem.views.admin.selectplugin.gradingsystempluginregistry', myregistry):
    #         response = self.get_as(self.admin1)
    #         self.assertEquals(response.status_code, 200)
    #         html = response.content
    #         self.assertEquals(cssGet(html, '.page-header h1').text.strip(),
    #             'How would you like to configure the plugin?')
    #         self.assertEquals(len(cssFind(html, '.devilry_gradingsystem_selectplugin_box')), 2)


    def test_post(self):
        with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', self.myregistry):
            response = self.post_as(self.admin1, {
                'form-0-grade': ['F'],
                'form-0-minimum_points': ['0'],
                'form-1-grade': ['C'],
                'form-1-minimum_points': ['50'],
                'form-INITIAL_FORMS': 0,
                'form-TOTAL_FORMS': 2
            })
            self.assertEquals(response.status_code, 302)
            self.assignmentbuilder.reload_from_db()
            self.assertFalse(self.assignmentbuilder.assignment.pointtogrademap.invalid)
            self.assertTrue(self.assignmentbuilder.assignment.has_valid_grading_setup())
Exemple #22
0
 def test_render_custom_table(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(
         grading_system_plugin_id=MockPointsPluginApi.id,
         points_to_grade_mapper='custom-table')
     self.assignmentbuilder.assignment.get_point_to_grade_map().create_map(
         (0, 'Bad'),
         (30, 'Better'),
         (60, 'Good'))
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.get_as(self.admin1)
         self.assertEquals(response.status_code, 200)
         html = response.content
         self.assertEquals(cssGet(html, '.page-header h1').text.strip(),
             'Select the grade required to pass')
         self.assertTrue(cssExists(html, '#id_passing_grade_min_points'))
         self.assertEquals(len(cssFind(html, '#id_passing_grade_min_points option')), 3)
         self.assertEquals(cssGet(html, '#id_passing_grade_min_points option[value=0]').text.strip(), 'Bad')
         self.assertEquals(cssGet(html, '#id_passing_grade_min_points option[value=30]').text.strip(), 'Better')
         self.assertEquals(cssGet(html, '#id_passing_grade_min_points option[value=60]').text.strip(), 'Good')
Exemple #23
0
 def setUp(self):
     self.admin1 = UserBuilder('admin1').user
     self.myregistry = GradingSystemPluginRegistry()
     self.myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('assignment1',
             grading_system_plugin_id=MockPointsPluginApi.id,
             max_points=100,
             points_to_grade_mapper='custom-table'
         )\
         .add_admins(self.admin1)
     self.url = reverse('devilry_gradingsystem_admin_setup_custom_table', kwargs={
         'assignmentid': self.assignmentbuilder.assignment.id,
     })