~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-02-24 14:32:55 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090224143255-eflrd17t4k8p5s85
Started adding in add and save options in the exercise edit view, to
start supporting full modification of exercises through the browser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * Author: Nick Chadwick
19
19
 */
20
20
 
21
 
function hideall()
22
 
{
23
 
  $('').hide();
24
 
}
25
 
 
26
21
function tog(something)
27
22
{
28
23
  $('#' + something).toggle("slow");
29
24
}
 
25
 
 
26
function save_exercise()
 
27
{
 
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_include').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(testresponse['result']);
 
44
            window.location.reload();
 
45
            return;
 
46
        }
 
47
        catch(ex)
 
48
        {
 
49
            alert('Error updating Exercise');
 
50
            return;
 
51
        }
 
52
    }
 
53
    
 
54
    update_path = "api/+exercises/" + exercise + "/+edit";
 
55
    
 
56
    var args = {'name': exercise_name, 'description': exercise_desc, 
 
57
                'partial': exercise_partial, 'solution': exercise_solution,
 
58
                'include': exercise_include, 'num_rows': exercise_num_rows,
 
59
                'ivle.op': 'update_exercise'};
 
60
    ajax_call(callback, update_path, "", args, 'POST');
 
61
}