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

« back to all changes in this revision

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

  • Committer: mattgiuca
  • Date: 2008-04-06 15:04:54 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:725
The database now stores a cache of all the worksheets and what problems
are contained within each, for the purposes of determining marks.

This cache is automatically written to the database when someone visits a
worksheet in the website. If the worksheet file gets updated (touched), then
the database entries will be refreshed (so it is kept up to date).

At this stage, it isn't used to compute anything, it just gets stored in the
DB and updated.

Also added an "assessable" attribute to the worksheet element in the
worksheet XML, and an "optional" attribute to the exercise element, also in
the worksheet XML. (Both of these are optional, so it won't break existing
worksheets). Both default to False, so by default worksheets are not
assessable, and assessable worksheets have all-mandatory exercises.

users.sql: Added worksheet and worksheet_problem tables to the DB.
common/db.py: Added methods get_worksheet_mtime and create_worksheet.
tutorial/__init__.py:
    present_table_of_contents now gathers up details about all the exercises.
    present_worksheet now gets top level details.
    Added function update_db_worksheet, which checks the time stamps and
    updates the database if necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
var user_data;
24
24
 
 
25
function onload()
 
26
{
 
27
    revert_settings();
 
28
}
 
29
 
25
30
/* Fetch the user's details from the server, and populate the page.
26
31
 * Returns false. */
27
32
function revert_settings()
32
37
            populate(user);
33
38
        }
34
39
    /* Just get details for the logged in user */
35
 
    ajax_call(callback, "userservice", "get_user", {"login": settings_login}, "GET");
 
40
    ajax_call(callback, "userservice", "get_user", {}, "GET");
36
41
    return false;
37
42
}
38
43
 
42
47
    user_data = user;
43
48
    /* Plain text elements (non-editable) */
44
49
    var login = document.getElementById("login");
45
 
    var admin = document.getElementById("admin");
 
50
    var role = document.getElementById("role");
46
51
    var changepassword = document.getElementById("changepassword");
47
52
    var notices = document.getElementById("notices");
48
53
    /* Textbox (input) elements */
60
65
 
61
66
    /* Clear things */
62
67
    dom_removechildren(login);
63
 
    dom_removechildren(admin);
 
68
    dom_removechildren(role);
64
69
    dom_removechildren(changepassword);
65
70
    dom_removechildren(notices);
66
71
 
79
84
        text = ")"
80
85
    login.appendChild(document.createTextNode(text));
81
86
 
82
 
    /* "admin" : <p>Privilege: <strong>administrator</strong></p>
 
87
    /* "role" : <p>Your privilege level is <b>rolenm</b>.</p>
 
88
     * Unless rolenm is "student"
83
89
     */
84
 
    if (user.admin)
 
90
    if (user.rolenm != "student")
85
91
    {
86
 
        text = "Privilege: ";
87
 
        admin.appendChild(document.createTextNode(text));
88
 
        strong = document.createElement("strong");
89
 
        strong.appendChild(document.createTextNode("IVLE administrator"));
90
 
        admin.appendChild(strong);
 
92
        text = "Your privilege level is ";
 
93
        role.appendChild(document.createTextNode(text));
 
94
        b = document.createElement("b");
 
95
        text = user.rolenm;
 
96
        b.appendChild(document.createTextNode(text));
 
97
        role.appendChild(b);
 
98
        text = ".";
 
99
        role.appendChild(document.createTextNode(text));
91
100
    }
92
101
 
93
102
    /* "nick" and "email" boxes */
102
111
        p.appendChild(document.createTextNode("Change password"))
103
112
        changepassword.appendChild(p);
104
113
        p = document.createElement("p");
105
 
        
106
 
        p.appendChild(document.createTextNode("Please type your old password, "
107
 
                + "and new password twice, for verification."));
 
114
        p.appendChild(document.createTextNode("Please type your new password "
 
115
            + "twice, to make sure you remember it."))
108
116
        changepassword.appendChild(p);
109
117
 
110
118
        table = document.createElement("table");
112
120
 
113
121
        tr = document.createElement("tr");
114
122
        td = document.createElement("td");
115
 
        td.appendChild(document.createTextNode("Old password:"))
116
 
        tr.appendChild(td);
117
 
        td = document.createElement("td");
118
 
        inputbox = document.createElement("input");
119
 
        inputbox.setAttribute("type", "password");
120
 
        inputbox.setAttribute("name", "oldpass");
121
 
        inputbox.setAttribute("id", "oldpass");
122
 
        inputbox.setAttribute("size", "40");
123
 
        td.appendChild(inputbox)
124
 
        tr.appendChild(td);
125
 
        tbody.appendChild(tr);
126
 
 
127
 
        tr = document.createElement("tr");
128
 
        td = document.createElement("td");
129
123
        td.appendChild(document.createTextNode("New password:"))
130
124
        tr.appendChild(td);
131
125
        td = document.createElement("td");
208
202
    /* Textbox (input) elements */
209
203
    try
210
204
    {
211
 
        var oldpass = document.getElementById("oldpass");
212
205
        var newpass = document.getElementById("newpass");
213
206
        var repeatpass = document.getElementById("repeatpass");
214
207
    }
221
214
    var email = document.getElementById("email");
222
215
 
223
216
    /* Check */
224
 
    oldpassval = oldpass == null ? null : oldpass.value;
225
217
    newpassval = newpass == null ? null : newpass.value;
226
218
    repeatpassval = repeatpass == null ? null : repeatpass.value;
227
219
    nickval = nick.value;
268
260
            dom_removechildren(usernick);
269
261
            usernick.appendChild(document.createTextNode(nickval));
270
262
        }
271
 
        else if (xhr.getResponseHeader("X-IVLE-Action-Error"))
272
 
        {
273
 
            set_result(decodeURIComponent(xhr.getResponseHeader(
274
 
                                     "X-IVLE-Action-Error").toString()), true);        
275
 
        }
276
263
        else
277
264
        {
278
265
            set_result("There was a problem updating the details."
279
 
                + " Your changes have not been saved.", true);
 
266
                + " Your changes have not been saved.");
280
267
        }
281
268
    }
282
269
    data = {
283
270
        "login": user_data.login,
284
271
        "nick": nickval,
285
272
        "email": emailval,
286
 
        "oldpass": oldpassval,
287
273
    }
288
274
    if (newpassval != null && newpassval != "")
289
275
        data['password'] = newpassval;