def get_task_html(self): h = self.get_standard_clinician_block() + u""" <div class="summary"> <table class="summary"> """ + self.get_is_complete_tr() h += tr_qa("Total errors", self.n_errors()) h += tr_qa("Predicted full-scale IQ <sup>[1]</sup>", self.fsiq()) h += tr_qa("Predicted verbal IQ <sup>[2]</sup>", self.viq()) h += tr_qa("Predicted performance IQ <sup>[3]</sup>", self.piq()) h += u""" </table> </div> <div class="explanation"> Estimates premorbid IQ by pronunciation of irregular words. </div> <table class="taskdetail"> <tr> <th width="16%">Word</th><th width="16%">Correct?</th> <th width="16%">Word</th><th width="16%">Correct?</th> <th width="16%">Word</th><th width="16%">Correct?</th> </tr> """ nwords = len(WORDLIST) ncolumns = 3 nrows = int(math.ceil(float(nwords)/float(ncolumns))) column = 0 row = 0 # x: word index (shown in top-to-bottom then left-to-right sequence) for unused_loopvar in range(nwords): x = (column * nrows) + row if column == 0: # first column h += u"<tr>" h += td(ACCENTED_WORDLIST[x]) h += td(answer(getattr(self, WORDLIST[x]))) if column == (ncolumns - 1): # last column h += u"</tr>" row += 1 column = (column + 1) % ncolumns h += u""" </table> <div class="footnotes"> [1] Full-scale IQ ≈ 127.7 – 0.826 × errors. [2] Verbal IQ ≈ 129.0 – 0.919 × errors. [3] Performance IQ ≈ 123.5 – 0.645 × errors. </div> <div class="copyright"> NART: Copyright © Hazel E. Nelson. Used with permission. </div> """ return h
def get_html_correct_by_group_and_block(self, trialarray): if not trialarray: return div(italic("No trials")) html = """ <table class="extradetail"> <tr> <th>Block</th> """ for g in range(N_CUES): html += """ <th>Group {0} P(detected|present)</th> <th>Group {0} P(detected|absent)</th> <th>Group {0} c</th> <th>Group {0} d'</th> """.format(g) html += """ </th> </tr> """ for b in range(self.num_blocks): html += "<tr>" + td(b) for g in range(N_CUES): (p_detected_given_present, p_detected_given_absent, c, dprime, n_trials) = self.get_p_detected(trialarray, [b], [g]) html += td(a(p_detected_given_present)) html += td(a(p_detected_given_absent)) html += td(a(c)) html += td(a(dprime)) html += "</tr>\n" html += """ </table> """ return html
def get_task_html(self): DICTQ1 = {None: None} DICTQ3 = {None: None} DICTQ4 = {None: None} DICTQ5 = {None: None} DICTQ11 = {None: None} DICTQ12 = {None: None} for option in range(1, 5): DICTQ1[option] = WSTRING("gmcpq_q1_option" + str(option)) for option in range(1, 6): DICTQ3[option] = WSTRING("gmcpq_q3_option" + str(option)) DICTQ11[option] = WSTRING("gmcpq_q11_option" + str(option)) for option in range(0, 6): prefix = str(option) + u" – " if option > 0 else "" DICTQ4[option] = prefix + WSTRING("gmcpq_q4_option" + str(option)) DICTQ5[option] = prefix + WSTRING("gmcpq_q5_option" + str(option)) for option in range(1, 17): DICTQ12[option] = WSTRING("gmcpq_ethnicity_option" + str(option)) h = u""" <div class="summary"> <table class="summary"> {} </table> </div> <table class="taskdetail"> <tr> <th width="60%">Question</th> <th width="40%">Answer</th> </tr> """.format(self.get_is_complete_tr()) ell = "… " # horizontal ellipsis sep_row = subheading_spanning_two_columns("") blank_cell = td("", td_class="subheading") h += tr_qa(WSTRING("gmcpq_q_doctor"), ws.webify(self.doctor)) h += sep_row h += tr_qa(WSTRING("gmcpq_q1"), get_from_dict(DICTQ1, self.q1)) h += tr(td(WSTRING("gmcpq_q2")), blank_cell, literal=True) h += tr_qa(ell + WSTRING("gmcpq_q2_a"), get_yes_no_none(self.q2a)) h += tr_qa(ell + WSTRING("gmcpq_q2_b"), get_yes_no_none(self.q2b)) h += tr_qa(ell + WSTRING("gmcpq_q2_c"), get_yes_no_none(self.q2c)) h += tr_qa(ell + WSTRING("gmcpq_q2_d"), get_yes_no_none(self.q2d)) h += tr_qa(ell + WSTRING("gmcpq_q2_e"), get_yes_no_none(self.q2e)) h += tr_qa(ell + WSTRING("gmcpq_q2_f"), get_yes_no_none(self.q2f)) h += tr_qa(ell + ell + WSTRING("gmcpq_q2f_s"), ws.webify(self.q2f_details)) h += tr_qa(WSTRING("gmcpq_q3"), get_from_dict(DICTQ3, self.q3)) h += tr(td(WSTRING("gmcpq_q4")), blank_cell, literal=True) h += tr_qa(ell + WSTRING("gmcpq_q4_a"), get_from_dict(DICTQ4, self.q4a)) h += tr_qa(ell + WSTRING("gmcpq_q4_b"), get_from_dict(DICTQ4, self.q4b)) h += tr_qa(ell + WSTRING("gmcpq_q4_c"), get_from_dict(DICTQ4, self.q4c)) h += tr_qa(ell + WSTRING("gmcpq_q4_d"), get_from_dict(DICTQ4, self.q4d)) h += tr_qa(ell + WSTRING("gmcpq_q4_e"), get_from_dict(DICTQ4, self.q4e)) h += tr_qa(ell + WSTRING("gmcpq_q4_f"), get_from_dict(DICTQ4, self.q4f)) h += tr_qa(ell + WSTRING("gmcpq_q4_g"), get_from_dict(DICTQ4, self.q4g)) h += tr(td(WSTRING("gmcpq_q5")), blank_cell, literal=True) h += tr_qa(ell + WSTRING("gmcpq_q5_a"), get_from_dict(DICTQ5, self.q5a)) h += tr_qa(ell + WSTRING("gmcpq_q5_b"), get_from_dict(DICTQ5, self.q5b)) h += tr_qa(WSTRING("gmcpq_q6"), get_yes_no_none(self.q6)) h += tr_qa(WSTRING("gmcpq_q7"), get_yes_no_none(self.q7)) h += tr_qa(WSTRING("gmcpq_q8"), get_yes_no_none(self.q8)) h += tr_qa(WSTRING("gmcpq_q9_s"), ws.webify(self.q9)) h += sep_row h += tr_qa(WSTRING("sex"), ws.webify(self.q10)) h += tr_qa(WSTRING("gmcpq_q11"), get_from_dict(DICTQ11, self.q11)) h += tr_qa(WSTRING("gmcpq_q12"), get_from_dict(DICTQ12, self.q12)) h += tr_qa(ell + WSTRING("gmcpq_ethnicity_other_s"), ws.webify(self.q12_details)) h += u""" </table> """ return h
def get_task_html(self): vsp = self.score_vsp() naming = self.score_naming() attention = self.score_attention() language = self.score_language() abstraction = self.score_abstraction() memory = self.score_memory() orientation = self.score_orientation() totalscore = self.total_score() category = self.category() h = self.get_standard_clinician_block(True, self.comments) + u""" <div class="summary"> <table class="summary"> """ + self.get_is_complete_tr() h += tr(WSTRING("total_score"), answer(totalscore) + " / 30") h += tr_qa(WSTRING("moca_category") + " <sup>[1]</sup>", category) h += u""" </table> </div> <table class="taskdetail"> <tr> <th width="69%">Question</th> <th width="31%">Score</th> </tr> """ h += tr(WSTRING("moca_subscore_visuospatial"), answer(vsp) + " / 5", tr_class="subheading") h += tr("Path, cube, clock/contour, clock/numbers, clock/hands", ", ".join([answer(x) for x in [self.q1, self.q2, self.q3, self.q4, self.q5]])) h += tr(WSTRING("moca_subscore_naming"), answer(naming) + " / 3", tr_class="subheading") h += tr("Lion, rhino, camel", ", ".join([answer(x) for x in [self.q6, self.q7, self.q8]])) h += tr(WSTRING("moca_subscore_attention"), answer(attention) + " / 6", tr_class="subheading") h += tr("5 digits forwards, 3 digits backwards, tapping, serial 7s " "[<i>scores 3</i>]", ", ".join([answer(x) for x in [self.q9, self.q10, self.q11, self.q12]])) h += tr(WSTRING("moca_subscore_language"), answer(language) + " / 3", tr_class="subheading") h += tr(u"Repeat sentence 1, repeat sentence 2, fluency to letter ‘F’", ", ".join([answer(x) for x in [self.q13, self.q14, self.q15]])) h += tr(WSTRING("moca_subscore_abstraction"), answer(abstraction) + " / 2", tr_class="subheading") h += tr("Means of transportation, measuring instruments", ", ".join([answer(x) for x in [self.q16, self.q17]])) h += tr(WSTRING("moca_subscore_memory"), answer(memory) + " / 5", tr_class="subheading") h += tr( "Registered on first trial [<i>not scored</i>]", ", ".join([ answer(x, formatter_answer=italic) for x in [ self.register_trial1_1, self.register_trial1_2, self.register_trial1_3, self.register_trial1_4, self.register_trial1_5 ] ]) ) h += tr( "Registered on second trial [<i>not scored</i>]", ", ".join([ answer(x, formatter_answer=italic) for x in [ self.register_trial2_1, self.register_trial2_2, self.register_trial2_3, self.register_trial2_4, self.register_trial2_5 ] ]) ) h += tr( "Recall FACE, VELVET, CHURCH, DAISY, RED with no cue", ", ".join([ answer(x) for x in [ self.q18, self.q19, self.q20, self.q21, self.q22 ] ]) ) h += tr( "Recall with category cue [<i>not scored</i>]", ", ".join([ answer(x, formatter_answer=italic) for x in [ self.recall_category_cue_1, self.recall_category_cue_2, self.recall_category_cue_3, self.recall_category_cue_4, self.recall_category_cue_5 ] ]) ) h += tr( "Recall with multiple-choice cue [<i>not scored</i>]", ", ".join([ answer(x, formatter_answer=italic) for x in [ self.recall_mc_cue_1, self.recall_mc_cue_2, self.recall_mc_cue_3, self.recall_mc_cue_4, self.recall_mc_cue_5 ] ]) ) h += tr(WSTRING("moca_subscore_orientation"), answer(orientation) + " / 6", tr_class="subheading") h += tr( "Date, month, year, day, place, city", ", ".join([ answer(x) for x in [ self.q23, self.q24, self.q25, self.q26, self.q27, self.q28 ] ]) ) h += subheading_spanning_two_columns(WSTRING("moca_education_s")) h += tr_qa(u"≤12 years’ education?", self.education12y_or_less) h += u""" </table> <table class="taskdetail"> """ h += subheading_spanning_two_columns( "Images of tests: trail, cube, clock", th_not_td=True) h += tr( td(self.get_blob_png_html(self.trailpicture_blobid), td_class="photo", td_width="50%"), td(self.get_blob_png_html(self.cubepicture_blobid), td_class="photo", td_width="50%"), literal=True, ) h += tr( td(self.get_blob_png_html(self.trailpicture_blobid), td_class="photo", td_width="50%"), td("", td_class="subheading"), literal=True, ) h += u""" </table> <div class="footnotes"> [1] Normal is ≥26 (Nasreddine et al. 2005, PubMed ID 15817019). </div> <div class="copyright"> MoCA: Copyright © Ziad Nasreddine. May be reproduced without permission for CLINICAL and EDUCATIONAL use. You must obtain permission from the copyright holder for any other use. </div> """ return h
def text_row(self, wstringname): return tr(td(WSTRING(wstringname)), td("", td_class="subheading"), literal=True)
def get_task_html(self): score = self.total_score() category = self.category() h = self.get_standard_clinician_block(True, self.comments) + u""" <div class="summary"> <table class="summary"> """ + self.get_is_complete_tr() h += tr(WSTRING("total_score"), answer(score) + " / 30") h += tr_qa(WSTRING("category") + " <sup>[1]</sup>", category) h += u""" </table> </div> <table class="taskdetail"> <tr> <th width="80%">Question</th> <th width="20%">Score</th> </tr> """ h += tr_qa(WSTRING("slums_alert_s"), get_yes_no_none(self.alert)) h += tr_qa(WSTRING("slums_highschool_s"), get_yes_no_none(self.highschooleducation)) h += tr_qa(WSTRING("slums_q1_s"), self.q1) h += tr_qa(WSTRING("slums_q2_s"), self.q2) h += tr_qa(WSTRING("slums_q3_s"), self.q3) h += tr(u"Q5 <sup>[2]</sup> (money spent, money left " u"[<i>scores 2</i>]", u", ".join([answer(x) for x in [self.q5a, self.q5b]])) h += tr_qa(u"Q6 (animal fluency) [<i>≥15 scores 3, 10–14 scores 2, " u"5–9 scores 1, 0–4 scores 0</i>]", self.q6) h += tr(u"Q7 (recall: apple, pen, tie, house, car)", u", ".join([answer(x) for x in [self.q7a, self.q7b, self.q7c, self.q7d, self.q7e]])) h += tr(u"Q8 (backwards: 648, 8537)", u", ".join([answer(x) for x in [self.q8b, self.q8c]])) h += tr(u"Q9 (clock: hour markers, time [<i>score 2 each</i>]", u", ".join([answer(x) for x in [self.q9a, self.q9b]])) h += tr(u"Q10 (X in triangle; which is biggest?)", u", ".join([answer(x) for x in [self.q10a, self.q10b]])) h += tr(u"Q11 (story: Female’s name? Job? When back to work? " u"State she lived in? [<i>score 2 each</i>])", u", ".join([answer(x) for x in [self.q11a, self.q11b, self.q11c, self.q11d]])) h += u""" </table> <table class="taskdetail"> """ h += subheading_spanning_two_columns("Images of tests: clock, shapes") h += tr( td(self.get_blob_png_html(self.clockpicture_blobid), td_width="50%", td_class="photo"), td(self.get_blob_png_html(self.shapespicture_blobid), td_width="50%", td_class="photo"), literal=True ) h += u""" </table> <div class="footnotes"> [1] With high school education: ≥27 normal, ≥21 MCI, ≤20 dementia. Without high school education: ≥25 normal, ≥20 MCI, ≤19 dementia. (Tariq et al. 2006, PubMed ID 17068312.) [2] Q4 (learning the five words) isn’t scored. </div> """ return h