当前位置: 首页>>代码示例>>Python>>正文


Python NumericActivity.due_date方法代码示例

本文整理汇总了Python中grades.models.NumericActivity.due_date方法的典型用法代码示例。如果您正苦于以下问题:Python NumericActivity.due_date方法的具体用法?Python NumericActivity.due_date怎么用?Python NumericActivity.due_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grades.models.NumericActivity的用法示例。


在下文中一共展示了NumericActivity.due_date方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_activity_status

# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import due_date [as 别名]
 def test_activity_status(self):
     """
     Test operations on activity's status
     """
     # check the get_status_display override
     now = datetime.datetime.now()
     a = NumericActivity(name="Assign 1", short_name="A1", status="INVI", max_grade=10)
     self.assertEquals(a.get_status_display(), ACTIVITY_STATUS["INVI"])
     a.status="RLS"
     self.assertEquals(a.get_status_display(), ACTIVITY_STATUS["RLS"])
     a.status="URLS"
     self.assertEquals(a.get_status_display(), ACTIVITY_STATUS["URLS"])
     a.due_date = now - datetime.timedelta(hours=1)
     self.assertEquals(a.get_status_display(), ACTIVITY_STATUS["URLS"])
     # the special case: unreleased, before the due date
     a.due_date = now + datetime.timedelta(hours=1)
     self.assertEquals(a.get_status_display(), "no grades: due date not passed")
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:19,代码来源:tests.py

示例2: test_group_change

# 需要导入模块: from grades.models import NumericActivity [as 别名]
# 或者: from grades.models.NumericActivity import due_date [as 别名]
    def test_group_change(self):
        """
        Test changing group <-> individual on an activity.  Should only be possible in some conditions.
        """
        s, c = create_offering()

        # add some assignments and members
        due = datetime.datetime.now() + datetime.timedelta(days=1)
        due_date = str(due.date())
        due_time = due.time().strftime("%H:%M:%S")
        a = NumericActivity(name="Assignment 1", short_name="A1", status="RLS", offering=c, position=2, max_grade=15, percent=10, due_date=due, group=False)
        a.save()
        p = Person.objects.get(userid="ggbaker")
        m = Member(person=p, offering=c, role="INST", added_reason="UNK")
        m.save()
        p = Person.objects.get(userid="0aaa0")
        m = Member(person=p, offering=c, role="STUD", added_reason="UNK")
        m.save()
        
        client = Client()
        client.login_user("ggbaker")
        url = reverse('grades.views.edit_activity', kwargs={'course_slug': c.slug, 'activity_slug': a.slug})

        # for whatever reason, '0' is group and '1' is individual for the group value
        submit_dict = {'name': a.name, 'short_name': a.short_name, 'status': a.status, 'due_date_0': due_date, 'due_date_1': due_time, 'percent': a.percent, 'max_grade': a.max_grade, 'group': '1', 'extend_group': 'None'}
        # no change
        response = client.post(url, submit_dict)
        self.assertEquals(response.status_code, 302) # successful submit -> redirect
        self.assertEquals(NumericActivity.objects.get(id=a.id).group, False)

        # change indiv -> group
        submit_dict['group'] = '0'
        response = client.post(url, submit_dict)
        self.assertEquals(response.status_code, 302)
        self.assertEquals(NumericActivity.objects.get(id=a.id).group, True)
        
        # try with activity past due
        a.due_date = datetime.datetime.now() - datetime.timedelta(days=1)
        a.save()
        submit_dict['due_date_0'] = str(a.due_date.date())
        submit_dict['group'] = '0'
        response = client.post(url, submit_dict)
        self.assertEquals(response.status_code, 200) # error on form -> 200 and back to form with error
        self.assertContains(response, "due date has passed")
        
        # try with a mark in the system
        a.due_date = datetime.datetime.now() + datetime.timedelta(days=1)
        a.save()
        submit_dict['due_date_0'] = str(a.due_date.date())
        submit_dict['group'] = '0'
        g = NumericGrade(activity=a, member=m, value=2, flag="GRAD")
        g.save(entered_by='ggbaker')
        response = client.post(url, submit_dict)
        self.assertEquals(response.status_code, 200)
        self.assertContains(response, "grades have already been given")
        
        # try with a submission in the system
        g.flag = "NOGR"
        g.save(entered_by='ggbaker')
        s = StudentSubmission(activity=a, member=m)
        s.save()
        response = client.post(url, submit_dict)
        self.assertEquals(response.status_code, 200)
        self.assertContains(response, "submissions have already been made")
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:66,代码来源:tests.py


注:本文中的grades.models.NumericActivity.due_date方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。