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

« back to all changes in this revision

Viewing changes to bin/ivle-cloneworksheets

  • Committer: Matt Giuca
  • Date: 2009-04-24 13:19:39 UTC
  • mto: This revision was merged to the branch mainline in revision 1196.
  • Revision ID: matt.giuca@gmail.com-20090424131939-1dgftrcyy8f4l7v4
ivle-marks: Removed temporary printing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
import sys
23
23
 
24
 
import ivle.config
25
24
from ivle.database import get_store, Subject, Semester, Offering, Worksheet
26
25
import ivle.worksheet.utils
27
26
 
35
34
                         % os.path.basename(sys.argv[0])
36
35
    sys.exit()
37
36
 
38
 
store = get_store(ivle.config.Config())
 
37
store = get_store()
39
38
 
40
39
src = store.find(Offering,
41
40
                 Subject.code == unicode(sys.argv[1]),
54
53
if dst.worksheets.count() > 0:
55
54
    die('%r already has worksheets - doing nothing' % dst)
56
55
 
57
 
dst.clone_worksheets(src)
 
56
for oldws in src.worksheets:
 
57
    newws = Worksheet()
 
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
 
64
    newws.offering = dst
 
65
    store.add(newws)
 
66
    ivle.worksheet.utils.update_exerciselist(newws)
58
67
 
59
68
print >> sys.stderr, 'copied %d worksheets from %r to %r' \
60
69
                     % (dst.worksheets.count(), src, dst)