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

« back to all changes in this revision

Viewing changes to bin/ivle-addexercise

  • Committer: William Grant
  • Date: 2009-03-04 00:27:20 UTC
  • Revision ID: grantw@unimelb.edu.au-20090304002720-tdicsjr1zi30gmgd
Tags: 0.1.9.8, 0.1.9.9
In the console, append a newline to the end of a submitted block of code. 
Fixes issue 111.

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
xmlfile = sys.argv[1]
176
176
 
177
177
def add_exercise(xmlfile):
 
178
    store = get_store()
 
179
 
 
180
    # Skip existing ones.
 
181
    if store.find(Exercise, id=unicode(xmlfile)).count():
 
182
        return
 
183
 
 
184
    print "Adding exercise", xmlfile
178
185
    try:
179
186
        filedom = minidom.parse(xmlfile)
180
187
    except IOError, e:
215
222
        elif child.tagName == 'desc':
216
223
            description = getTextData(child)
217
224
 
218
 
    if solution is None:
219
 
        raise XMLMalformedError("ivle-addexercise: error parsing XML: No solution given")
220
 
    if len(test_suite_nodes) == 0:
221
 
        raise XMLMalformedError("ivle-addexercise: error parsing XML: No Tests Given!")
222
 
 
223
 
    store = get_store()
224
225
    new_exercise = Exercise()
225
226
    new_exercise.id = unicode(xmlfile)
226
227
    new_exercise.name = exercisename
241
242
    
242
243
xmlfiles = sys.argv[1:]
243
244
for xmlfile in xmlfiles:
244
 
    print "Adding exercise", xmlfile
245
245
    try:
246
246
        add_exercise(xmlfile)
247
247
    except Exception, e: