Certificates and Certificate Courses ************************************ .. module:: waeup.kofa.university.certificate Components that represent and manage certificates. .. :doctest: .. :layer: waeup.kofa.testing.KofaUnitTestLayer Content Classes (models and containers) ======================================= :class:`Certificate` -------------------- .. class:: Certificate([code=u'NA',[ title=u'Unnamed Certificate',[ study_mode=None,[ start_level=None,[ end_level=None,[ application_category=None,[ m_prefix=u'']]]]]]]) Create a certificate object with the given parameters. .. attribute:: grok.implements(ICertificate) All parameters are optional: >>> from waeup.kofa.university.certificate import Certificate >>> mycertificate = Certificate() Certificates have the attributes required by the `ICertificate` interface: >>> from waeup.kofa.university.interfaces import ICertificate >>> ICertificate.providedBy(mycertificate) True >>> from zope.interface.verify import verifyObject >>> verifyObject(ICertificate, mycertificate) True Beside the attributes, certificates are containers for certificate-courses (see :class:`CertificateCourse`). Each certificate course can be accessed by the code of the course it wraps. .. attribute:: title Each certificate has a title: >>> mycertificate.title u'Unnamed Certificate' .. attribute:: code Each certificate holds a code, which might be a shortcut or abbreviation of the real certificate name. By default the code is ``NA`` (=not assigned): >>> mycertificate.code u'NA' .. attribute:: study_mode Each :class:`Certificate` instance has a study mode: >>> print mycertificate.study_mode None .. XXX: This is not a proper description .. attribute:: start_level Each :class:`Certificate` instance has a start level: >>> print mycertificate.start_level None .. XXX: This is not a proper description .. attribute:: end_level Each :class:`Certificate` instance has a end level: >>> print mycertificate.end_level None .. XXX: This is not a proper description .. attribute:: application_category Each :class:`Certificate` instance has an application category: >>> print mycertificate.application_category None .. XXX: This is not a proper description .. method:: addCertCourse(course[, level=100,[ mandatory=True]]) Add a certificate course. A course is an object implementing :class:`waeup.kofa.interfaces.ICourse`. Please don't be confused by the term 'certificate course'. As course objects will normaly be stored in a department, the certificate course refers to the 'real' course in the department container. .. method:: delCertCourses(code) Remove a certificate course from a certificate. The certificate course must be given by its code number. :class:`CertificateCourse` -------------------------- .. class:: CertificateCourse(course[, level=100[, mandatory=True]]) Create a certificate course. A certificate course are held in certificates and refer to an existing :class:`Course` instance held elsewhere. A certificate can require several certificate courses and one certificate course can be required by several certificates. .. attribute:: course An instance of :class:`ICourse`. .. attribute:: level An integer telling the level to which this course applies. .. attribute:: mandatory A bool stating whether this course is required or optional to get the certificate. Utilities ========= :class:`CertificateFactory` --------------------------- .. class:: CertificateFactory() .. attribute:: grok.name(u'waeup.Certificate') .. attribute:: grok.implements(IFactory) A named utility to deliver new instances of :class:`Certificate` without the need to import the implementation before: >>> from zope.component import createObject >>> mycertificate = createObject(u'waeup.Certificate') >>> mycertificate The factory complies with the specifications from the :class:`IFactory` insterface: >>> from zope.interface.verify import verifyClass >>> from zope.component.interfaces import IFactory >>> from waeup.kofa.university.certificate import CertificateFactory >>> verifyClass(IFactory, CertificateFactory) True This means also, that we can get the interfaces of the created object from the factory: >>> certificate_factory = CertificateFactory() >>> certificate_factory.getInterfaces() :class:`CertificateCourseFactory` --------------------------------- .. class:: CertificateCourseFactory() .. attribute:: grok.name(u'waeup.CertificateCourse') .. attribute:: grok.implements(IFactory) A named utility to deliver new instances of :class:`CertificateCourse` without the need to import the implementation before: >>> from zope.component import createObject >>> mycertificatecourse = createObject(u'waeup.CertificateCourse') >>> mycertificatecourse The factory complies with the specifications from the :class:`IFactory` insterface: >>> from zope.interface.verify import verifyClass >>> from zope.component.interfaces import IFactory >>> from waeup.kofa.university.certificate import CertificateCourseFactory >>> verifyClass(IFactory, CertificateCourseFactory) True This means also, that we can get the interfaces of the created object from the factory: >>> certcourse_factory = CertificateCourseFactory() >>> certcourse_factory.getInterfaces() Examples ======== Certificates ------------ We can create certificates: >>> from waeup.kofa.university.certificate import Certificate >>> mycertificate = Certificate() >>> mycertificate Another way to create certificates is by asking for a factory called ``waeup.Certificate``. This way we can create a factory without importing a class: >>> from zope.component import createObject >>> mycertificate = createObject(u'waeup.Certificate') >>> mycertificate Certificate Courses ------------------- :class:`CertificateCourse` instances comply with the :class:`ICertificateCourse` interface: >>> from waeup.kofa.university.interfaces import ICertificateCourse >>> from waeup.kofa.university.certificate import CertificateCourse >>> mycertcourse = CertificateCourse(None, 200, False) >>> ICertificateCourse.providedBy(mycertcourse) True >>> from zope.interface.verify import verifyObject >>> verifyObject(ICertificateCourse, mycertcourse) True Also instances of :class:`CertificateCourse` can be created by asking the component architechture: >>> from zope.component import createObject >>> mycertcourse = createObject(u'waeup.CertificateCourse') >>> mycertcourse