~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 01:15:33 UTC
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090309011533-dw59mhauiysji3nt
Fixed a slight oversight, which meant there was no way to add a new
exercise through the ui.

In addition, entire exercises can now be deleted, providing they have
never been linked to a worksheet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
  $('#' + something).toggle("slow");
25
25
}
26
26
 
 
27
function add_exercise()
 
28
{
 
29
    var exercise_id = $('#exercise_id').val();
 
30
    var exercise_name = $('#exercise_name').val();
 
31
    var exercise_num_rows = $('#exercise_num_rows').val();
 
32
    var exercise_desc = $('#exercise_desc').val();
 
33
    var exercise_partial = $('#exercise_partial').val();
 
34
    var exercise_solution = $('#exercise_solution').val();
 
35
    var exercise_include = $('#exercise_include').val();
 
36
 
 
37
    var callback = function(xhr)
 
38
    {
 
39
        var testresponse;
 
40
        try
 
41
        {
 
42
            testresponse = JSON.parse(xhr.responseText);
 
43
            alert('Exercise Created');
 
44
            window.location = '/+exercises';
 
45
        }
 
46
        catch (ex)
 
47
        {
 
48
            alert('Error: Could not add exercise');
 
49
            return;
 
50
        }
 
51
    }
 
52
    
 
53
    update_path = "api/+exercises";
 
54
    
 
55
    var args = {'identifier': exercise_id , 'name': exercise_name, 
 
56
                'description': exercise_desc, 'partial': exercise_partial,
 
57
                'solution': exercise_solution, 'include': exercise_include,
 
58
                'num_rows': exercise_num_rows, 'ivle.op': 'add_exercise'};
 
59
    ajax_call(callback, update_path, "", args, 'POST');
 
60
    
 
61
}
 
62
 
27
63
/* Edit the exercise values */
28
64
function edit_exercise()
29
65
{