示例#1
0
	def grade(self,settings,studentId,version,tallies,force=False):
		from knst.knstdoc import parseString
		import logging
		xml_data = unicode(self.mark(settings,version,tallies),'utf8')
		mark = 0.0
		marked = {}
		for n,page in enumerate(parseString(xml_data).pages):
			for q in page.questions:
				ans = q.marked()
				if ans:
					mark += ans.value
					marked[n] = ans.id
		
		if not self.add_result(studentId,mark, (version,tallies),force):
			raise ValueError, "Already submmitted or unknow student."
		logging.info("%s: Submitting for '%s' grade %5.3f. Data: %d:%s answers: %s",
						resource_path(self), studentId, mark,
						version,`tallies`, `marked`)
		return mark	 
示例#2
0
    def grade(self, settings, studentId, version, tallies, force=False):
        from knst.knstdoc import parseString
        import logging
        xml_data = unicode(self.mark(settings, version, tallies), 'utf8')
        mark = 0.0
        marked = {}
        for n, page in enumerate(parseString(xml_data).pages):
            for q in page.questions:
                ans = q.marked()
                if ans:
                    mark += ans.value
                    marked[n] = ans.id

        if not self.add_result(studentId, mark, (version, tallies), force):
            raise ValueError, "Already submmitted or unknow student."
        logging.info(
            "%s: Submitting for '%s' grade %5.3f. Data: %d:%s answers: %s",
            resource_path(self), studentId, mark, version, ` tallies `,
            ` marked `)
        return mark
示例#3
0
	def pages(self):
		from knst.knstdoc import parseString
		if not self.xml:
			raise RuntimeError, "Normalize first"
		return len(parseString(self.xml).pages)
示例#4
0
 def pages(self):
     from knst.knstdoc import parseString
     if not self.xml:
         raise RuntimeError, "Normalize first"
     return len(parseString(self.xml).pages)