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')
 def test_next_page_invalid_pluginid(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch('devilry.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)
 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')
 def test_get_not_admin_404_with_pluginselected(self):
     nobody = UserBuilder('nobody').user
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch('devilry.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)
 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.assertEqual(cssGet(html, '#id_max_points')['value'], '2030')
 def test_get_not_admin_404_with_pluginselected(self):
     nobody = UserBuilder('nobody').user
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch(
             'devilry.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)
 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')
 def test_next_page_invalid_pluginid(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch(
             'devilry.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)
 def test_render(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     myregistry.add(MockApprovedPluginApi)
     with patch('devilry.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)
 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
 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)
 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.assertEqual(response.status_code, 200)
         html = response.content
         self.assertEqual(cssGet(html, '.page-header h1').text.strip(),
             'Set the maximum possible number of points')
         self.assertTrue(cssExists(html, '#id_max_points'))
         self.assertEqual(cssGet(html, '#id_max_points')['value'], '1')  # The default value
 def test_sets_max_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.assertEqual(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.assertEqual(self.assignmentbuilder.assignment.max_points,
             MockApprovedPluginApi(self.assignmentbuilder.assignment).get_max_points())
Beispiel #14
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')
 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())
    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())
 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.assertEqual(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.assertEqual(self.assignmentbuilder.assignment.max_points, 100)
Beispiel #18
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)
 def test_next_page_no_configuration_required(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch('devilry.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)
 def test_next_page_requires_configuration(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockRequiresConfigurationPluginApi)
     with patch('devilry.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)
Beispiel #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.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())
 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.assertEqual(response.status_code, 200)
         self.assertEqual(self.assignmentbuilder.assignment.max_points, 10) # Unchanged
         html = response.content
         self.assertIn('Ensure this value is greater than or equal to 0', html)
 def test_post_negative_value_shows_error(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     self.assignmentbuilder.update(
         grading_system_plugin_id=MockPointsPluginApi.id,
         passing_grade_min_points=10
     )
     with patch('devilry.apps.core.models.assignment.gradingsystempluginregistry', myregistry):
         response = self.post_as(self.admin1, {
             'passing_grade_min_points': -1
         })
         self.assertEquals(response.status_code, 200)
         self.assertEquals(self.assignmentbuilder.assignment.passing_grade_min_points, 10) # Unchanged
         html = response.content
         self.assertIn('Ensure this value is greater than or equal to 0', html)
 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')
 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)
 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)
Beispiel #27
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,
                        })
 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')
Beispiel #29
0
 def test_invalid_pluginid_404(self):
     myregistry = GradingSystemPluginRegistry()
     self.assignmentbuilder.update(grading_system_plugin_id=1001)
     with patch(
             'devilry.apps.core.models.assignment.gradingsystempluginregistry',
             myregistry):
         response = self.get_as(self.admin1)
         self.assertEquals(response.status_code, 404)
    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')
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.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())
Beispiel #32
0
 def test_no_grading_system_configured(self):
     myregistry = GradingSystemPluginRegistry()
     self.assignmentbuilder.update(grading_system_plugin_id=None)
     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.assertIn('No grading system configured.', html)
 def test_next_page_requires_configuration(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockRequiresConfigurationPluginApi)
     with patch(
             'devilry.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)
Beispiel #34
0
 def test_no_drafts_or_feedbacks_message(self):
     myregistry = GradingSystemPluginRegistry()
     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.assertIn(
             'You can safely reconfigure the grading system for this assignment.',
             html)
 def test_next_page_no_configuration_required(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     with patch(
             'devilry.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)
 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')
 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')
 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')
 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,
     })
Beispiel #40
0
 def test_has_staticfeedbacks_warning(self):
     examiner1 = UserBuilder('examiner1').user
     delivery = self.assignmentbuilder\
         .add_group()\
         .add_deadline_in_x_weeks(weeks=1)\
         .add_delivery_x_hours_before_deadline(hours=1)\
         .add_passed_feedback(saved_by=examiner1)
     myregistry = GradingSystemPluginRegistry()
     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.assertIn(
             'You SHOULD NOT reconfigure the grading system for this assignment.',
             html)
Beispiel #41
0
 def test_has_feedbackdrafts_message(self):
     delivery = self.assignmentbuilder\
         .add_group()\
         .add_deadline_in_x_weeks(weeks=1)\
         .add_delivery_x_hours_before_deadline(hours=1).delivery
     examiner1 = UserBuilder('examiner1').user
     FeedbackDraft.objects.create(points=40,
                                  delivery=delivery,
                                  saved_by=examiner1,
                                  feedbacktext_html='This is a test.')
     myregistry = GradingSystemPluginRegistry()
     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.assertIn(
             'You can reconfigure the grading system for this assignment, but be careful, at least one examiner has saved a feedback draft.',
             html)
 def test_render(self):
     myregistry = GradingSystemPluginRegistry()
     myregistry.add(MockPointsPluginApi)
     myregistry.add(MockApprovedPluginApi)
     with patch(
             'devilry.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)