%try:
% eval(f'from {__name__} import *')
%except:
% pass
%end
%def chok(ok):
% if ok: #✔
✔\\
% else: #✘
✘\\
% end
%end
%def chq(
% idx=None #either not there or a (list of) number or the same as ``htmlbr``
% ,htmlbr='
' # html delimiter if no idx =/ more idx
% # #the following can also be defined in either __init__.py or in the language html
% ,**ka
% # ,chesults # the result (calculated by chalc())
% # ,chanser # the answer given by the user
% # ,chames # input names (per idx a html/tex string, e.g. r"\(\alpha\)")
% # ,champles # input examples ( " )
% # ,chadios # texts for radio buttons (a tuple per idx)
% # ,checkos # texts for check boxes (a tuble per idx)
% # ,chow # a function to show the result (e.g. chutil.tx)
% ):
% def _get(n):
% if n in ka:
% return ka.get(n,'')
% else:
% return env.get(n,'')
% end
% end
% # if not defined('chesults'):
% # chesults = _get('chesults')
% # end
% if idx is None:
% idxs = range(len(chesults))
% else:
% try:
% idxs = [int(i) for i in idx]
% except:
% try:
% idxs = [int(idx)]
% except:
% idxs = range(len(chesults))
% htmlbr = idx
% end
% end
% end
% more_idx = len(idxs) > 1
% def _getidx(n,i):
% nv = _get(n)
% try:
% if isinstance(nv,list) or isinstance(nv,dict):
% return nv[i]
% elif not more_idx: # use tuple for chadios and checkos
% return nv
% end
% except:
% return ''
% end
% end
% for idx in idxs:
% if more_idx:
{{! htmlbr}}
% end
% chame = _getidx('chames',idx)
{{! chame}}
% chample = _getidx('champles',idx)
% choice = _getidx('chadios',idx)
% checks = _getidx('checkos',idx)
% chowfun = _getidx('chow',idx)
% if choice:
% for i,val in enumerate(choice):
% answ = str(i+1)
% # mention answ in val to link to saved value of answer (1. 2. )
% # have a
at the end of ``val`` for vertical alignment
% end
% elif checks:
% for i,val in enumerate(checks):
% answ = chr(65+i)
% end
% else:
% if not chanswered:
{{! chample}}
% if choints[idx] > 0:
[{{choints[idx]}}P]\\
% end
% else:
% if chowfun:
{{!chowfun(chesults[idx])}}\\
% else:
{{!chesults[idx]}}\\
% end
% end
% end
% if chanswered:
% if chanswers[idx].strip() != '':
({{chanswers[idx]}} \\
% chok(bool(choks[idx]))
)
% end
% if choks[idx]:
[{{choints[idx]}}P]
% else:
[0P]
% end
% end
% end
%end
%def chinc(lnk, chumber):