Esempio n. 1
0
 def test_groups(self):
     group = StudentGroup(course_instance=self.current_course_instance)
     group.save()
     group.members.add(self.user.userprofile,self.grader.userprofile)
     self.assertEqual(StudentGroup.get_exact(self.current_course_instance,
         [self.user.userprofile,self.grader.userprofile]), group)
     self.assertEqual(StudentGroup.get_exact(self.current_course_instance,
         [self.user.userprofile,self.superuser.userprofile]), None)
Esempio n. 2
0
 def test_groups(self):
     group = StudentGroup(course_instance=self.current_course_instance)
     group.save()
     group.members.add(self.user.userprofile,self.grader.userprofile)
     self.assertEqual(StudentGroup.get_exact(self.current_course_instance,
         [self.user.userprofile,self.grader.userprofile]), group)
     self.assertEqual(StudentGroup.get_exact(self.current_course_instance,
         [self.user.userprofile,self.superuser.userprofile]), None)
Esempio n. 3
0
def modify_default_courses():
    from course.models import Course, CourseInstance, Enrollment, StudentGroup

    # The container has already created the default database, but we
    # modify some settings of the course instance here.
    course = Course.objects.get(url="def", )

    instance = CourseInstance.objects.get(
        course=course,
        url="current",
    )

    #instance.head_urls =
    #        "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_CHTML-full&delayStartupUntil=onload"
    #instance.view_content_to = CourseInstance.VIEW_ACCESS.ENROLLED
    #instance.view_content_to = CourseInstance.VIEW_ACCESS.PUBLIC
    #if not instance.description:
    #    instance.description = '<p><b>TESTing</b> course instance description.</p><p>Hello course!</p>'
    #instance.save()

    from django.contrib.auth.models import User

    teacher = User.objects.get(username="******")

    course2, created = Course.objects.get_or_create(
        name="Test course 2",
        code='testcourse2',
        url='testcourse2',
    )
    if created:
        course2.teachers.set([teacher.userprofile])
        course2.save()
    now = timezone.now()
    try:
        instance2 = CourseInstance.objects.get(
            course=course2,
            instance_name="Test instance",
            url='test',
        )
        instance2.starting_time = now
        instance2.ending_time = now + timedelta(days=365)
        instance2.save()
    except CourseInstance.DoesNotExist:
        instance2 = CourseInstance.objects.create(
            course=course2,
            instance_name="Test instance",
            url='test',
            starting_time=now,
            ending_time=now + timedelta(days=365),
        )

    # enroll students
    for i in range(2, 100):
        user = User.objects.get(username="******" + str(i))
        Enrollment.objects.get_or_create(course_instance=instance,
                                         user_profile=user.userprofile)

    # student groups
    for i in range(2, 90, 3):
        group = StudentGroup(course_instance=instance)
        group.save()
        member1 = User.objects.get(username="******" + str(i))
        member2 = User.objects.get(username="******" + str(i + 1))
        group.members.add(member1.userprofile, member2.userprofile)

    # UserTags
    create_user_tags(instance)

    ###########################################################
    # add submissions for testing
    from course.models import CourseModule
    from exercise.exercise_models import BaseExercise, LearningObject
    from exercise.submission_models import Submission
    time.sleep(
        4
    )  # let the database initialize the course (JSON import from the mooc-grader)

    student1 = User.objects.get(username='******', )
    # module from the aplus-manual course
    course_module = CourseModule.objects.get(
        url='m01_introduction',
        course_instance=instance,
    )
    exercise = BaseExercise.objects.get(
        course_module=course_module,
        url='m01_introduction_07_questionnaires_questionnaire_demo',
        #order=1,
    )
    for i in range(300):
        new_submission = Submission.objects.create(exercise=exercise,
                                                   #submission_data={},
                                                   )
        new_submission.submitters.set([student1.userprofile])
        if random.random() > 0.3:  # randomly grade some submissions
            new_submission.set_points(random.randint(0, 50), 50)
            new_submission.set_ready()
            new_submission.save()