Beispiel #1
0
    def test_faculty_see_submissions(self):
        if not self.users:
            self.extra_users()

        # Create an assignment
        self.assignment = Assignment(course=self.course,
                                     title='Test Assignment',
                                     description='Test',
                                     due_date=(datetime.date.today() -
                                               one_week).isoformat())

        self.assignment.save()

        # Submit it

        self.submission = AssignmentSubmission(
            assignment=self.assignment,
            link='http://example.com',
        )
        self.submission.save()
        self.submission.users.add(self.users[0])

        # Set myself as the faculty for the course.
        self.course.faculty.add(self.user)
        self.course.save()

        response = self.c.get(
            reverse('courses:assignment_overview', args=[self.assignment.id]))

        self.assertEquals(len(response.context['submissions']), 1)

        self.course.faculty.remove(self.user)
        self.course.save()
Beispiel #2
0
    def test_late(self):
        self.assignment = Assignment(course=self.course,
                                     title='Test Assignment',
                                     description='Test',
                                     due_date=(datetime.date.today() -
                                               one_week).isoformat())

        self.assignment.save()

        self.submission = AssignmentSubmission(assignment=self.assignment,
                                               link='http://example.com')
        self.submission.save()
Beispiel #3
0
    def test_faculty_see_submissions(self):
        if not self.users:
            self.extra_users()

        # Create an assignment
        self.assignment = Assignment(course = self.course,
                                     title = 'Test Assignment',
                                     description = 'Test',
                                     due_date = (datetime.date.today() - one_week).isoformat()
            )

        self.assignment.save()

        # Submit it

        self.submission = AssignmentSubmission(assignment = self.assignment,
                                               link = 'http://example.com',
                    )
        self.submission.save()
        self.submission.users.add(self.users[0])

        # Set myself as the faculty for the course.
        self.course.faculty.add(self.user)
        self.course.save()

        response = self.c.get(reverse('courses:assignment_overview', args = [self.assignment.id]))

        self.assertEquals(len(response.context['submissions']), 1)

        self.course.faculty.remove(self.user)
        self.course.save()
Beispiel #4
0
    def test_delete_submission(self):
        # We overrode the delete, so we should be testing it
        self.course.members.add(self.user)

        assignment = Assignment(course = self.course, title = "Test Assignment", description = 'Test of the description <b>HERE</b>', due_date = (datetime.date.today() + one_week).isoformat())
        assignment.save()

        submission = AssignmentSubmission(assignment = assignment, link = "http://www.example.com", notes = "Test notes.")
        submission.save()
        submission.users.add(self.user)
        submission.save()

        s_id = submission.id

        response = self.c.post(reverse('courses:delete_submission'), {'id': submission.id})

        self.assertEquals(response.content, reverse('courses:assignment_overview', kwargs = {'pk': assignment.id}))

        self.assertRaises(AssignmentSubmission.DoesNotExist, AssignmentSubmission.objects.get, pk = s_id)
Beispiel #5
0
    def test_late(self):
        self.assignment = Assignment(course = self.course,
                                     title = 'Test Assignment',
                                     description = 'Test',
                                     due_date = (datetime.date.today() - one_week).isoformat()
            )

        self.assignment.save()

        self.submission = AssignmentSubmission(assignment = self.assignment,
                                               link = 'http://example.com')
        self.submission.save()
Beispiel #6
0
    def test_delete_submission(self):
        # We overrode the delete, so we should be testing it
        self.course.members.add(self.user)
        self.course.save()

        assignment = Assignment(
            course=self.course,
            title="Test Assignment",
            description='Test of the description <b>HERE</b>',
            due_date=(datetime.date.today() + one_week).isoformat())
        assignment.save()

        submission = AssignmentSubmission(assignment=assignment,
                                          link="http://www.example.com",
                                          notes="Test notes.")
        submission.save()
        submission.users.add(self.user)
        submission.save()

        s_id = submission.id

        response = self.c.post(reverse('courses:delete_submission'),
                               {'id': submission.id})

        self.assertEquals(
            response.content,
            reverse('courses:assignment_overview',
                    kwargs={'pk': assignment.id}))

        self.assertRaises(AssignmentSubmission.DoesNotExist,
                          AssignmentSubmission.objects.get,
                          pk=s_id)
Beispiel #7
0
def submit_assignment(request):
	course_code = request.GET.get('code')
	aname = request.GET.get('aname')
	ccourse = CurrentCourse.objects.get(course_code=course_code)
	assignment = Assignment.objects.get(course=ccourse,name=aname)
	student = Student.objects.get(username=request.user.username)
	alink = get_download_link(dbx,course_code,assignment.filename,'assignments')
	sfile = None
	data = {'assgn':assignment,'course_code':course_code,'alink':alink}
	if request.method=='POST' and request.FILES['sfile']:
		sfile = request.FILES['sfile']
		if sfile is not None:
			sub_folder = os.path.join(course_code,'submissions')
			if not check(dbx,sub_folder):
				create_folder(dbx,sub_folder)
			filename = student.username + '|' + sfile.name
			result = upload_to_dropbox(dbx,sfile,filename,course_code,datetime.datetime.now(),subfolder='submissions')
			asub = AssignmentSubmission(assignment=assignment,student=student,solution_file=sfile.name,
				status='S')
			asub.save()
			print result
		return HttpResponseRedirect("%s?code=%s" % (reverse('student:assignments'),course_code))
	else:	
		return render(request,'students/submit_assignment.html',data)		
Beispiel #8
0
class AssignmentTest(test_utils.AuthenticatedTest):
    def setUp(self):
        super(AssignmentTest, self).setUp()
        self.semester = Semester(name='Spring', year = '2012', start = datetime.date(2012, 1, 1), end = datetime.date(2012, 5, 1))
        self.semester.save()
        self.course = Course(title='Test Course', number = '101', section = '001', description = 'Test description of a course', semester = self.semester)
        self.course.save()

    def tearDown(self):
        super(AssignmentTest, self).tearDown()
        self.course.delete()
        self.semester.delete()

    def test_create(self):
        # Add client user as faculty member
        self.course.faculty.add(self.user)
        self.course.save()

        # Test we get the form
        response = self.c.get(reverse('courses:new_assignment', kwargs = {'pk':self.course.id}))
        self.assertEquals(response.status_code, 200)

        response = self.c.post(reverse('courses:new_assignment', kwargs = {'pk':self.course.id}), {'course':self.course.id,
                                                                                            'title':'Test Assignment',
                                                                                            'description':'Test of the description <b>HERE</b>',
                                                                                            'due_date': (datetime.date.today() + one_week).isoformat()})

        self.assertEquals(response.status_code, 302)

        # Remove user
        self.course.faculty.remove(self.user)


    def test_list(self):
        assignment = Assignment(course = self.course, title = "Test Assignment", description = 'Test of the description <b>HERE</b>', due_date = (datetime.date.today() + one_week).isoformat())
        assignment.save()

        # Add client user as faculty member
        self.course.faculty.add(self.user)
        self.course.save()
        
        response = self.c.get(reverse('courses:assignments', kwargs = {'pk':self.course.id}))

        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.context['assignments'][0], assignment)

        # Remove user
        self.course.faculty.remove(self.user)

    def test_submit(self):
        # Add client user as faculty member
        self.course.faculty.add(self.user)
        self.course.save()
        response = self.c.post(reverse('courses:new_assignment', kwargs = {'pk':self.course.id}), {'course':self.course.id,
                                                                                            'title':'Test Assignment',
                                                                                            'description':'Test of the description <b>HERE</b>',
                                                                                            'due_date': (datetime.date.today() + one_week).isoformat()})

        # Remove user
        self.course.faculty.remove(self.user)

        self.course.members.add(self.user)
        self.course.save()

        assignment = Assignment.objects.get(course = self.course, title = 'Test Assignment')

        # Test submitting solution
        response = self.c.post(reverse('courses:submit_assignment', kwargs = {'pk':assignment.id}), {'link':'http://www.example.com',
                                                                                                     'notes':'Test notes.',})
        self.assertEquals(response.status_code, 302)

        self.course.members.remove(self.user)


    def test_faculty_see_submissions(self):
        if not self.users:
            self.extra_users()

        # Create an assignment
        self.assignment = Assignment(course = self.course,
                                     title = 'Test Assignment',
                                     description = 'Test',
                                     due_date = (datetime.date.today() - one_week).isoformat()
            )

        self.assignment.save()

        # Submit it

        self.submission = AssignmentSubmission(assignment = self.assignment,
                                               link = 'http://example.com',
                    )
        self.submission.save()
        self.submission.users.add(self.users[0])

        # Set myself as the faculty for the course.
        self.course.faculty.add(self.user)
        self.course.save()

        response = self.c.get(reverse('courses:assignment_overview', args = [self.assignment.id]))

        self.assertEquals(len(response.context['submissions']), 1)

        self.course.faculty.remove(self.user)
        self.course.save()


    def test_late(self):
        self.assignment = Assignment(course = self.course,
                                     title = 'Test Assignment',
                                     description = 'Test',
                                     due_date = (datetime.date.today() - one_week).isoformat()
            )

        self.assignment.save()

        self.submission = AssignmentSubmission(assignment = self.assignment,
                                               link = 'http://example.com')
        self.submission.save()
        


    def test_delete_submission(self):
        # We overrode the delete, so we should be testing it
        self.course.members.add(self.user)
        self.course.save()

        assignment = Assignment(course = self.course, title = "Test Assignment", description = 'Test of the description <b>HERE</b>', due_date = (datetime.date.today() + one_week).isoformat())
        assignment.save()

        submission = AssignmentSubmission(assignment = assignment, link = "http://www.example.com", notes = "Test notes.")
        submission.save()
        submission.users.add(self.user)
        submission.save()

        s_id = submission.id

        response = self.c.post(reverse('courses:delete_submission'), {'id': submission.id})

        self.assertEquals(response.content, reverse('courses:assignment_overview', kwargs = {'pk': assignment.id}))

        self.assertRaises(AssignmentSubmission.DoesNotExist, AssignmentSubmission.objects.get, pk = s_id)

    def test_team_submit(self):
        if not self.users:
            self.extra_users()

        # Add client user as faculty member
        self.course.faculty.add(self.user)
        self.course.save()
        response = self.c.post(reverse('courses:new_assignment', kwargs = {'pk':self.course.id}), {'course':self.course.id,
                                                                                            'title':'Test Assignment',
                                                                                            'description':'Test of the description <b>HERE</b>',
                                                                                            'due_date': (datetime.date.today() + one_week).isoformat()})

        # Remove user
        self.course.faculty.remove(self.user)
        self.course.members.add(self.user)
        self.course.save()

        for user in self.users:
            self.course.members.add(user)

        self.course.save()
        
        assignment = Assignment.objects.get(course = self.course, title = 'Test Assignment')

        # Test submitting solution
        response = self.c.post(reverse('courses:team_submit_assignment', kwargs = {'pk':assignment.id}), {'link':'http://www.example.com',
                                                                                                     'notes':'Test notes.',
                                                                                                     'users':[user.id for user in self.users]})
        self.assertEquals(response.status_code, 302)

        self.course.members.remove(self.user)

        for user in self.users:
            self.course.members.remove(user)
Beispiel #9
0
class AssignmentTest(test_utils.AuthenticatedTest):
    def setUp(self):
        super(AssignmentTest, self).setUp()
        self.semester = Semester(name='Spring',
                                 year='2012',
                                 start=datetime.date(2012, 1, 1),
                                 end=datetime.date(2012, 5, 1))
        self.semester.save()
        self.course = Course(title='Test Course',
                             number='101',
                             section='001',
                             description='Test description of a course',
                             semester=self.semester)
        self.course.save()

    def tearDown(self):
        super(AssignmentTest, self).tearDown()
        self.course.delete()
        self.semester.delete()

    def test_create(self):
        # Add client user as faculty member
        self.course.faculty.add(self.user)
        self.course.save()

        # Test we get the form
        response = self.c.get(
            reverse('courses:new_assignment', kwargs={'pk': self.course.id}))
        self.assertEquals(response.status_code, 200)

        response = self.c.post(
            reverse('courses:new_assignment', kwargs={'pk': self.course.id}), {
                'course': self.course.id,
                'title': 'Test Assignment',
                'description': 'Test of the description <b>HERE</b>',
                'due_date': (datetime.date.today() + one_week).isoformat()
            })

        self.assertEquals(response.status_code, 302)

        # Remove user
        self.course.faculty.remove(self.user)

    def test_list(self):
        assignment = Assignment(
            course=self.course,
            title="Test Assignment",
            description='Test of the description <b>HERE</b>',
            due_date=(datetime.date.today() + one_week).isoformat())
        assignment.save()

        # Add client user as faculty member
        self.course.faculty.add(self.user)
        self.course.save()

        response = self.c.get(
            reverse('courses:assignments', kwargs={'pk': self.course.id}))

        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.context['assignments'][0], assignment)

        # Remove user
        self.course.faculty.remove(self.user)

    def test_submit(self):
        # Add client user as faculty member
        self.course.faculty.add(self.user)
        self.course.save()
        response = self.c.post(
            reverse('courses:new_assignment', kwargs={'pk': self.course.id}), {
                'course': self.course.id,
                'title': 'Test Assignment',
                'description': 'Test of the description <b>HERE</b>',
                'due_date': (datetime.date.today() + one_week).isoformat()
            })

        # Remove user
        self.course.faculty.remove(self.user)

        self.course.members.add(self.user)
        self.course.save()

        assignment = Assignment.objects.get(course=self.course,
                                            title='Test Assignment')

        # Test submitting solution
        response = self.c.post(
            reverse('courses:submit_assignment', kwargs={'pk': assignment.id}),
            {
                'link': 'http://www.example.com',
                'notes': 'Test notes.',
            })
        self.assertEquals(response.status_code, 302)

        self.course.members.remove(self.user)

    def test_faculty_see_submissions(self):
        if not self.users:
            self.extra_users()

        # Create an assignment
        self.assignment = Assignment(course=self.course,
                                     title='Test Assignment',
                                     description='Test',
                                     due_date=(datetime.date.today() -
                                               one_week).isoformat())

        self.assignment.save()

        # Submit it

        self.submission = AssignmentSubmission(
            assignment=self.assignment,
            link='http://example.com',
        )
        self.submission.save()
        self.submission.users.add(self.users[0])

        # Set myself as the faculty for the course.
        self.course.faculty.add(self.user)
        self.course.save()

        response = self.c.get(
            reverse('courses:assignment_overview', args=[self.assignment.id]))

        self.assertEquals(len(response.context['submissions']), 1)

        self.course.faculty.remove(self.user)
        self.course.save()

    def test_late(self):
        self.assignment = Assignment(course=self.course,
                                     title='Test Assignment',
                                     description='Test',
                                     due_date=(datetime.date.today() -
                                               one_week).isoformat())

        self.assignment.save()

        self.submission = AssignmentSubmission(assignment=self.assignment,
                                               link='http://example.com')
        self.submission.save()

    def test_delete_submission(self):
        # We overrode the delete, so we should be testing it
        self.course.members.add(self.user)
        self.course.save()

        assignment = Assignment(
            course=self.course,
            title="Test Assignment",
            description='Test of the description <b>HERE</b>',
            due_date=(datetime.date.today() + one_week).isoformat())
        assignment.save()

        submission = AssignmentSubmission(assignment=assignment,
                                          link="http://www.example.com",
                                          notes="Test notes.")
        submission.save()
        submission.users.add(self.user)
        submission.save()

        s_id = submission.id

        response = self.c.post(reverse('courses:delete_submission'),
                               {'id': submission.id})

        self.assertEquals(
            response.content,
            reverse('courses:assignment_overview',
                    kwargs={'pk': assignment.id}))

        self.assertRaises(AssignmentSubmission.DoesNotExist,
                          AssignmentSubmission.objects.get,
                          pk=s_id)

    def test_team_submit(self):
        if not self.users:
            self.extra_users()

        # Add client user as faculty member
        self.course.faculty.add(self.user)
        self.course.save()
        response = self.c.post(
            reverse('courses:new_assignment', kwargs={'pk': self.course.id}), {
                'course': self.course.id,
                'title': 'Test Assignment',
                'description': 'Test of the description <b>HERE</b>',
                'due_date': (datetime.date.today() + one_week).isoformat()
            })

        # Remove user
        self.course.faculty.remove(self.user)
        self.course.members.add(self.user)
        self.course.save()

        for user in self.users:
            self.course.members.add(user)

        self.course.save()

        assignment = Assignment.objects.get(course=self.course,
                                            title='Test Assignment')

        # Test submitting solution
        response = self.c.post(
            reverse('courses:team_submit_assignment',
                    kwargs={'pk': assignment.id}), {
                        'link': 'http://www.example.com',
                        'notes': 'Test notes.',
                        'users': [user.id for user in self.users]
                    })
        self.assertEquals(response.status_code, 302)

        self.course.members.remove(self.user)

        for user in self.users:
            self.course.members.remove(user)