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 ...>5A</a> » Faustin Blondeel (5A) 1
When the enrolment 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 ...>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 343 (10.09.) <…>`__ Well done! `4 / 6 <…>`__, `4,5 / 8 <…>`__
`Exam 345 (13.09.) <…>`__ It's never too late. `28 / 30 <…>`__, `5 / 5 <…>`__
`Exam 347 (14.09.) <…>`__ Well done! `5,5 / 6 <…>`__, `7 / 8 <…>`__, `12 / 15 <…>`__
`Exam 349 (15.09.) <…>`__ It's never too late. `6,5 / 10 <…>`__, `16 / 20 <…>`__, `7,5 / 12 <…>`__
`Exam 351 (10.09.) <…>`__ Well done! `17,5 / 20 <…>`__
=========================== ====================== =====================================================
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 347 (14.09.) <…>`__ Well done! `5,5 / 6 <…>`__, `7 / 8 <…>`__, `12 / 15 <…>`__
`Exam 349 (15.09.) <…>`__ It's never too late. `6,5 / 10 <…>`__, `16 / 20 <…>`__, `7,5 / 12 <…>`__
=========================== ====================== =====================================================
>>> 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 343 (10.09.) <…>`__ Well done! `4 / 6 <…>`__, `4,5 / 8 <…>`__
`Exam 345 (13.09.) <…>`__ It's never too late. `28 / 30 <…>`__, `5 / 5 <…>`__
=========================== ====================== ================================
>>> 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 351 (10.09.) <…>`__ Well done! `17,5 / 20 <…>`__
=========================== ============ ===================
The Ratings detail¶
>>> ar = rt.login('robin')
>>> obj = cert.Certificate.objects.get(id=291)
>>> print(obj)
Guillaume Borsu 1
>>> print(obj.enrolment)
Guillaume Borsu (6A)
>>> er = cert.ElementResponse.objects.get(
... section_response__certificate=obj,
... cert_element__skill__designation="Geography")
>>> fld = er._meta.get_field('ratings_detail')
>>> res = fld.value_from_object(er, ar)
>>> print(html2text(res))
| Source | 2024/25-1 | 2024/25-2 | Challenges | [4.0/6.0](…) \+ [4.5/8.0](…) \+ |
| [28.0/30.0](…) \+ [5.0/5.0](…) = 41,5 / 49 (84,7 %) | [8.5/15.0](…) \+ |
| [15.5/20.0](…) = 24 / 35 (68,6 %) |
|-----------------------------------------------------|------------------|------------|
| Projects | no ratings | no ratings |
| Final exams | no ratings | no ratings |
| Certificate | no ratings | no ratings |
The printed certificate¶
This section uses a utility function to show & test the content of a printed certificate:
>>> def doit(cert_id):
... obj = cert.Certificate.objects.get(id=cert_id)
... res = "".join(obj.as_page(ar))
... print(html2text(res))
The following snippets print out the certificates of Guillaume Borsu in group 6A.
>>> ar = rt.login('robin')
>>> cert.Certificate.objects.filter(enrolment__pupil__first_name="Guillaume")
...
<QuerySet [Certificate #289 ('Guillaume Borsu 2023/24-1'), Certificate #290
('Guillaume Borsu 2023/24-2'), Certificate #291 ('Guillaume Borsu 1'),
Certificate #292 ('Guillaume Borsu 2')]>
We look only at those of the current school year, i.e. 291 and 292.
The certificate of the first semester does not include scores of second semester, even though they exist.
The certificate of the second semester includes final exam information.
First period¶
>>> doit(291)
# Certificate
Name: BORSU Guillaume
Group: 6A — Schuljahr 2024/25 - 1. Periode
Class teacher: Aimée AELTER; Protestant religion: Abel ADAM; Music: Adèle
ADAMI
### 🖩 Mathematics
| Kompetenz | Punkte | Prozentsatz |
|-------------|--------|-------------|
| Arithmetics | — / — | |
| Stochastics | — / — | |
| Gesamt | — / — | — |
### Science
| Kompetenz | Punkte | Prozentsatz |
|------------------------------------------------------------------------|------------|-------------|
| Geography | 5,1 / 6 | 85,0 % |
| History | 6,1 / 8 | 76,2 % |
| Natural science | 13,1 / 15 | 87,3 % |
| Gesamt | 24,3 / 29 | 83,8 % |
| **Geography/Geography:** Well done! It's never too late. |
| **History/History/History:** Well done! It's never too late. **Natural |
| science:** Well done! |
### 🕊 Religion
This Course is _really_ great.
| Kompetenz | Punkte | Prozentsatz |
|------------------------------------------------------------------------------|-----------|-------------|
| Knowledge | 16,8 / 20 | 84,0 % |
| Behaviour | 23,5 / 30 | 78,3 % |
| Attitude | 3,7 / 5 | 74,0 % |
| Gesamt | 44 / 55 | 80,0 % |
| **Knowledge/Behaviour/Attitude:** It's never too late. Well done! It's never |
| too late. Well done! |
### 🎜 Music
This Course is _really_ cool.
| Note | Kommentar | | |
|------|-----------|
### Soft skills
| Skill |  |  |  |  |
|------------------------------------------------------|--...--|--...--|--...--|--...--|
| You obey rules | | | | |
| You respect your classmates | | | | |
| You respect your teachers | | | | |
| You are helpful | | | | |
| You are able to cope in situations of conflict | | | | |
| You say your opinion respectfully and can explain it | | | | |
| You do your homework carefully | | | | |
| You focus on your work | | | | |
| You can work independently | | | | |
| You have a readable handwriting | | | | |
### Übersicht
| Fach | 1 | 2 | Durchschnitt | Mathematics | — | — | — |
|-----------------|-----------|-------|--------------|
| Arithmetics | — / — | — / — | — / — |
| Stochastics | — / — | — / — | — / — |
| Science | 83,8 % | — | 83,8 % |
| Geography | 5,1 / 6 | — / — | 5,1 / 6 |
| History | 6,1 / 8 | — / — | 6,1 / 8 |
| Natural science | 13,1 / 15 | — / — | 13,1 / 15 |
| Religion | 80,0 % | — | 80,0 % |
| Knowledge | 16,8 / 20 | — / — | 16,8 / 20 |
| Behaviour | 23,5 / 30 | — / — | 23,5 / 30 |
| Attitude | 3,7 / 5 | — / — | 3,7 / 5 |
| Music | | | — |
##### Abwesenheiten
(in halben Schultagen)
| mit einer **schriftlichen Entschuldigung** | **ohne** schriftliche Entschuldigung | mit einem **ärztlichen Attest** | 0 | 0 | 0 |
|--------------------------------------------|---------------------------------------|----------------------------------|
Last period (with final exams)¶
>>> doit(292)
# Certificate
Name: BORSU Guillaume
Group: 6A — Schuljahr 2024/25 - 2. Periode
Class teacher: Aimée AELTER; Protestant religion: Abel ADAM; Music: Adèle
ADAMI
### 🖩 Mathematics
| Kompetenz | 2\. Periode | Prüfungen | Punkte gesamt | Prozentsatz gesamt |
|--------------------------------------------------------------------------------|-------------|------------|---------------|--------------------|
| Arithmetics | — | 62,5 % | 12,5 / 20 | 62,5 % |
| Stochastics | — | 60,0 % | 7,2 / 12 | 60,0 % |
| Gesamt | | 19,7 / 32 | 61,6 % |
| **Arithmetics:** It's never too late. **Stochastics:** Beware of the mistakes! |
### Science
| Kompetenz | 2\. Periode | Prüfungen | Punkte gesamt | Prozentsatz gesamt |
|-------------------------------------------------------------------------------|-------------|-----------|---------------|--------------------|
| Geography | 68,3 % | — | 4,1 / 6 | 68,3 % |
| History | 73,8 % | — | 5,9 / 8 | 73,8 % |
| Natural science | 53,3 % | — | 8 / 15 | 53,3 % |
| Gesamt | | 18 / 29 | 62,1 % |
| **Geography/Geography:** Beware of the mistakes! **History/History/History:** |
| You should be more attentive. Beware of the mistakes! You should be more |
| attentive. **Natural science:** Beware of the mistakes! |
### 🕊 Religion
This Course is _really_ great.
| Kompetenz | 2\. Periode | Prüfungen | Punkte gesamt | Prozentsatz gesamt |
|------------------------------------------------------------------------|-------------|------------|---------------|--------------------|
| Knowledge | 79,5 % | 57,5 % | 13,7 / 20 | 68,5 % |
| Behaviour | 57,0 % | 55,0 % | 16,8 / 30 | 56,0 % |
| Attitude | 78,0 % | 52,0 % | 3,3 / 5 | 66,0 % |
| Gesamt | | 33,8 / 55 | 61,5 % |
| **Knowledge:** Well done! **Behaviour:** You should be more attentive. |
| **Attitude:** It's never too late. |
### 🎜 Music
This Course is _really_ cool.
| Note | Kommentar | | |
|------|-----------|
### Soft skills
| Skill |  |  |  |  |
|------------------------------------------------------|--...--|--...--|--...--|--...--|
| You obey rules | | | | |
| You respect your classmates | | | | |
| You respect your teachers | | | | |
| You are helpful | | | | |
| You are able to cope in situations of conflict | | | | |
| You say your opinion respectfully and can explain it | | | | |
| You do your homework carefully | | | | |
| You focus on your work | | | | |
| You can work independently | | | | |
| You have a readable handwriting | | | | |
### Übersicht
| Fach | 1 | 2 | Durchschnitt | Mathematics | — | 61,6 % | 61,6 % |
|-----------------|-----------|-----------|--------------|
| Arithmetics | — / — | 12,5 / 20 | 12,5 / 20 |
| Stochastics | — / — | 7,2 / 12 | 7,2 / 12 |
| Science | 83,8 % | 62,1 % | 72,9 % |
| Geography | 5,1 / 6 | 4,1 / 6 | 4,6 / 6 |
| History | 6,1 / 8 | 5,9 / 8 | 6 / 8 |
| Natural science | 13,1 / 15 | 8 / 15 | 10,6 / 15 |
| Religion | 80,0 % | 61,5 % | 70,7 % |
| Knowledge | 16,8 / 20 | 13,7 / 20 | 15,3 / 20 |
| Behaviour | 23,5 / 30 | 16,8 / 30 | 20,2 / 30 |
| Attitude | 3,7 / 5 | 3,3 / 5 | 3,5 / 5 |
| Music | | | — |
##### Abwesenheiten
(in halben Schultagen)
| mit einer **schriftlichen Entschuldigung** | **ohne** schriftliche Entschuldigung | mit einem **ärztlichen Attest** | 0 | 0 | 0 |
|--------------------------------------------|---------------------------------------|----------------------------------|
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.