Beispiel #1
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 #2
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 #3
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 #4
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)