def test_list_ordering(self):
     currentperiodbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()
     for short_name in ('week1', 'week2', 'week3'):
         currentperiodbuilder.add_assignment(short_name)\
             .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')), 3)
     names = [name.text.strip() for name in cssFind(html, '.assignmentname')]
     self.assertEquals(names, [
         'duck1010.active - week3',
         'duck1010.active - week2',
         'duck1010.active - week1'])
 def test_deadline_ordering(self):
     groupbuilder = self.week1builder.add_group(
             examiners=[self.examiner1])
     deadline2 = groupbuilder.add_deadline_in_x_weeks(weeks=1).deadline
     deadline3 = groupbuilder.add_deadline_in_x_weeks(weeks=2).deadline
     deadline1 = groupbuilder.add_deadline_x_weeks_ago(weeks=1).deadline
     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
     prefixes = map(lambda element: element.text.strip(), cssFind(html, '.deadline-header-prefix'))
     self.assertEquals(prefixes, ['Deadline 3', 'Deadline 2', 'Deadline 1'])
     datetimes = map(lambda element: element.text.strip(), cssFind(html, '.deadline-datetime'))
     self.assertEquals(datetimes,
         [_isoformat_datetime(deadline.deadline) for deadline in (deadline3, deadline2, deadline1)])
    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_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_deadline_render_no_text(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(len(cssFind(html, '.deadlinebox .deadline-text')), 0)
 def test_assignmentadmin(self):
     self.assignmentbuilder.add_admins(self.admin1)
     response = self.get_as(self.admin1)
     html = response.content
     breadcrumb = cssFind(html, 'ol.breadcrumb li')
     self.assertEquals(len(breadcrumb), 3)
     self.assertEquals(breadcrumb[0].text, 'Subject administrator')
     self.assertEquals(breadcrumb[1].text, 'duck1010.active.myassignment')
     self.assertEquals(breadcrumb[2].text, 'Grading system')
Пример #7
0
 def test_assignmentadmin(self):
     self.assignmentbuilder.add_admins(self.admin1)
     response = self.get_as(self.admin1)
     html = response.content
     breadcrumb = cssFind(html, 'ol.breadcrumb li')
     self.assertEquals(len(breadcrumb), 3)
     self.assertEquals(breadcrumb[0].text, 'Subject administrator')
     self.assertEquals(breadcrumb[1].text, 'duck1010.active.myassignment')
     self.assertEquals(breadcrumb[2].text, 'Grading system')
 def test_delivery_order(self):
     groupbuilder = self.week1builder.add_group(
             examiners=[self.examiner1])
     deadlinebuilder = groupbuilder.add_deadline_in_x_weeks(weeks=1)
     delivery1 = deadlinebuilder.add_delivery_x_hours_before_deadline(hours=10).delivery
     delivery2 = deadlinebuilder.add_delivery_x_hours_before_deadline(hours=5).delivery
     delivery3 = deadlinebuilder.add_delivery_x_hours_before_deadline(hours=1).delivery
     with self.settings(DATETIME_FORMAT=_DJANGO_ISODATETIMEFORMAT, USE_L10N=False):
         response = self._getas('examiner1', groupbuilder.group.id)
     html = response.content
     deliveries = map(lambda element: element.text.strip(), cssFind(html, '.delivery h3 a'))
     self.assertEquals(deliveries,
         ['Delivery #3', 'Delivery #2', 'Delivery #1'])
     datetimes = map(lambda element: element.text.strip(), cssFind(html, '.delivery .time_of_delivery'))
     self.assertEquals(datetimes, [
         _isoformat_datetime(delivery3.time_of_delivery),
         _isoformat_datetime(delivery2.time_of_delivery),
         _isoformat_datetime(delivery1.time_of_delivery),
     ])
    def test_results_ordering(self):
        self.assignmentbuilder\
            .add_group(name='Group A')\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()\
            .add_filemeta(filename='Test1.java', data='if(i==10) {}')
        self.assignmentbuilder\
            .add_group(name='Group B')\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()\
            .add_filemeta(filename='Test2.java', data='class Test {if(i==10) {}}')
        self.assignmentbuilder\
            .add_group(name='Group C')\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()\
            .add_filemeta(filename='Test3.java', data='class Test {}')
        detektorassignment = DetektorAssignment.objects.create(
            assignment_id=self.assignmentbuilder.assignment.id,
            processing_started_by=self.testuser)
        AssignmentParser(assignment_id=self.assignmentbuilder.assignment.id).run_detektor()
        CompareManyCollection(detektorassignment).save()

        request = self._create_mock_getrequest(data={
            'language': 'java'
        })
        response = AssignmentAssemblyView.as_view()(
            request, assignmentid=self.assignmentbuilder.assignment.id)
        response.render()

        displaynames = []
        for displayname1, displayname2 in zip(
                [span.text.strip() for span in
                 cssFind(response.content, '#detektorassembly-results .detektorassembly-delivery1-displayname')],
                [span.text.strip() for span in
                 cssFind(response.content, '#detektorassembly-results .detektorassembly-delivery2-displayname')]):
            displaynames.append({displayname1, displayname2})
        self.assertEqual(
            displaynames,
            [
                {'Group A', 'Group B'},
                {'Group A', 'Group C'},
            ])
 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))
Пример #11
0
 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_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')
Пример #13
0
    def test_render_waiting_for_response_from(self):
        inviteuser1 = UserBuilder('inviteuser1').user
        inviteuser2 = UserBuilder('inviteuser2').user
        groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_assignment('assignment1', students_can_create_groups=True)\
            .add_group(students=[self.testuser])
        groupbuilder.add_deadline_in_x_weeks(weeks=1)
        for inviteuser in (inviteuser1, inviteuser2):
            groupbuilder.group.groupinvite_set.create(
                sent_by=self.testuser,
                sent_to=inviteuser)

        html = self._getas(groupbuilder.group.id, self.testuser).content
        names = [element.text.strip() for element in \
            cssFind(html, '#devilry_student_projectgroup_overview_waiting_for_response_from .invite_sent_to_displayname')]
        self.assertEquals(set(names), {'inviteuser1', 'inviteuser2'})
Пример #14
0
 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(),
                '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_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')
Пример #17
0
    def test_render_send_invite_to_selectlist(self):
        UserBuilder('ignoreduser')
        alreadyingroupuser1 = UserBuilder('alreadyingroupuser1').user
        alreadyingroupuser2 = UserBuilder('alreadyingroupuser2').user
        hasinviteuser = UserBuilder('hasinviteuser').user
        matchuser1 = UserBuilder('matchuser1').user
        matchuser2 = UserBuilder('matchuser2', full_name='Match User Two').user

        groupbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
            .add_relatedstudents(
                alreadyingroupuser1, alreadyingroupuser2, hasinviteuser,
                matchuser1, matchuser2)\
            .add_assignment('assignment1', students_can_create_groups=True)\
            .add_group(students=[alreadyingroupuser1, alreadyingroupuser2])
        groupbuilder.add_deadline_in_x_weeks(weeks=1)
        groupbuilder.group.groupinvite_set.create(
            sent_by=alreadyingroupuser1,
            sent_to=hasinviteuser)

        html = self._getas(groupbuilder.group.id, alreadyingroupuser1).content
        send_to_options = [e.text.strip() for e in cssFind(html, '#id_sent_to option')]
        self.assertEquals(set(send_to_options), {'', 'matchuser1', 'Match User Two'})