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