Ejemplo n.º 1
0
	def test_last_visited_deleted_lesson(self):
		# log in
		self.assertTrue(self.client.login(username=self.username, \
					                         password=self.password))
      # enroll in a course
		self.client.post('/submit_join_course_request', \
				           {'courseid':self.course_id})

		# visit a page
		response = self.client.get("/course/%s/page/%s/" \
				% (self.course_slug, self.lesson_slug))
		self.failUnlessEqual(response.status_code, 200, \
				"Hmm, that's not good; we got a status code of %s instead." \
				% response)

      # remove it
		removePage(Page.objects.get(slug=self.lesson_slug))

		response = self.client.get("/")
		self.failUnlessEqual(response.status_code, 200, \
				"Hmm, that's not good; we got a status code of %s instead." \
				% response)
		self.assertNotContains(response, "last viewing")
		self.assertNotContains(response, "/course/%s/page/%s" % \
				(self.course_slug, self.lesson_slug))
Ejemplo n.º 2
0
def removeLesson(pid, course):
	'''
	Removes a lesson from the database.  Except it f*****g does it wrong.

	TODO: This needs to not return 0 or -1, and it needs to use removePage
	@author John Hartquist
	@author Matthew Tytel
	'''
	try:
		page = Page.objects.get(slug=pid)
		removePage(page)
		return 0
	except Page.DoesNotExist:
		return -1
Ejemplo n.º 3
0
def removeQuiz(self):
	'''
		Removes a quiz from the databass. It will recursivly delete all related
		objects including paths, prerequisites, questions, and answers and the working copy.
		Statistics will be left in the database for data integrity purposes
		but will be unreachable by the program.

		Parameters:
		   self - the quiz being operated on

		@author Evan Kleist
	'''
	questions = self.questions.all()
	prerequisites = self.prerequisites.all()
	paths = self.paths.all()
	workingQuiz = Quiz.objects.get(slug=(self.slug + "_workingCopy"), course=self.course)
	workingQuestions = workingQuiz.questions.all()
	workingPrerequisites = workingQuiz.prerequisites.all()
	workingPaths = workingQuiz.paths.all()

	# Remove Questions
	for q in questions:
		removeQuestion(q)
	for q in workingQuestions:
		removeQuestion(q)

	# Remove Prerequisites
	for p in prerequisites:
		p.delete()
	for p in workingPrerequisites:
		p.delete()

	# Remove Paths
	for p in paths:
		p.delete()
	for p in workingPaths:
		p.delete()

	# Remove Pages
	removePage(self)
	workingQuiz.delete()
	# should also remove all associated quiz objects such as stats, questions, answers, paths
	return 0