32
32
if len(sys.argv) != 7:
33
print >> sys.stderr, "usage: %s <oldsubjectcode> <oldyear> <oldsemester> "\
34
"<newsubjectcode> <newyear> <newsemester>" \
33
print >> sys.stderr, "usage: %s <oldsubjectcode> <oldyear> <oldsemestercode> "\
34
"<newsubjectcode> <newyear> <newsemestercode>" \
35
35
% os.path.basename(sys.argv[0])
40
40
src = store.find(Offering,
41
41
Subject.code == unicode(sys.argv[1]),
42
42
Semester.year == unicode(sys.argv[2]),
43
Semester.semester == unicode(sys.argv[3]),
43
Semester.code == unicode(sys.argv[3]),
44
44
Offering.subject_id == Subject.id,
45
45
Offering.semester_id == Semester.id).one()
47
47
dst = store.find(Offering,
48
48
Subject.code == unicode(sys.argv[4]),
49
49
Semester.year == unicode(sys.argv[5]),
50
Semester.semester == unicode(sys.argv[6]),
50
Semester.code == unicode(sys.argv[6]),
51
51
Offering.subject_id == Subject.id,
52
52
Offering.semester_id == Semester.id).one()
54
54
if dst.worksheets.count() > 0:
55
55
die('%r already has worksheets - doing nothing' % dst)
57
for oldws in src.worksheets:
59
newws.seq_no = oldws.seq_no
60
newws.identifier = oldws.identifier
61
newws.name = oldws.name
62
newws.assessable = oldws.assessable
63
newws.data = oldws.data
64
newws.format = oldws.format
67
ivle.worksheet.utils.update_exerciselist(newws)
57
dst.clone_worksheets(src)
69
59
print >> sys.stderr, 'copied %d worksheets from %r to %r' \
70
60
% (dst.worksheets.count(), src, dst)