def __init__(self): title = "SAT Analysis - Results by State" self.doc = MyDocument(stylesheet="state-report-styles.css", title=title) self.doc.body.append(H1(title)) self.doc.body.append(self.data_table()) self.write()
def documentInit(self): blurb = """NSES Standards having no relevant state standards suggested in the top %d ranks (%d)""" % (self.rank, len (self)) title = "SAT Analysis" subtitle = "Poor Performing Standards for %s" % self.state self.doc = MyDocument (stylesheet="weak-std-report.css", title=title) self.doc.body.append (H1 (title)) self.doc.body.append (H2 (subtitle)) self.doc.body.append (DIV (blurb, klass="blurb")) self.doc.body.append (self.setsAsHtml())
class StateReport: outpath = "state-out.html" rank_list = ["", "1", "2", "3"] all_rank_list = ["1", "2", "3", "4", "5"] interpretation = """<b>Interpretation</b> — Contents of a cell denote the number of NSES standards for the given group (e.g., Applied) had a assigned relevance (or less) than the relevance number contained in the column header, at the rank specified for the particular table.""" def __init__(self): title = "SAT Analysis - Results by State" self.doc = MyDocument(stylesheet="state-report-styles.css", title=title) self.doc.body.append(H1(title)) self.doc.body.append(self.data_table()) self.write() def data_table(self): ranklist = self.all_rank_list collector = MASSGraftCollector() ## graft newer Mass results ## collector = Collector() table = TABLE() interp = TR( TD(DIV(self.interpretation, klass="interpretation"), colspan=len(ranklist))) table.append(interp) state_list.sort() for state in state_list: ## if state == "Massachusetts": continue table.append(TR(TD(H2(state), colspan=len(ranklist)))) row = TR() table.append(row) for rank in ranklist: row.append( TD(GroupTable(collector, state=state, rank=rank).ashtml())) return table def write(self): # fp = open (self.outpath, 'w') # fp.write (self.html.__str__()) # fp.close() self.doc.writeto(self.outpath)
def toHtml(self): """ Generate the html document as string """ title = "toc" doc = MyDocument(title=title, stylesheet="styles.css") # doc.body["onload"] = "init();" # <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> doc.head.append( META(http_equiv="Content-Type", content="text/html; charset=utf-8")) doc.addJavascript("javascript/prototype.js") doc.addJavascript("javascript/toc-scripts.js") doc.append(H4(self.title, align="center")) doc.append(self.getTocHtml()) return doc
def makeHtmlDocument(self): """ create HTML document """ # MyDocument (stylesheet=stylesheet, javascript=javascript) stylesheet = "styles.css" javascript = ["prototype.js", "lexicon.js"] doc = MyDocument(stylesheet=stylesheet, javascript=javascript) doc.body.append(H1("The Teachers' Domain Lexicon")) doc.body.append( DIV("This page is a hierarchical representation of the ", Href( 'http://www.teachersdomain.org:8086/public/view_all_lex_terms/', 'Teacher\'s Domain Lexicon term list', target='_blank'), klass='blurb')) doc.body.append(self.html) return doc
class WeaklingSetHtml (WeaklingSet): default_write_dest = "weak-std-report.html" def __init__ (self, **args): state = args.has_key("state") and args["state"] or None rank = args.has_key("rank") and args["rank"] and int(args["rank"]) or None # weaklings = standardsWithNoHits (Collector(), state=self.state, rank=self.rank) WeaklingSet.__init__ (self, state=state, rank=rank) self.documentInit() def setsAsHtml (self): box = DIV() for nsesDataSet in self.values(): box.append (self.nsesStdAsHtml (nsesDataSet)) box.append (self.stateStdsAsHtml (nsesDataSet [self.state])) return box def nsesStdAsHtml (self, nsesDataSet): table = TABLE (klass="nses-std-table") header = TR (valign="top", klass="header-row"); table.append (header) fields = ["id", "group", "gradeLevel", "benchmark", "text"] for field in fields: headerStr = (field == "id" and "NSES id") or field header.append (TH (headerStr, klass=field)) content = TR (valign="top", klass="content-row"); table.append (content) for field in fields: val = getattr (nsesDataSet.nses_standard, field) or getattr (nsesDataSet, field) content.append (TD (val, klass=field)) return table def stateStdsAsHtml (self, stateStandardList): table = TABLE (klass="state-std-table") header = TR (valign="top", klass="header-row"); table.append (header) fields = ["id", "relevance", "gradeLevel", "benchmark", "text"] for field in fields: headerStr = (field == "relevance" and "score") or \ (field == "id" and "state id") or field header.append (TH (headerStr, klass=field)) for stateStandard in stateStandardList: content = TR (valign="top", klass="content-row"); table.append (content) for field in fields: val = getattr (stateStandard, field) or "none" content.append (TD (val, klass=field)) return table def documentInit(self): blurb = """NSES Standards having no relevant state standards suggested in the top %d ranks (%d)""" % (self.rank, len (self)) title = "SAT Analysis" subtitle = "Poor Performing Standards for %s" % self.state self.doc = MyDocument (stylesheet="weak-std-report.css", title=title) self.doc.body.append (H1 (title)) self.doc.body.append (H2 (subtitle)) self.doc.body.append (DIV (blurb, klass="blurb")) self.doc.body.append (self.setsAsHtml()) def write (self, path=None): out = path or self.default_write_dest self.doc.writeto (out) print "html written to " + out
def makeHtmlDoc(self): """ Generate the html document as string """ ## title = os.path.splitext(self.filename)[0] title = self.title doc = MyDocument(title=title, stylesheet="styles.css") # doc.body["onload"] = "init();" # <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> doc.head.append( META(http_equiv="Content-Type", content="text/html; charset=utf-8")) doc.addJavascript("javascript/prototype.js") doc.addJavascript("javascript/asn-scripts.js") doc.append(DIV(id="stats-overlay")) doc.append(DIV(id="debug")) doc.append(H1(title)) doc.append(self.html) return doc