811
811
return mand_done, mand_total, opt_done, opt_total
813
def add_enrolment(self, login, subj_code, semester, year=None, dry=False):
815
Enrol a student in the given offering of a subject.
816
Returns True on success, False on failure (which usually means either
817
the student is already enrolled in the subject, the student was not
818
found, or no offering existed with the given details).
819
The return value can usually be ignored.
821
subj_code = str(subj_code)
822
semester = str(semester)
824
year = str(time.gmtime().tm_year)
828
INSERT INTO enrolment (loginid, offeringid)
830
(SELECT loginid FROM login WHERE login=%s),
832
FROM (offering INNER JOIN subject
833
ON subject.subjectid = offering.subject)
834
WHERE subj_code=%s AND semester=%s AND year=%s)
835
);""" % (_escape(login), _escape(subj_code), _escape(semester),
840
result = self.db.query(query)
841
except pg.ProgrammingError:
814
846
"""Close the DB connection. Do not call any other functions after
815
847
this. (The behaviour of doing so is undefined).