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

1""" 

2@file 

3@brief Defines :epkg:`HTML` displays. 

4""" 

5from ...activities import Display 

6 

7 

8class DisplayQuestionChoiceHTML(Display): 

9 """ 

10 Renders a question into :epkg:`HTML`. 

11 """ 

12 

13 def __init__(self): 

14 """ 

15 constructor 

16 """ 

17 Display.__init__(self, "qcm_html1", self.__class__.__name__) 

18 

19 def get_context(self, group, item): 

20 """ 

21 Renders a question specified as QCM. 

22 

23 @param group group of activities, see @see cl ActivityGroup 

24 @param item item in the group 

25 @return dictionary 

26 """ 

27 act = group[item] 

28 context = dict(question=act['title'], description=act['description'], 

29 answers=act['content']["answers"], 

30 number=group.get_display_item(item), 

31 nbnumber=len(group), qn=item, 

32 previous_button=group.get_previous(item), 

33 next_button=group.get_next(item), 

34 image=act['content'].get("show", None)) 

35 context['has_previous_button'] = context['previous_button'] is not None 

36 context['has_next_button'] = context['next_button'] is not None 

37 return context