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 ↛ 69line 52 didn't jump to line 69, 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([f"""{seq}{DOT}{NBSP}""", critRecord.title()], cls="col1"), 

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

64 status, 

65 ], 

66 cls="centrytitle criteria", 

67 ) 

68 else: 

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

70 evidence = f"""{hasEvidence} evidence""" 

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

72 critRep = critRecord.title(markup=markup) 

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

74 

75 def bodyCompact(self, **kwargs): 

76 critId = self.critId 

77 critRecord = self.critRecord 

78 perm = self.perm 

79 

80 critData = critRecord.record 

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

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

83 

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

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

86 (N.info, N.dismiss), 

87 critRecord.wrapHelp(), 

88 critKey, 

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

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

91 ) 

92 

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

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

95 entry = H.div( 

96 [ 

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

98 infoShow, 

99 infoHide, 

100 infoBody, 

101 score, 

102 evidence, 

103 ], 

104 ) 

105 

106 return entry