~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-08 06:07:16 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090308060716-f3i65yqr9otr7p5n
Exercise UI is now ready to be merged into 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)
244
292
    ajax_call(callback, update_path, "", args, 'POST');
245
293
}
246
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 */
247
321
function edit_test_part(partid, testid, suiteid)
248
322
{
249
323
    var part_type = $("#test_part_part_type_" + partid).val();
313
387
    ajax_call(callback, update_path, "", args, 'POST');
314
388
}
315
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');
 
412
}