def writeTurningPointClickerIDs(self):
		# This is where the work is done. Need to read in the class
		# list and the answers to the moodle quiz asking the students
		# what there clicker ID is. After matching them up the Turning
		# Point clicker ID file is written out.
		#self.moodleIDNumbers = {}

		# Go through each csv file that has the section information in it.
		defaultXMLFileName = None
		itemScores = TurningPointFile(self)

		# Add all of the section information to the itemScores list.
		writtenSections = self.specifySectionClassLists(itemScores,None,True)
		if(not writtenSections):
			tkMessageBox.showinfo(
				"OK",
				"No section files have been specified. Please choose a default file name for the one xml output file.");

			defaultXMLFileName = tkFileDialog.asksaveasfile(mode='w',
															filetypes= [("tplx files",".tplx"),
																		('all files', '.*')]);

			if(defaultXMLFileName):
				itemScores.addSection(None,defaultXMLFileName,None)

		# set the xml tree to the end of the AllScores section list
		# Get the title that will be displayed in the turning point window for each file.
        # COMMENTED OUT CUZ WE WANT TO USE TURNING POINT XML FILES TO GET THE IDs
		#for section in itemScores:
		#	moodleIDRequest = SimpleRequestDialog(
		#		self, \
		#		"What is the title to use for the information for\n file {0}".format( \
		#		section[1].name),
		#		"Turning Point Title");
		#	self.wait_window(moodleIDRequest.getTop())
		#	section[2] = AssignTurningPointClickerIDs(section[1],moodleIDRequest.getResult())

		#	if(itemScores.isSingleOutFile()):
		#		break


		# Prepare to start the process of going through the grade files.
		numberGradeRows = self.gradeListBox.size()

		# Go through each grade data file and read it in.
		readResults = ""
		for row in range(numberGradeRows) :
			if(self.DEBUG):
				 print(" reading response file: {0}".format(self.gradeListBox.get(row)))

			# Read in and create the xml file. For now just save it.
			readResults += self.addClickerIDs(self.gradeListBox.get(row),itemScores)

		# Now go through and create the xml tree for every section.
		if(itemScores.isSingleOutFile()):
			# only need to save the tree for one tree
			section = itemScores.getSection(0)
			section[2].constructTree()
		else:
			# Need to save a tree for every section.
			for section in itemScores:
				#print(section)
				section[2].constructTree()


		#if(len(readResults)>0):
		#	 print(readResults)
		numberSections = itemScores.getNumberOfSections()
		currentSectionNumber = 0
		for section in itemScores:
			closeFile = True
			if(currentSectionNumber < numberSections-1):
				nextSection = itemScores.getSection(currentSectionNumber+1)
				if(nextSection[1].name == section[1].name):
					 closeFile = False
			
			if(section[2]):
			   section[2].writeXML(closeFile)
			   
			currentSectionNumber += 1

			if(itemScores.isSingleOutFile()):
				break;
	def writeGradesFromTurningPoint(self):
		# This is where the work is done. Need to read in the xml
		# files that have the sections information in them. Then read
		# the grade files. The create the xml files for output.
		#print("Write grades")
		self.moodleIDNumbers = {}
		itemScores = TurningPointFile(self)
		itemScores.setRegradeState(self.overwriteOld.get())
		itemScores.setNumericState(self.numericGrade.get())
		itemScores.setCSVOutfile(self.writeCSV.get())

			# See http://docs.moodle.org/en/Development:Grades for the
			# details on the xml format.



		# Go through each xml file that has the section information in it.
		defaultXMLFileName = None
		writtenSections = self.specifySectionClassLists(itemScores) # ,[('tpzx files', '.tpzx')])
		if(not writtenSections):
			tkMessageBox.showinfo(
				"OK",
				"No section files have been specified. Please choose a default file name for the one xml output file.");

			if(self.writeCSV.get()):
				fileExtensions = [('csv files', '.csv')]
			else:
				fileExtensions = [('xml files', '.xml')]
			fileExtensions.append(('all files', '.*'))
			#fileExtensions.append(('tpzx files', '.tpzx'))

			defaultXMLFileName = tkFileDialog.asksaveasfile(mode='w',filetypes=fileExtensions);

			if(defaultXMLFileName):
				itemScores.addSection(None,defaultXMLFileName,None)
			else:
				tkMessageBox.showinfo(
					"OK",
					"No section file was given. No action taken")
				return

		# Get the clicker ID information
		clickerIDs = self.getClickerIDResponses()

		# Prepare to start the process of going through the grade files.
		numberGradeRows = self.gradeListBox.size()
		if(self.saveGradeList.get()) :
			completeOutput = "ID,section,score\n"
		else :
			completeOutput = ""

		# Go through each grade data file and read it in.
		for row in range(numberGradeRows) :
			if(self.DEBUG):
				 print(" reading turning point file: {0}".format(self.gradeListBox.get(row)))

			# Open the file. If it cannot be opened move on to the next one.
			if(self.csvExtension.search(self.gradeListBox.get(row))):
				# This is a csv file. Read it as the output from turning point.
				#print("{0} is a csv file.".format(self.gradeListBox.get(row)))
				completeOutput += self.readTurningPointCSVFile( \
					self.gradeListBox.get(row),
					itemScores,clickerIDs)

			elif(self.tpzxExtension.search(self.gradeListBox.get(row))):
				# This is a session file from a turning point class.
				#print("{0} is a zipped set of xml files.".format(
				#				  self.gradeListBox.get(row)))
				completeOutput += itemScores.readTurningPointXMLFile( \
								self.gradeListBox.get(row),
								itemScores,self.leadingZero.get(),clickerIDs,
								self.moodleIDNumbers)

		if(self.DEBUG):
			print("Output:\n{0}\n{1}".format(completeOutput,len(completeOutput)))
		#print("item scores: {0}".format(itemScores))

		# There is some output from the grade parsing routines.
		if(len(completeOutput)>0) :
			if(self.DEBUG):
				print("Creating text output")
			newTextViewer = TextOutput(self)
			newTextViewer.setDocument(completeOutput)
			self.textWindows.append(newTextViewer)

		## Write the results to their respective xml files.
		itemScores.writeOutputFiles(self.moodleIDNumbers,None)