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
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
def pages(self): from knst.knstdoc import parseString if not self.xml: raise RuntimeError, "Normalize first" return len(parseString(self.xml).pages)