~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to bin/ivle-enrol

  • Committer: Matt Giuca
  • Date: 2009-04-24 14:29:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1196.
  • Revision ID: matt.giuca@gmail.com-20090424142912-bgkaglhv1ct4vi87
ivle.worksheet.utils: Can now calculate exercise and worksheet marks as of a
    particular date (optional argument).
ivle-marks: Added --cutoff argument which allows the user to display the marks
    as of a given date. (This allows you to get the marks at a particular
    cut-off date, since students may continue working past this date; the
    marks should not count).

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import os
26
26
import sys
27
27
 
28
 
from ivle.config import Config
29
28
from ivle.database import get_store, Subject, Semester, Offering, User
30
29
 
31
30
def die(error):
33
32
    sys.exit(1)
34
33
 
35
34
if len(sys.argv) not in (5, 6):
36
 
    print >> sys.stderr, '''usage: %s <login> <subjectcode> <year> <semestercode> [role]
 
35
    print >> sys.stderr, '''usage: %s <login> <subjectcode> <year> <semester> [role]
37
36
 
38
37
'role' should be one of student (the default), tutor or lecturer.
39
38
If an enrolment already exists, it will be reactivated and its role set.''' \
40
39
                         % os.path.basename(sys.argv[0])
41
40
    sys.exit()
42
41
 
43
 
store = get_store(Config())
 
42
store = get_store()
44
43
 
45
44
user = User.get_by_login(store, sys.argv[1])
46
45
if user is None:
49
48
offering = store.find(Offering,
50
49
                    Subject.code == unicode(sys.argv[2]),
51
50
                    Semester.year == unicode(sys.argv[3]),
52
 
                    Semester.code == unicode(sys.argv[4]),
 
51
                    Semester.semester == unicode(sys.argv[4]),
53
52
                    Offering.subject_id == Subject.id,
54
53
                    Offering.semester_id == Semester.id).one()
55
54
if not offering: