Exemple #1
0
    def test_add_common_problems(self):
        c = CourseOffering.objects.get(slug = self.c_slug)
        a = NumericActivity(offering = c, name = 'test_assignment_1', \
                            short_name = 'ta1', status = 'RLS', \
                            due_date = datetime.now(), max_grade = 100, position = 1)
        a.save()        
        co1 = ActivityComponent(numeric_activity = a, title = 'part1', max_mark = 50, position = 1)
        co2 = ActivityComponent(numeric_activity = a, title = 'part2', max_mark = 50, position = 2) 
        co1.save()
        co2.save()
        
        #add some common problems
        cp1 = CommonProblem(activity_component = co1, title = 'cp1', penalty="0")
        cp2 = CommonProblem(activity_component = co1, title = 'cp2', penalty="1.12")        
        cp3 = CommonProblem(activity_component = co2, title = 'cp3', penalty="-2.3")
        
        cp1.save()
        cp2.save()
        cp3.save()
        
        self.client.login_user('ggbaker')        

        response = basic_page_tests(self, self.client, reverse(manage_common_problems, args=(self.c_slug,a.slug)))
        
        forms = response.context['formset'].forms
 
        ins0 = forms[0].instance
        ins1 = forms[1].instance
        ins2 = forms[2].instance
        
        self.assertEquals(ins0.title, 'cp1')
        self.assertEquals(ins0.activity_component, co1)
        self.assertEquals(ins1.title, 'cp2')
        self.assertEquals(ins1.activity_component, co1)
        self.assertEquals(ins2.title, 'cp3')
        self.assertEquals(ins2.activity_component, co2)
        
        #test the marking page as well        
        url = reverse(marking_student, args=(self.c_slug, a.slug, '0aaa0'))
        response = basic_page_tests(self, self.client, url)
        
        mark_components = response.context['component_data']
        com1 = mark_components[0]
        com2 = mark_components[1]
        
        self.assertEquals(com1['component'], co1)
        self.assertEquals(len(com1['common_problems']), 2)
        self.assertEquals(com2['component'], co2)
        self.assertEquals(len(com2['common_problems']), 1)
Exemple #2
0
    def test_add_common_problems(self):
        c = CourseOffering.objects.get(slug=self.c_slug)
        a = NumericActivity(offering = c, name = 'test_assignment_1', \
                            short_name = 'ta1', status = 'RLS', \
                            due_date = datetime.now(), max_grade = 100, position = 1)
        a.save()
        co1 = ActivityComponent(numeric_activity=a,
                                title='part1',
                                max_mark=50,
                                position=1)
        co2 = ActivityComponent(numeric_activity=a,
                                title='part2',
                                max_mark=50,
                                position=2)
        co1.save()
        co2.save()

        #add some common problems
        cp1 = CommonProblem(activity_component=co1, title='cp1', penalty="0")
        cp2 = CommonProblem(activity_component=co1,
                            title='cp2',
                            penalty="1.12")
        cp3 = CommonProblem(activity_component=co2,
                            title='cp3',
                            penalty="-2.3")

        cp1.save()
        cp2.save()
        cp3.save()

        self.client.login_user('ggbaker')

        response = basic_page_tests(
            self, self.client,
            reverse('offering:marking:manage_common_problems',
                    args=(self.c_slug, a.slug)))

        forms = response.context['formset'].forms

        ins0 = forms[0].instance
        ins1 = forms[1].instance
        ins2 = forms[2].instance

        self.assertEquals(ins0.title, 'cp1')
        self.assertEquals(ins0.activity_component, co1)
        self.assertEquals(ins1.title, 'cp2')
        self.assertEquals(ins1.activity_component, co1)
        self.assertEquals(ins2.title, 'cp3')
        self.assertEquals(ins2.activity_component, co2)

        #test the marking page as well
        url = reverse('offering:marking:marking_student',
                      args=(self.c_slug, a.slug, '0aaa0'))
        response = basic_page_tests(self, self.client, url)

        mark_components = response.context['component_data']
        com1 = mark_components[0]
        com2 = mark_components[1]

        self.assertEquals(com1['component'], co1)
        self.assertEquals(len(com1['common_problems']), 2)
        self.assertEquals(com2['component'], co2)
        self.assertEquals(len(com2['common_problems']), 1)
Exemple #3
0
    def test_frontend(self):
        client = Client()
        client.login_user('ggbaker')

        # set up a course
        c = CourseOffering.objects.get(slug=self.c_slug)
        a1 = NumericActivity(offering = c, name = 'test_assignment_1', \
                            short_name = 'ta1', status = 'RLS', \
                            due_date = datetime.now(), max_grade = 100, position = 0, group=True)
        a1.save()
        a2 = NumericActivity(offering = c, name = 'test_assignment_1', \
                            short_name = 'ta1', status = 'RLS', \
                            due_date = datetime.now(), max_grade = 100, position = 0, group=False)
        a2.save()

        stud1 = Member.objects.get(person=Person.objects.get(userid='0aaa0'),
                                   offering=c)
        stud2 = Member.objects.get(person=Person.objects.get(userid='0aaa1'),
                                   offering=c)
        instr = Member.objects.get(person=Person.objects.get(userid='ggbaker'),
                                   offering=c)
        group = Group.objects.create(courseoffering=c,
                                     name='hello',
                                     manager=stud1)
        member1 = GroupMember.objects.create(group=group,
                                             student=stud1,
                                             confirmed=True,
                                             activity=a1)
        member2 = GroupMember.objects.create(group=group,
                                             student=stud2,
                                             confirmed=True,
                                             activity=a1)

        # marking form (student)
        url = reverse('offering:marking:marking_student',
                      kwargs={
                          'course_slug': c.slug,
                          'activity_slug': a2.slug,
                          'userid': stud1.person.userid
                      })

        response = basic_page_tests(self, client, url)

        ac = ActivityComponent(numeric_activity=a2,
                               max_mark=5,
                               title="AC Title",
                               description="AC Description",
                               position=1,
                               deleted=False)
        ac.save()
        ac = ActivityComponent(numeric_activity=a2,
                               max_mark=5,
                               title="AC Title2",
                               description="AC Description2",
                               position=2,
                               deleted=False)
        ac.save()
        cp = CommonProblem(activity_component=ac,
                           title="CP title",
                           penalty=2,
                           description="Cp description",
                           deleted=False)
        cp.save()

        response = basic_page_tests(self, client, url)

        # submit the form and check that objects were created
        PENALTY = '12.5'  # Percentage
        CMP_1_VALUE = '5.5'
        CMP_2_VALUE = '3'
        ADJ = '1.25'  # Adjustments are subtracted
        TOTAL_MARK = (
            (Decimal(CMP_1_VALUE) + Decimal(CMP_2_VALUE) - Decimal(ADJ)) *
            (1 - (Decimal(PENALTY) / 100))).quantize(Decimal('.01'),
                                                     rounding=ROUND_HALF_EVEN)

        response = client.post(
            url, {
                'cmp-1-value': float(CMP_1_VALUE),
                'cmp-1-comment': 'perfect part 1',
                'cmp-2-value': float(CMP_2_VALUE),
                'cmp-2-comment': 'ok',
                'mark_adjustment': float(ADJ),
                'mark_adjustment_reason': 'reason',
                'late_penalty': float(PENALTY),
                u'overall_comment': 'overall'
            })
        self.assertEquals(response.status_code, 302)
        sam = StudentActivityMark.objects.filter(activity=a2,
                                                 numeric_grade__member=stud1)
        self.assertEquals(len(sam), 1)
        sam = sam[0]
        self.assertEquals(sam.mark_adjustment, Decimal(ADJ))
        self.assertEquals(sam.late_penalty, Decimal(PENALTY))
        self.assertEquals(sam.overall_comment, 'overall')
        self.assertEquals(sam.mark, TOTAL_MARK)
        acms = sam.activitycomponentmark_set.all()
        self.assertEquals(len(acms), 2)
        self.assertEquals(acms[0].value, Decimal(CMP_1_VALUE))
        self.assertEquals(acms[0].comment, 'perfect part 1')
        g = NumericGrade.objects.get(activity=a2, member=stud1)
        self.assertEquals(g.value, TOTAL_MARK)

        # make sure we get old data for "mark based on"
        response = basic_page_tests(self, client,
                                    url + "?base_activity_mark=" + str(sam.id))
        #self.assertContains(response, 'name="cmp-1-value" type="text" value="{0}'.format(CMP_1_VALUE))
        #self.assertContains(response, 'name="late_penalty" type="text" value="{0}'.format(PENALTY))

        # look at the "view details" page
        url = reverse('offering:marking:mark_summary_student',
                      kwargs={
                          'course_slug': c.slug,
                          'activity_slug': a2.slug,
                          'userid': stud1.person.userid
                      })
        response = basic_page_tests(self, client, url)
        self.assertContains(response, 'perfect part 1')

        # marking form (group)
        url = reverse('offering:marking:marking_student',
                      kwargs={
                          'course_slug': c.slug,
                          'activity_slug': a1.slug,
                          'userid': stud1.person.userid
                      })
        response = basic_page_tests(self, client, url)

        ac = ActivityComponent(numeric_activity=a1,
                               max_mark=5,
                               title="AC Title",
                               description="AC Description",
                               position=1,
                               deleted=False)
        ac.save()
        ac = ActivityComponent(numeric_activity=a1,
                               max_mark=5,
                               title="AC Title2",
                               description="AC Description2",
                               position=2,
                               deleted=False)
        ac.save()
        cp = CommonProblem(activity_component=ac,
                           title="CP title",
                           penalty=2,
                           description="Cp description",
                           deleted=False)
        cp.save()

        response = basic_page_tests(self, client, url)

        # common problem form
        url = reverse('offering:marking:manage_common_problems',
                      kwargs={
                          'course_slug': c.slug,
                          'activity_slug': a2.slug
                      })
        response = basic_page_tests(self, client, url)

        # mark all (student and group)
        url = reverse('offering:mark_all_students',
                      kwargs={
                          'course_slug': c.slug,
                          'activity_slug': a2.slug
                      })
        response = basic_page_tests(self, client, url)
        # mark all (student and group)
        url = reverse('offering:mark_all_groups',
                      kwargs={
                          'course_slug': c.slug,
                          'activity_slug': a1.slug
                      })
        response = basic_page_tests(self, client, url)
Exemple #4
0
    def test_frontend(self):
        client = Client()
        client.login_user('ggbaker')
        
        # set up a course
        c = CourseOffering.objects.get(slug = self.c_slug)
        a1 = NumericActivity(offering = c, name = 'test_assignment_1', \
                            short_name = 'ta1', status = 'RLS', \
                            due_date = datetime.now(), max_grade = 100, position = 0, group=True)
        a1.save()
        a2 = NumericActivity(offering = c, name = 'test_assignment_1', \
                            short_name = 'ta1', status = 'RLS', \
                            due_date = datetime.now(), max_grade = 100, position = 0, group=False)
        a2.save()
        
        stud1 = Member.objects.get(person = Person.objects.get(userid = '0aaa0'), offering = c)
        stud2 = Member.objects.get(person = Person.objects.get(userid = '0aaa1'), offering = c)
        instr = Member.objects.get(person = Person.objects.get(userid = 'ggbaker'), offering = c)
        group = Group.objects.create(courseoffering = c, name = 'hello', manager = stud1)
        member1 = GroupMember.objects.create(group = group, student = stud1, confirmed = True, activity=a1)
        member2 = GroupMember.objects.create(group = group, student = stud2, confirmed = True, activity=a1)
        
        # marking form (student)
        url = reverse('marking.views.marking_student', kwargs={'course_slug':c.slug, 'activity_slug':a2.slug, 'userid':stud1.person.userid})

        response = basic_page_tests(self, client, url)
        
        ac = ActivityComponent(numeric_activity=a2, max_mark=5, title="AC Title", description="AC Description", position=1, deleted=False)
        ac.save()
        ac = ActivityComponent(numeric_activity=a2, max_mark=5, title="AC Title2", description="AC Description2", position=2, deleted=False)
        ac.save()
        cp = CommonProblem(activity_component=ac, title="CP title", penalty=2, description="Cp description", deleted=False)
        cp.save()

        response = basic_page_tests(self, client, url)
        
        # submit the form and check that objects were created
        PENALTY = '12.5' # Percentage
        CMP_1_VALUE = '5.5'
        CMP_2_VALUE = '3'
        ADJ = '1.25'# Adjustments are subtracted
        TOTAL_MARK = ((Decimal(CMP_1_VALUE) + Decimal(CMP_2_VALUE) - Decimal(ADJ)) *
            (1 - (Decimal(PENALTY) / 100))).quantize(Decimal('.01'), rounding=ROUND_HALF_EVEN)

        response = client.post(url, {'cmp-1-value': float(CMP_1_VALUE), 'cmp-1-comment': 'perfect part 1',
            'cmp-2-value': float(CMP_2_VALUE), 'cmp-2-comment': 'ok', 'mark_adjustment': float(ADJ),
            'mark_adjustment_reason': 'reason', 'late_penalty': float(PENALTY),
            u'overall_comment': 'overall'})
        self.assertEquals(response.status_code, 302)
        sam = StudentActivityMark.objects.filter(activity=a2, numeric_grade__member=stud1)
        self.assertEquals(len(sam), 1)
        sam = sam[0]
        self.assertEquals(sam.mark_adjustment, Decimal(ADJ))
        self.assertEquals(sam.late_penalty, Decimal(PENALTY))
        self.assertEquals(sam.overall_comment, 'overall')
        self.assertEquals(sam.mark, TOTAL_MARK)
        acms = sam.activitycomponentmark_set.all()
        self.assertEquals(len(acms), 2)
        self.assertEquals(acms[0].value, Decimal(CMP_1_VALUE))
        self.assertEquals(acms[0].comment, 'perfect part 1')
        g = NumericGrade.objects.get(activity=a2, member=stud1)
        self.assertEquals(g.value, TOTAL_MARK)
        
        # make sure we get old data for "mark based on"
        response = basic_page_tests(self, client, url + "?base_activity_mark="+str(sam.id))
        #self.assertContains(response, 'name="cmp-1-value" type="text" value="{0}'.format(CMP_1_VALUE))
        #self.assertContains(response, 'name="late_penalty" type="text" value="{0}'.format(PENALTY))

        # look at the "view details" page
        url = reverse('marking.views.mark_summary_student', kwargs={'course_slug':c.slug, 'activity_slug':a2.slug, 'userid':stud1.person.userid})
        response = basic_page_tests(self, client, url)
        self.assertContains(response, 'perfect part 1')

        # marking form (group)
        url = reverse('marking.views.marking_student', kwargs={'course_slug':c.slug,
            'activity_slug':a1.slug, 'userid':stud1.person.userid})
        response = basic_page_tests(self, client, url)
        
        ac = ActivityComponent(numeric_activity=a1, max_mark=5, title="AC Title",
            description="AC Description", position=1, deleted=False)
        ac.save()
        ac = ActivityComponent(numeric_activity=a1, max_mark=5, title="AC Title2",
            description="AC Description2", position=2, deleted=False)
        ac.save()
        cp = CommonProblem(activity_component=ac, title="CP title", penalty=2,
            description="Cp description", deleted=False)
        cp.save()

        response = basic_page_tests(self, client, url)

        # common problem form
        url = reverse('marking.views.manage_common_problems', kwargs={'course_slug':c.slug, 'activity_slug':a2.slug})
        response = basic_page_tests(self, client, url)
        
        # mark all (student and group)
        url = reverse('marking.views.mark_all_students', kwargs={'course_slug':c.slug, 'activity_slug':a2.slug})
        response = basic_page_tests(self, client, url)
        # mark all (student and group)
        url = reverse('marking.views.mark_all_groups', kwargs={'course_slug':c.slug, 'activity_slug':a1.slug})
        response = basic_page_tests(self, client, url)