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

« back to all changes in this revision

Viewing changes to ivle/webapp/tutorial/media/exercise_admin.js

  • Committer: Nick Chadwick
  • Date: 2009-03-09 00:15:21 UTC
  • mfrom: (1099.6.4 new-dispatch)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090309001521-dffcygyuyvs2cap0
finished the exercise-ui. It is now ready to be merged with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    ajax_call(callback, update_path, "", args, 'POST');
62
62
}
63
63
 
64
 
/* Modify and add suites */
 
64
/* Modify, add and delete suites */
65
65
function edit_suite(suiteid)
66
66
{
67
67
    var desc = $('#test_suite_description_' + suiteid).val();
119
119
    ajax_call(callback, update_path, "", args, 'POST');
120
120
}
121
121
 
 
122
function delete_suite(suiteid)
 
123
{
 
124
    var callback = function(xhr)
 
125
    {
 
126
        var testresponse;
 
127
        try
 
128
        {
 
129
            testresponse = JSON.parse(xhr.responseText);
 
130
            alert('Suite Deleted.');
 
131
            window.location.reload()
 
132
            return;
 
133
        }
 
134
        catch (ex)
 
135
        {
 
136
            alert('Could not delete suite.');
 
137
        }
 
138
        
 
139
    }
 
140
    
 
141
    var args = {'ivle.op': 'delete_suite', 'suiteid': suiteid}
 
142
    update_path = "api/+exercises/" + exercise;
 
143
    ajax_call(callback, update_path, "", args, 'POST');
 
144
}
 
145
 
122
146
/* Modify and add Variables */
123
147
function edit_var(varid)
124
148
{
170
194
        }
171
195
        catch(ex)
172
196
        {
173
 
            alert('Error Creating Test Suite');
 
197
            alert('Error Adding Variable.');
174
198
            return;
175
199
        }
176
200
    }
182
206
    ajax_call(callback, update_path, "", args, 'POST');
183
207
}
184
208
 
 
209
function delete_var(varid, suiteid)
 
210
{
 
211
    var callback = function(xhr)
 
212
    {
 
213
        var testresponse;
 
214
        try
 
215
        {
 
216
            testresponse = JSON.parse(xhr.responseText);
 
217
            alert('Variable Deleted.');
 
218
            window.location.reload();
 
219
            return;
 
220
        }
 
221
        catch(ex)
 
222
        {
 
223
            alert('Error Deleting Variable');
 
224
            return;
 
225
        }
 
226
    }
 
227
    var args = {'ivle.op': 'delete_var', 'suiteid': suiteid, 'varid': varid};
 
228
    update_path = "api/+exercises/" + exercise;
 
229
    ajax_call(callback, update_path, "", args, 'POST');
 
230
 
 
231
}
 
232
 
185
233
/* Add and edit test case parts */
186
234
 
187
235
function add_test_case(suiteid)
188
236
{
189
 
    var passmsg = $("new_test_case_pass_" + suiteid).val();
190
 
    var failmsg = $("new_test_case_fail_" + suiteid).val();
191
 
    var case_default = $("new_test_case_default_" + suiteid).val();
 
237
    var passmsg = $("#new_test_case_pass_" + suiteid).val();
 
238
    var failmsg = $("#new_test_case_fail_" + suiteid).val();
 
239
    var case_default = $("#new_test_case_default_" + suiteid).val();
192
240
    
193
241
    var callback = function(xhr)
194
242
    {
196
244
        try
197
245
        {
198
246
            testresponse = JSON.parse(xhr.responseText);
199
 
            alert('Variable Added Sucessfully');
 
247
            alert('Test Case Added Sucessfully');
200
248
            window.location.reload();
201
249
            return;
202
250
        }
207
255
        }
208
256
    }
209
257
    
 
258
    var args = {'ivle.op': 'add_testcase', 'passmsg': passmsg, 
 
259
                'failmsg': failmsg, 'default': case_default,
 
260
                'suiteid': suiteid};
 
261
    update_path = "api/+exercises/" + exercise;
 
262
    ajax_call(callback, update_path, "", args, 'POST');
 
263
    
 
264
}
 
265
 
 
266
function edit_test_case(testid, suiteid)
 
267
{
 
268
    var passmsg = $("#test_case_pass_" + testid + "_" + suiteid).val();
 
269
    var failmsg = $("#test_case_fail_" + testid + "_" + suiteid).val();
 
270
    var case_default = $("#test_case_default_" + testid + "_" + suiteid).val();
 
271
    
 
272
    var callback = function(xhr)
 
273
    {
 
274
        var testresponse;
 
275
        try
 
276
        {
 
277
            testresponse = JSON.parse(xhr.responseText);
 
278
            alert('Test Case Modified Sucessfully');
 
279
            return;
 
280
        }
 
281
        catch(ex)
 
282
        {
 
283
            alert('Error Saving Test Case');
 
284
            return;
 
285
        }
 
286
    }
 
287
    
 
288
    var args = {'ivle.op': 'edit_testcase', 'passmsg': passmsg, 
 
289
                'failmsg': failmsg, 'default': case_default,
 
290
                'testid':testid, 'suiteid': suiteid};
 
291
    update_path = "api/+exercises/" + exercise;
 
292
    ajax_call(callback, update_path, "", args, 'POST');
 
293
}
 
294
 
 
295
function delete_testcase(testid, suiteid)
 
296
{
 
297
    var callback = function(xhr)
 
298
    {
 
299
        var testresponse;
 
300
        try
 
301
        {
 
302
            testresponse = JSON.parse(xhr.responseText);
 
303
            alert('Test Case Deleted.');
 
304
            window.location.reload();
 
305
            return;
 
306
        }
 
307
        catch(ex)
 
308
        {
 
309
            alert('Error Deleting Test Case');
 
310
            return;
 
311
        }
 
312
    }
 
313
    
 
314
    var args = {'ivle.op': 'delete_testcase', 'testid': testid, 
 
315
                'suiteid': suiteid};
 
316
    update_path = "api/+exercises/" + exercise;
 
317
    ajax_call(callback, update_path, "", args, 'POST');
 
318
}
 
319
 
 
320
/* Functions to add, edit, and delete test case parts */
 
321
function edit_test_part(partid, testid, suiteid)
 
322
{
 
323
    var part_type = $("#test_part_part_type_" + partid).val();
 
324
    var test_type = $("#test_part_test_type_" + partid).val();
 
325
    var data = $("#test_part_data_" + partid).val();
 
326
    var filename = $("#test_part_file_" + partid).val();
 
327
    
 
328
    var callback = function(xhr)
 
329
    {
 
330
        var testresponse;
 
331
        try
 
332
        {
 
333
            testresponse = JSON.parse(xhr.responseText);
 
334
            alert("Test Part Modified");
 
335
        }
 
336
        catch (ex)
 
337
        {
 
338
            alert("Error Adding Test Part");
 
339
            return;
 
340
        }
 
341
    }
 
342
    
 
343
    var args = {'ivle.op': 'edit_testpart', 'part_type': part_type, 
 
344
                'test_type': test_type, 'data': data, 'filename': filename,
 
345
                'partid': partid, 'testid': testid, 'suiteid': suiteid};
 
346
    update_path = "api/+exercises/" + exercise;
 
347
    ajax_call(callback, update_path, "", args, 'POST');
 
348
}
 
349
 
 
350
function add_test_part(testid, suiteid)
 
351
{
 
352
    var part_type = $("#new_test_part_part_type_" + testid).val();
 
353
    var test_type = $("#new_test_part_test_type_" + testid).val();
 
354
    var data = $("#new_test_part_data_" + testid).val();
 
355
    var filename = $("#new_test_part_file_" + testid).val();
 
356
 
 
357
    var savebutton = $("#new_test_part_save_" + testid);
 
358
    savebutton.attr('value', 'Saving...');
 
359
    savebutton.attr('disabled', 'disabled');
 
360
    
 
361
    var callback = function(xhr)
 
362
    {
 
363
        var testresponse;
 
364
        var test_part_id;
 
365
        var test_parts = $("#test_case_parts_" + testid);
 
366
        try
 
367
        {
 
368
            testresponse = JSON.parse(xhr.responseText);
 
369
            savebutton.attr('value', 'Saving...');
 
370
            savebutton.removeAttr('disabled');
 
371
            
 
372
            alert("Test Part Added");
 
373
            window.location.reload();
 
374
            return;
 
375
        }
 
376
        catch (ex)
 
377
        {
 
378
            alert("Error Adding Test Part");
 
379
            return;
 
380
        }
 
381
    }
 
382
    
 
383
    var args = {'ivle.op': 'add_testpart', 'part_type': part_type, 
 
384
                'test_type': test_type, 'data': data, 'filename': filename,
 
385
                'testid': testid, 'suiteid': suiteid};
 
386
    update_path = "api/+exercises/" + exercise;
 
387
    ajax_call(callback, update_path, "", args, 'POST');
 
388
}
 
389
 
 
390
function delete_testpart(partid, testid, suiteid)
 
391
{
 
392
    var callback = function(xhr)
 
393
    {
 
394
        try
 
395
        {
 
396
            testresponse = JSON.parse(xhr.responseText);
 
397
            alert("Test Part Deleted.");
 
398
            window.location.reload();
 
399
            return;
 
400
        }
 
401
        catch (ex)
 
402
        {
 
403
            alert("Error Deleting Test Part");
 
404
            return;
 
405
        }
 
406
    }
 
407
    
 
408
    var args = {'ivle.op': 'delete_testpart', 'partid': partid, 
 
409
                'testid': testid, 'suiteid': suiteid};
 
410
    update_path = "api/+exercises/" + exercise;
 
411
    ajax_call(callback, update_path, "", args, 'POST');
210
412
}