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

« back to all changes in this revision

Viewing changes to www/media/tutorial/tutorial.js

  • Committer: mattgiuca
  • Date: 2008-03-28 06:58:51 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:715
Tutorial: Added "Reset" button to exercises, so you can get back to the
original "partial solution".
    tutorial/init.py: Stores the backed up text hidden in the HTML so it can
    be retrieved by the client at will.
        Added reset button which calls JavaScript.
    tutorial.js: Added resetexercise function (event handler for reset button)
        which replaces the user code with the stored backed up partial soln.

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
        "multipart/form-data");
113
113
}
114
114
 
 
115
/** User clicks "Reset" button. Replace the contents of the user program text
 
116
 * box with the hidden "reset button backup" field, containing the original
 
117
 * partial fragment.
 
118
 * exerciseid: "id" of the exercise's div element.
 
119
 */
 
120
function resetexercise(exerciseid)
 
121
{
 
122
    conf_msg = "This will delete your solution to this exercise, and reset "
 
123
        + "it back to the default partial solution.\n\n"
 
124
        + "Are you sure you want to do this?";
 
125
    if (!confirm(conf_msg))
 
126
        return;
 
127
    /* Get the source code the student is submitting */
 
128
    var exercisediv = document.getElementById(exerciseid);
 
129
    var exercisebox = exercisediv.getElementsByTagName("textarea")[0];
 
130
    var resettextbox = document.getElementById("input_resettext_" + exerciseid);
 
131
    exercisebox.value = resettextbox.value;
 
132
}
 
133
 
115
134
/* savetimers is a dict mapping exerciseIDs to timer IDs.
116
135
 * Its members indicate all exercises that have been modified but not saved.
117
136
 */