Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from config import Config as C, Names as N 

2from control.html import HtmlElements as H 

3from control.utils import pick as G, E, DOT, Q, NBSP 

4from control.record import Record 

5 

6 

7CW = C.web 

8 

9MESSAGES = CW.messages 

10 

11 

12class CriteriaEntryR(Record): 

13 """Logic for criteriaEntry records. 

14 

15 Criteria entry records have a customised title, with the sequence number 

16 of the criteria in it, plus the score the assessor has entered and an icon 

17 to show whether there is evidence or not. 

18 

19 There is also a `compact` method to present these records, with a collapsible 

20 legend, fitting on one line, so that a series of criteriaEntry records shows 

21 up as a tidy list on the page. 

22 

23 !!! hint 

24 If the `criteriaEntry` record is not part of the workflow, the behaviour 

25 of this class falls back to the base class `control.record.Record`. 

26 """ 

27 

28 def __init__(self, *args, **kwargs): 

29 super().__init__(*args, **kwargs) 

30 

31 context = self.context 

32 record = self.record 

33 mkTable = self.mkTable 

34 

35 if mkTable: 35 ↛ exitline 35 didn't return from function '__init__', because the condition on line 35 was never false

36 critObj = mkTable(context, N.criteria) 

37 critId = G(record, N.criteria) 

38 critRecord = critObj.record(eid=critId) 

39 self.critId = critId 

40 """*ObjectId* The id of the `criteria` record to which this entry refers. 

41 """ 

42 

43 self.critRecord = critRecord 

44 """*dict* The `criteria` record to which this entry refers. 

45 """ 

46 

47 def title(self, *args, **kwargs): 

48 record = self.record 

49 critRecord = self.critRecord 

50 

51 markup = kwargs.get("markup", True) 

52 if markup: 52 ↛ 72line 52 didn't jump to line 72, because the condition on line 52 was never false

53 withEvidence = H.icon( 

54 N.missing if self.field(N.evidence).isBlank() else N.check 

55 ) 

56 status = H.span(f"""evidence{NBSP}{withEvidence}""", cls="right small") 

57 seq = G(record, N.seq, default=(E if markup is None else Q)) 

58 scoreRep = self.field(N.score).wrapBare() 

59 

60 return H.span( 

61 [ 

62 H.span( 

63 [f"""{seq}{DOT}{NBSP}""", critRecord.title(**kwargs)], 

64 cls="col1", 

65 ), 

66 H.span(scoreRep, cls="col2"), 

67 status, 

68 ], 

69 cls="centrytitle criteria", 

70 ) 

71 else: 

72 hasEvidence = "without" if self.field(N.evidence).isBlank() else "with" 

73 evidence = f"""{hasEvidence} evidence""" 

74 scoreRep = self.field(N.score).wrapBare(markup=markup) 

75 critRep = critRecord.title(markup=markup, **kwargs) 

76 return f"""{seq}{DOT} {critRep} {scoreRep}, {evidence}""" 

77 

78 def bodyCompact(self, **kwargs): 

79 critId = self.critId 

80 critRecord = self.critRecord 

81 perm = self.perm 

82 

83 critData = critRecord.record 

84 actual = G(critData, N.actual, default=False) 

85 msg = E if actual else G(MESSAGES, N.legacyCriterion) 

86 

87 critKey = f"""{N.criteria}/{critId}/help""" 

88 (infoShow, infoHide, infoBody) = H.detailx( 

89 (N.info, N.dismiss), 

90 critRecord.wrapHelp(), 

91 critKey, 

92 openAtts=dict(cls="button small", title="Explanation and scoring guide"), 

93 closeAtts=dict(cls="button small", title="Hide criteria explanation"), 

94 ) 

95 

96 score = H.div(self.field(N.score).wrap(asEdit=G(perm, N.isEdit))) 

97 evidence = H.div(self.field(N.evidence).wrap(asEdit=G(perm, N.isEdit))) 

98 entry = H.div( 

99 [ 

100 H.div(H.he(msg), cls="heavy") if msg else E, 

101 infoShow, 

102 infoHide, 

103 infoBody, 

104 score, 

105 evidence, 

106 ], 

107 ) 

108 

109 return entry