def test_give_another_chance(self): groupbuilder = self.week1builder\ .add_group(students=[self.student1], examiners=[self.examiner1]) deliverybuilder = groupbuilder\ .add_deadline_in_x_weeks(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) deliverybuilder.add_failed_feedback(saved_by=UserBuilder('testuser').user) response = self._getas('examiner1', groupbuilder.group.id) html = response.content groupbuilder.reload_from_db() self.assertEquals(groupbuilder.group.feedback, deliverybuilder.delivery.last_feedback) self.assertEquals(groupbuilder.group.delivery_status, 'corrected') self.assertFalse(groupbuilder.group.feedback.is_passing_grade) self.assertTrue(cssExists(html, '.devilry_give_another_chance_box')) box = cssGet(html, '.devilry_give_another_chance_box') self.assertIn('The last feedback for this group is a failing grade.', box.text.strip()) self.assertEquals(cssGet(html, '.devilry_give_another_chance_box form input[name=group_ids]')['value'], str(groupbuilder.group.id)) self.assertEquals(cssGet(html, '.devilry_give_another_chance_box form input[name=give_another_chance]')['value'], 'true') self.assertEquals(cssGet(html, '.devilry_give_another_chance_box form input[name=success_url]')['value'], reverse('devilry_examiner_singlegroupoverview', kwargs={'groupid': groupbuilder.group.id})) self.assertEquals(cssGet(html, '.devilry_give_another_chance_box form input[name=cancel_url]')['value'], reverse('devilry_examiner_singlegroupoverview', kwargs={'groupid': groupbuilder.group.id}))
def test_header(self): groupbuilder = self.week1builder.add_group( students=[self.student1], examiners=[self.examiner1]) response = self._getas('examiner1', groupbuilder.group.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.page-header h1').text.strip(), 'Week 1 — Student One') self.assertEquals(cssGet(html, '.page-header .subheader').text.strip(), 'duck1010, active')
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_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_header(self): deliverybuilder = self.week1builder\ .add_group(students=[self.student1], examiners=[self.examiner1])\ .add_deadline_in_x_weeks(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) with self.settings(DATETIME_FORMAT=DJANGO_ISODATETIMEFORMAT, USE_L10N=False): response = self._getas('examiner1', deliverybuilder.delivery.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.page-header h1').text.strip(), 'Week 1 — Student One') self.assertEquals(cssGet(html, '.page-header .subheader').text.strip(), 'Delivery 1/1-{}'.format(isoformat_datetime(deliverybuilder.delivery.time_of_delivery)))
def test_delivery_render(self): groupbuilder = self.week1builder.add_group( examiners=[self.examiner1]) delivery = groupbuilder.add_deadline_in_x_weeks(weeks=1)\ .add_delivery().delivery with self.settings(DATETIME_FORMAT=_DJANGO_ISODATETIMEFORMAT, USE_L10N=False): response = self._getas('examiner1', groupbuilder.group.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.delivery h3 a').text.strip(), 'Delivery #1') self.assertEquals(cssGet(html, '.delivery .no-feedback-message').text.strip(), 'No feedback') self.assertEquals(cssGet(html, '.delivery .time_of_delivery').text.strip(), _isoformat_datetime(delivery.time_of_delivery)) self.assertFalse(cssExists(html, '.delivery .after_deadline_message'))
def test_deadline_render(self): groupbuilder = self.week1builder.add_group( examiners=[self.examiner1]) deadlinebuilder = groupbuilder.add_deadline_in_x_weeks(weeks=1, text='This is the deadline text.') with self.settings(DATETIME_FORMAT=_DJANGO_ISODATETIMEFORMAT, USE_L10N=False): response = self._getas('examiner1', groupbuilder.group.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.deadlinebox h2 .deadline-header-prefix').text.strip(), 'Deadline 1') self.assertEquals(cssGet(html, '.deadlinebox h2 .deadline-datetime').text.strip(), _isoformat_datetime(deadlinebuilder.deadline.deadline)) self.assertEquals(cssGet(html, '.deadlinebox .deadline-text').text.strip(), 'This is the deadline text.')
def test_give_another_chance_sets_initial_text(self): group1 = self.assignment1builder\ .add_group(examiners=[self.examiner1]).group response = self._postas(self.examiner1, { 'group_ids': [group1.id], 'give_another_chance': 'on' }) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '#id_text').text.strip(), "I have given you a new chance to pass this assignment. Read your last feedback for information about why you did not pass, and why you have been given another chance.") self.assertEquals(cssGet(html, '#id_why_created')['value'], 'examiner-gave-another-chance') self.assertEquals(cssGet(html, '#id_why_created')['type'], 'hidden')
def test_no_deliveries_on_deadline(self): groupbuilder = self.week1builder.add_group( examiners=[self.examiner1]) deadlinebuilder = groupbuilder.add_deadline_in_x_weeks(weeks=1) response = self._getas('examiner1', groupbuilder.group.id) html = response.content self.assertEquals(cssGet(html, '.deadlinebox .no-deliveries-message').text.strip(), 'No deliveries')
def test_render(self): group1 = self.assignment1builder\ .add_group(examiners=[self.examiner1]).group response = self._postas(self.examiner1, { 'group_ids': [group1.id] }) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.page-header h1').text.strip(), 'Add non-electronic delivery') self.assertEquals(cssGet(html, '.page-header .subheader').text.strip(), "Assignment One — duck1010, active") self.assertTrue(cssExists(html, 'input[name=success_url]')) self.assertTrue(cssExists(html, 'input[name=cancel_url]')) self.assertTrue(cssExists(html, 'input[name=group_ids]')) self.assertTrue(cssExists(html, '[name=add_nonelectronic_deliveries_form]')) self.assertTrue(cssExists(html, '[name=submit_cancel]'))
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_render(self): periodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\ .add_admins(self.testuser) publishing_time = DateTimeBuilder.now().plus(days=10) assignment1builder = periodbuilder.add_assignment('assignment1', long_name='Assignment One', anonymous=True, publishing_time=publishing_time, deadline_handling=1) response = self._getas(assignment1builder.assignment.id, self.testuser) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, 'input[name=long_name]')['value'], 'Assignment One') self.assertEquals(cssGet(html, 'select[name=deadline_handling] option[value=1]')['selected'], 'selected') self.assertEquals(cssGet(html, 'input[name=publishing_time]')['value'], isoformat_datetime(publishing_time)) self.assertEquals(cssGet(html, 'input[name=short_name]')['value'], 'assignment1')
def test_delivery_render_failed_grade(self): groupbuilder = self.week1builder.add_group( examiners=[self.examiner1]) delivery = groupbuilder.add_deadline_in_x_weeks(weeks=1)\ .add_delivery()\ .add_feedback( grade='2/20', points=2, is_passing_grade=False, saved_by=self.examiner1) response = self._getas('examiner1', groupbuilder.group.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, '.delivery .last-feedback .feedback-grade').text.strip(), '2/20') self.assertEquals(cssGet(html, '.delivery .last-feedback .feedback-is_passing_grade').text.strip(), 'failed') self.assertIn('text-warning', cssGet(html, '.delivery .last-feedback')['class'])
def test_render(self): groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\ .add_assignment('assignment1')\ .add_group(students=[self.testuser]) groupbuilder.add_deadline_in_x_weeks(weeks=1) response = self._getas(groupbuilder.group.id, self.testuser) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, 'h1').text.strip(), 'Project group')
def test_languageselect_no_current_language(self): with self.settings( LANGUAGES=[('en', 'English'), ('nb', 'Norwegian')], LANGUAGE_CODE='nb'): html = self._getas(self.testuserbuilder.user).content self.assertTrue(cssExists(html, '#devilry_change_language_form')) self.assertEquals( cssGet(html, '#devilry_change_language_form option[value="nb"]')['selected'], 'selected')
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_delivery_render_after_deadline(self): groupbuilder = self.week1builder.add_group( examiners=[self.examiner1]) delivery = groupbuilder.add_deadline_in_x_weeks(weeks=1)\ .add_delivery_x_hours_after_deadline(hours=2).delivery response = self._getas('examiner1', groupbuilder.group.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals( normalize_whitespace(cssGet(html, '.delivery .after_deadline_message').text), "2 hours after the deadline")
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_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_languageselect(self): self.testuserbuilder.update( languagecode='en' ) with self.settings(LANGUAGES=[('en', 'English'), ('nb', 'Norwegian')]): html = self._getas(self.testuserbuilder.user).content self.assertTrue(cssExists(html, '#devilry_change_language_form')) self.assertEquals( cssGet(html, '#devilry_change_language_form option[value="en"]')['selected'], 'selected')
def test_after_deadline(self): delivery = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_after_deadline(hours=1).delivery response = self._getas('examiner1', delivery.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals( normalize_whitespace(cssGet(html, '.after_deadline_message').text), 'This delivery was added 1 hour after the deadline.The group has no other deliveries for this deadline.')
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_list_single(self): currentperiodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active() week1builder = currentperiodbuilder.add_assignment('week1', 'Week 1') week1builder.add_group().add_examiners(self.examiner1) response = self._getas('examiner1') self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(len(cssFind(html, '.active-assignment-listing-item')), 1) linktag = cssGet(html, 'a.assignment-duck1010.active.week1') self.assertEquals(linktag.text.strip(), 'duck1010.active - Week 1') self.assertEquals(linktag['href'], '/devilry_examiner/allgroupsoverview/{}/waiting_for_feedback_or_all'.format(week1builder.assignment.id))
def test_show_render_no_feedback(self): delivery = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1).delivery response = self._getas('examiner1', delivery.id) html = response.content self.assertIsNone(delivery.last_feedback) self.assertFalse(cssExists(html, '.read-feedback-box')) self.assertTrue(cssExists(html, '.no-feedback-box')) self.assertEquals(cssGet(html, '.no-feedback-box').text.strip(), 'Write feedbackNo feedback on this delivery.')
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_after_deadline_other_deliveries(self): deadlinebuilder = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1) delivery1 = deadlinebuilder.add_delivery_x_hours_before_deadline(hours=1).delivery delivery2 = deadlinebuilder.add_delivery_x_hours_after_deadline(hours=4).delivery response = self._getas('examiner1', delivery2.id) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals( normalize_whitespace(cssGet(html, '.after_deadline_message').text), 'This delivery was added 4 hours after the deadline.The group has made at least one more delivery for this deadline.Browse other deliveries.')
def test_not_last_delivery_message(self): groupbuilder = self.week1builder.add_group(examiners=[self.examiner1]) deadlinebuilder = groupbuilder.add_deadline_x_weeks_ago(weeks=1) delivery1 = deadlinebuilder.add_delivery_x_hours_before_deadline(hours=1).delivery deadlinebuilder.add_delivery_x_hours_after_deadline(hours=1) response = self._getas('examiner1', delivery1.id) groupbuilder.reload_from_db() html = response.content self.assertEquals( cssGet(html, '.not_last_delivery_message').text.strip(), 'This delivery is not the last delivery made by this group on this assignment.Browse other deliveries.')
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_filemeta_links_single(self): deliverybuilder = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) deliverybuilder.add_filemeta(filename='testfile.txt', data='test') response = self._getas('examiner1', deliverybuilder.delivery.id) html = response.content self.assertTrue(cssExists(html, '.delivery_files')) self.assertEquals(len(cssFind(html, '.delivery_files a')), 1) self.assertTrue(cssExists(html, '.delivery_files .btn')) self.assertEquals(cssGet(html, '.delivery_files a.btn').text.strip(), 'testfile.txt')
def test_readonly_feedback_render(self): feedback = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1)\ .add_feedback( points=10, grade='10/100', is_passing_grade=False, saved_by=UserBuilder('testuser').user, rendered_view='This is a test.' ).feedback response = self._getas('examiner1', feedback.delivery.id) html = response.content self.assertFalse(cssExists(html, '.no-feedback-box')) self.assertTrue(cssExists(html, '.read-feedback-box')) self.assertEquals(cssGet(html, '.read-feedback-box .feedback_gradebox .feedback_grade').text.strip(), '10/100') self.assertEquals(cssGet(html, '.read-feedback-box .feedback_gradebox .feedback_is_passing_grade').text.strip(), 'failed') self.assertIn('django-cradmin-container-fluid-focus-warning', cssGet(html, '.read-feedback-box .feedback_gradebox')['class']) self.assertEquals(cssGet(html, '.read-feedback-box #devilry_examiner_feedback_rendered_view').text.strip(), 'This is a test.')
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_filemeta_links_multi(self): deliverybuilder = self.week1builder\ .add_group(examiners=[self.examiner1])\ .add_deadline_x_weeks_ago(weeks=1)\ .add_delivery_x_hours_before_deadline(hours=1) deliverybuilder.add_filemeta( filename='b.txt', data='test') deliverybuilder.add_filemeta(filename='a.txt', data='test') response = self._getas('examiner1', deliverybuilder.delivery.id) html = response.content self.assertTrue(cssExists(html, '.delivery_files')) self.assertEquals(len(cssFind(html, '.delivery_files a')), 3) # One for the "Download files"-button and one for each file self.assertTrue(cssExists(html, '.delivery_files .btn')) self.assertEquals(cssGet(html, '.delivery_files .btn').text.strip(), 'Download files') filenames = map(lambda e: e.text.strip(), cssFind(html, '.delivery_files ul li')) self.assertEquals(filenames, ['a.txt', 'b.txt'])
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_render_noinput(self): response = self._getas(self.testuser) self.assertEquals(response.status_code, 200) html = response.content self.assertEquals(cssGet(html, "#id_search").value, None)