cert (Certificates)¶
A tested document¶
This is a tested document. The following instructions are used for initialization:
>>> import lino
>>> lino.startup('lino_prima.projects.prima1.settings')
>>> from lino.api.doctest import *
Plain-text representation¶
The plain-text representation methods of the Certificate model are
defined as follows:
def __str__(self):
return f"{self.enrolment.pupil} {self.period.nickname}"
def get_str_words(self, ar):
if not ar.is_obvious_field("enrolment"):
yield str(self.enrolment)
if not ar.is_obvious_field("period"):
yield str(self.period)
The following snippets test whether they work as expected.
>>> current_year = periods.StoredYear.get_or_create_from_date(dd.today())
>>> qs = cert.Certificate.objects.filter(enrolment__group__designation="4A")
>>> qs = qs.exclude(enrolment__group__year=current_year)
>>> print(qs.first())
Faustin Blondeel 2023/24-1
>>> qs = cert.Certificate.objects.filter(enrolment__group__designation="5A")
>>> obj = qs.filter(enrolment__group__year=current_year).first()
>>> print(obj.enrolment)
Faustin Blondeel (5A)
>>> print(obj)
Faustin Blondeel 1
>>> print(repr(obj))
Certificate #243 ('Faustin Blondeel 1')
>>> res = AttrDict(get_json_dict("robin", f"cert/Certificates/{obj.pk}"))
>>> print(res['title'])
<a ...>Certificates</a> » Faustin Blondeel (5A) 1
When the certificate is an obvious field, Lino does not show it:
>>> mt = contenttypes.ContentType.objects.get_for_model(school.Enrolment).id
>>> res = get_json_dict("robin", f"cert/CertificatesByEnrolment/{obj.pk}", mk=obj.enrolment.id, mt=mt)
>>> print(res['title'])
<a ...>Certificates of Faustin Blondeel (5A)</a> » 1
The Certificate.enrolment field in the detail view
>>> print(res['data']['enrolment'])
Faustin Blondeel in 5A
Filtering ExamResponsesBySection¶
The following snippets verify #6484 (Filter nach Kompetenzen). The user has opened the detail view of the “Science” section of the first certificate for pupil Guillaume Borsu in group 6A. This view shows a table of exam responses for this pupil and for the skills covered by this certificate section.
>>> sr = cert.SectionResponse.objects.get(pk=674)
>>> sr.section
CertSection #5 ('Science')
>>> sr.certificate
Certificate #291 ('Guillaume Borsu 1')
>>> rt.show(cert.ExamResponsesBySection, sr)
========================== ====================== ===============================================
Exam response Remark Ratings
-------------------------- ---------------------- -----------------------------------------------
`Exam 96 (11.08.) <…>`__ It's never too late. `0 / 5 <…>`__, `0 / 10 <…>`__
`Exam 97 (14.08.) <…>`__ It's never too late. `0 / 20 <…>`__, `0 / 12 <…>`__, `0 / 6 <…>`__
`Exam 98 (17.08.) <…>`__ It's never too late. `0 / 8 <…>`__, `0 / 15 <…>`__, `0 / 20 <…>`__
`Exam 99 (20.08.) <…>`__ It's never too late. `0 / 30 <…>`__
========================== ====================== ===============================================
This table has three parameter fields:
>>> pprint(cert.ExamResponsesBySection.parameters)
{'enrolment': <django.db.models.fields.related.ForeignKey: enrolment>,
'exam': <django.db.models.fields.related.ForeignKey: exam>,
'exam__challenge__skill': <lino.core.vfields.RemoteField: exam__challenge__skill>}
>>> skill = school.Skill.objects.get(designation="History")
>>> pv = dict(exam__challenge__skill=skill)
>>> rt.show(cert.ExamResponsesBySection, sr, param_values=pv)
========================== ====================== ===============================================
Exam response Remark Ratings
-------------------------- ---------------------- -----------------------------------------------
`Exam 97 (14.08.) <…>`__ It's never too late. `0 / 20 <…>`__, `0 / 12 <…>`__, `0 / 6 <…>`__
`Exam 98 (17.08.) <…>`__ It's never too late. `0 / 8 <…>`__, `0 / 15 <…>`__, `0 / 20 <…>`__
========================== ====================== ===============================================
>>> skill = school.Skill.objects.get(designation="Geography")
>>> pv = dict(exam__challenge__skill=skill)
>>> rt.show(cert.ExamResponsesBySection, sr, param_values=pv)
========================== ====================== ===============================
Exam response Remark Ratings
-------------------------- ---------------------- -------------------------------
`Exam 96 (11.08.) <…>`__ It's never too late. `0 / 5 <…>`__, `0 / 10 <…>`__
========================== ====================== ===============================
>>> skill = school.Skill.objects.get(designation="Natural science")
>>> pv = dict(exam__challenge__skill=skill)
>>> rt.show(cert.ExamResponsesBySection, sr, param_values=pv)
========================== ====================== ================
Exam response Remark Ratings
-------------------------- ---------------------- ----------------
`Exam 99 (20.08.) <…>`__ It's never too late. `0 / 30 <…>`__
========================== ====================== ================
API reference¶
- class lino_prima.plugins.cert.Certificate¶
- enrolment¶
The pupil for whom this certificate has been issued.
Note that this labelled “Pupil” but actually points to an enrolment, not to a pupil.
- absences_m¶
The number of absences for medical reasons.
- absences_p¶
The number of excused absences with parental proof.
- absences_u¶
The number of unexcused absences.