~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to mod/hotpot/mod.html

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!-- This page defines the form to create or edit an instance of this module -->
2
 
<!-- It is used from /course/mod.php.The whole instance is available as $form. -->
3
 
 
4
 
<?php 
5
 
 
6
 
require_once("$CFG->dirroot/mod/hotpot/lib.php");
7
 
 
8
 
// set default values in form fields, if necessary
9
 
set_form_fields($form);
10
 
 
11
 
// commonly used array of <select> options
12
 
$yes_no_options = array(
13
 
    HOTPOT_NO => get_string("no"), 
14
 
    HOTPOT_YES => get_string("yes")
15
 
);
16
 
$text_source_options = array(
17
 
    HOTPOT_TEXTSOURCE_QUIZ => get_string("textsourcequiz", "hotpot"), 
18
 
    HOTPOT_TEXTSOURCE_FILENAME => get_string("textsourcefilename", "hotpot"),
19
 
    HOTPOT_TEXTSOURCE_FILEPATH => get_string("textsourcefilepath", "hotpot"),
20
 
    HOTPOT_TEXTSOURCE_SPECIFIC => get_string("textsourcespecific", "hotpot")
21
 
);
22
 
?>
23
 
<script type="text/javascript">
24
 
//<![CDATA[
25
 
    var nameoffvalues = new Array(0,1,2);
26
 
    var namelockitems = new Array('name');
27
 
 
28
 
    var timeoffvalues = new Array('0'); // needs to be '0', not just 0
29
 
    var timeopenlockitems = new Array('openday','openmonth','openyear','openhour', 'openminute');
30
 
    var timecloselockitems = new Array('closeday','closemonth','closeyear','closehour','closeminute');
31
 
 
32
 
    var feedbackoffvalues = new Array(0,3,4,5);
33
 
    var feedbacklockitems = new Array('studentfeedbackurl');
34
 
 
35
 
    function hotpot_lockoptions(form, master, subitems, offvalues) {
36
 
        var disabled = false;
37
 
        var Frm = document.forms[form];
38
 
        if (Frm) {
39
 
            var obj = Frm.elements[master];
40
 
            if (obj) {
41
 
                var v = '';
42
 
                if (obj.type=='select-one') {
43
 
                    var v = obj.options[obj.selectedIndex].value;
44
 
                    for (i=0; i<offvalues.length; i++) {
45
 
                        if (v==offvalues[i]) {
46
 
                            disabled = true;
47
 
                        }
48
 
                    }
49
 
                } else if (obj.type=='checkbox') {
50
 
                    if (obj.checked==false) {
51
 
                        disabled = true;
52
 
                    }
53
 
                }
54
 
            }
55
 
            for (i=0; i<subitems.length; i++) {
56
 
                var obj = Frm.elements[subitems[i]];
57
 
                if (obj) {
58
 
                    obj.disabled = disabled;
59
 
                }
60
 
            }
61
 
        }
62
 
        return(true);
63
 
    }
64
 
//]]>
65
 
</script>
66
 
<center>
67
 
<form id="form" method="post" action="mod.php">
68
 
<table cellpadding="5">
69
 
    <tr valign="top">
70
 
        <td align="right"><b><?php print_string("name") ?>:</b></td>
71
 
        <td align="left"><?php
72
 
            if ($form->mode=='add') {
73
 
                choose_from_menu(
74
 
                    $text_source_options, "namesource", "$form->namesource", "", 
75
 
                    "return hotpot_lockoptions('form', 'namesource', namelockitems, nameoffvalues)"
76
 
                );
77
 
            } else {
78
 
                print '<input type="hidden" name="namesource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'" />';
79
 
            }
80
 
            print '<input type="text" name="name" size=40 value="'.$form->name.'">';
81
 
        ?></td>
82
 
    </tr>
83
 
    <tr valign="top">
84
 
        <td align="right">
85
 
            <b><?php 
86
 
                print_string("summary") 
87
 
            ?>:</b><br />
88
 
            <font size="1"><?php
89
 
                helpbutton("summary", get_string("summary"), "resource", true, true);
90
 
                print '<br />';
91
 
                helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
92
 
                print '<br />';
93
 
                if (isset($usehtmleditor) && $usehtmleditor) {
94
 
                    helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
95
 
                    print '<br />';
96
 
                } else {
97
 
                    helpbutton("text", get_string("helptext"), "moodle", true, true); 
98
 
                    print '<br />';
99
 
                    emoticonhelpbutton("form", "description");
100
 
                }
101
 
            ?></font>
102
 
            </span>
103
 
        </td>
104
 
        <td align="left"><?php 
105
 
            if ($form->mode=='add') {
106
 
                choose_from_menu($text_source_options, "summarysource", "$form->summarysource", "");
107
 
                print '<br />';
108
 
            } else {
109
 
                print '<input type="hidden" name="summarysource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'" />';
110
 
            }
111
 
            if (function_exists("print_textarea") && isset($usehtmleditor)) {
112
 
                print_textarea($usehtmleditor, 10, 65, 680, 400, "summary", $form->summary);
113
 
            } else {
114
 
                // Moodle 1.1.1 (original size was rows="5" cols="50")
115
 
                print '<textarea name="summary" rows="10" cols="65" wrap="virtual">'.$form->summary.'</textarea>';
116
 
            }
117
 
        ?></td>
118
 
    </tr>
119
 
    <tr valign="top">
120
 
        <td align="right"><b><?php print_string("quizopen", "quiz") ?>:</b></td>
121
 
        <td align="left"><?php
122
 
            if (!$form->timeopen && $course->format == "weeks") {
123
 
                $form->timeopen = $course->startdate + (($form->section - 1) * 608400);
124
 
            }
125
 
            print '<input name="enabletimeopen" type="checkbox" value="1" alt="'.get_string("quizopen", "quiz").'" onclick="'."return hotpot_lockoptions('form', 'enabletimeopen', timeopenlockitems)".'" '.(empty($form->timeopen) ? '' : 'checked="checked"').' />';
126
 
            print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
127
 
            print ' - ';
128
 
            print_time_selector("openhour", "openminute", $form->timeopen);
129
 
            helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
130
 
        ?></td>
131
 
    </tr>
132
 
    <tr valign="top">
133
 
        <td align="right"><b><?php print_string("quizclose", "quiz") ?>:</b></td>
134
 
        <td align="left"><?php
135
 
            if (!$form->timeclose && $course->format == "weeks") {
136
 
                $form->timeclose= $course->startdate + (($form->section) * 608400);
137
 
            }
138
 
            print '<input name="enabletimeclose" type="checkbox" value="1" alt="'.get_string("quizclose", "quiz").'" onclick="'."return hotpot_lockoptions('form', 'enabletimeclose', timecloselockitems)".'" '.(empty($form->timeclose) ? '' : 'checked="checked"').' />';
139
 
            print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
140
 
            print ' - ';
141
 
            print_time_selector("closehour", "closeminute", $form->timeclose);
142
 
            helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
143
 
        ?></td>
144
 
    </tr>
145
 
    <tr valign="top">
146
 
        <td align="right" nowrap>
147
 
            <b><?php print get_string("location","hotpot") ?>:</b>
148
 
        </td>
149
 
        <td align="left"><?php
150
 
 
151
 
            if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
152
 
                $site = get_site();
153
 
                if ($course->id==$site->id) {
154
 
                    $id = $site->id;
155
 
                    $location = HOTPOT_LOCATION_SITEFILES;
156
 
                } else {
157
 
                    $id = "'+(getObjValue(this.form.location)==".HOTPOT_LOCATION_SITEFILES."?".$site->id.":".$course->id.")+'";
158
 
                    $location = '';
159
 
                }
160
 
            } else { // ordinary teacher or content creator
161
 
                    $id = $course->id;
162
 
                    $location = HOTPOT_LOCATION_COURSEFILES;
163
 
            }
164
 
 
165
 
            if (array_key_exists($location, $HOTPOT_LOCATION)) {
166
 
                print '<input type="hidden" name="location" value="'.$location.'" />';
167
 
                print '<i><font size="-1">'.$HOTPOT_LOCATION[$location].'</font></i> &nbsp; ';
168
 
 
169
 
            } else { // admin can select from "site" or "course" files
170
 
                choose_from_menu($HOTPOT_LOCATION, "location", "$form->location", "");
171
 
            }
172
 
 
173
 
 
174
 
            if (function_exists("button_to_popup_window")) {
175
 
 
176
 
                // use javascript to extract wdir from the reference field
177
 
                $wdir = "'+getDir(getObjValue(this.form.reference))+'";
178
 
 
179
 
                // set button url depending on Moodle version
180
 
                if ($CFG->version < 2004083125) { // version may need refining
181
 
                    // up to and including Moodle 1.4.1
182
 
                    $url = "/mod/resource/coursefiles.php?id=$id&wdir=$wdir";
183
 
                } else {
184
 
                    // Moodle 1.4.2 and beyond
185
 
                    $url = "/files/index.php?id=$id&wdir=$wdir&choose=form.reference";
186
 
                }
187
 
 
188
 
                $strchooseafile = get_string("chooseafile", "resource");
189
 
                button_to_popup_window ($url, 'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
190
 
            }
191
 
        ?></td>
192
 
    </tr>
193
 
    <tr valign="top">
194
 
        <td align="right" nowrap>
195
 
            <b><?php print_string("filename", "resource") ?>:</b>
196
 
        </td>
197
 
        <td align="left"><?php
198
 
            if (function_exists("button_to_popup_window")) {
199
 
                print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
200
 
 
201
 
            } else if (function_exists("get_directory_list")) {
202
 
                // Moodle 1.1 (and perhaps some others)
203
 
                $dirs = get_directory_list("$CFG->dataroot/$course->id");
204
 
                $options = array();
205
 
                foreach ($dirs as $dir) {
206
 
                    $options["$dir"] = $dir;
207
 
                }
208
 
                choose_from_menu ($options, "reference", $form->reference);
209
 
 
210
 
            } else {
211
 
                // a very old Moodle (may be none left :-)
212
 
                print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
213
 
            }
214
 
            print '<br />';
215
 
            hotpot_print_show_links($form->course, $form->location, $form->reference, '', ' &nbsp; ', true);
216
 
        ?></td>
217
 
    </tr>
218
 
    <tr valign="top">
219
 
        <td align="right"><b><?php 
220
 
            $quizchain = "{$form->mode}quizchain";
221
 
            print_string($quizchain, "hotpot"); 
222
 
        ?>:</b></td>
223
 
        <td align="left"><?php
224
 
            choose_from_menu($yes_no_options, "quizchain", $form->quizchain, "");
225
 
            helpbutton($quizchain, get_string($quizchain,"hotpot"), "hotpot");
226
 
        ?></td>
227
 
    </tr>
228
 
    <tr valign="top">
229
 
        <td align="right"><b><?php print_string("outputformat", "hotpot") ?>:</b></td>
230
 
        <td align="left"><?php
231
 
            choose_from_menu($HOTPOT_OUTPUTFORMAT, "outputformat", "$form->outputformat", "");
232
 
            helpbutton("outputformat", get_string("outputformat","hotpot"), "hotpot");
233
 
        ?></td>
234
 
    </tr>
235
 
    <tr valign="top">
236
 
        <td align="right"><b><?php print_string("navigation", "hotpot") ?>:</b></td>
237
 
        <td align="left"><?php
238
 
            choose_from_menu($HOTPOT_NAVIGATION, "navigation", "$form->navigation", "");
239
 
            helpbutton("navigation", get_string("navigation","hotpot"), "hotpot");
240
 
        ?></td>
241
 
    </tr>
242
 
    <tr valign="top">
243
 
        <td align="right"><b><?php print_string("studentfeedback", "hotpot") ?>:</b></td>
244
 
        <td align="left"><?php
245
 
            choose_from_menu(
246
 
                $HOTPOT_FEEDBACK, "studentfeedback", "$form->studentfeedback", "",
247
 
                "return hotpot_lockoptions('form', 'studentfeedback', feedbacklockitems, feedbackoffvalues)"
248
 
            );
249
 
                        print '<span id="studentfeedbackurlSPAN">';
250
 
            print "<input name=\"studentfeedbackurl\" size=\"50\" value=\"$form->studentfeedbackurl\">";
251
 
                        print '</span>';
252
 
            helpbutton("studentfeedback", get_string("studentfeedback","hotpot"), "hotpot");
253
 
        ?></td>
254
 
    </tr>
255
 
    <tr valign="top">
256
 
        <td align="right"><b><?php print_string("forceplugins", "hotpot") ?>:</b></td>
257
 
        <td align="left"><?php
258
 
            choose_from_menu($yes_no_options, "forceplugins", "$form->forceplugins", "");
259
 
            helpbutton("forceplugins", get_string("forceplugins","hotpot"), "hotpot");
260
 
        ?></td>
261
 
    </tr>
262
 
    <tr valign="top">
263
 
        <td align="right"><b><?php print_string("shownextquiz", "hotpot") ?>:</b></td>
264
 
        <td align="left"><?php
265
 
            choose_from_menu($yes_no_options, "shownextquiz", "$form->shownextquiz", "");
266
 
            helpbutton("shownextquiz", get_string("shownextquiz","hotpot"), "hotpot");
267
 
        ?></td>
268
 
    </tr>
269
 
    <tr valign="top">
270
 
        <td align="right"><b><?php print_string("allowreview", "quiz") ?>:</b></td>
271
 
        <td align="left"><?php
272
 
            choose_from_menu($yes_no_options, "review", "$form->review", "");
273
 
            helpbutton("review", get_string("allowreview","quiz"), "quiz");
274
 
        ?></td>
275
 
    </tr>
276
 
    <tr valign="top">
277
 
        <td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
278
 
        <td align="left"><?php
279
 
            $options = array();
280
 
            for ($i=100; $i>=1; $i--) {
281
 
                $options[$i] = $i;
282
 
            }
283
 
            $options[0] = get_string("nograde");
284
 
 
285
 
            choose_from_menu($options, "grade", "$form->grade", "");
286
 
            helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
287
 
        ?></td>
288
 
    </tr>
289
 
    <tr valign="top">
290
 
        <td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
291
 
        <td align="left"><?php
292
 
            choose_from_menu($HOTPOT_GRADEMETHOD, "grademethod", "$form->grademethod", "");
293
 
            helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
294
 
        ?></td>
295
 
    </tr>
296
 
    <tr valign="top">
297
 
        <td align="right"><b><?php print_string("attemptsallowed", "quiz") ?>:</b></td>
298
 
        <td align="left"><?php
299
 
            $options = array(
300
 
                0 => get_string("attemptsunlimited", "quiz"),
301
 
                1 => '1 '.strtolower(get_string("attempt", "quiz"))
302
 
            );
303
 
            for ($i=2; $i<=10; $i++) {
304
 
                $options[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
305
 
            }
306
 
            choose_from_menu($options, "attempts", "$form->attempts", "");
307
 
            helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
308
 
        ?></td>
309
 
    </tr>
310
 
    <tr valign="top">
311
 
        <td align="right"><b><?php print_string("requirepassword", "quiz") ?>:</b></td>
312
 
        <td align="left">
313
 
            <input type="text" name="password" size=40 value="<?php p($form->password) ?>">
314
 
            <?php helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
315
 
        </td>
316
 
    </tr>
317
 
    <tr valign="top">
318
 
        <td align="right"><b><?php print_string("requiresubnet", "quiz") ?>:</b></td>
319
 
        <td align="left">
320
 
            <input type="text" name="subnet" size=40 value="<?php p($form->subnet) ?>">
321
 
            <?php helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
322
 
        </td>
323
 
    </tr>
324
 
    <tr valign="top">
325
 
        <td align="right"><b><?php print_string("clickreporting", "hotpot") ?>:</b></td>
326
 
        <td align="left"><?php
327
 
            choose_from_menu($yes_no_options, "clickreporting", "$form->clickreporting", "");
328
 
            helpbutton("clickreporting", get_string("clickreporting","hotpot"), "hotpot");
329
 
        ?></td>
330
 
    </tr>
331
 
<?php 
332
 
    print_standard_coursemodule_settings($form); 
333
 
?>
334
 
    <tr valign="top">
335
 
        <td align="right">&nbsp;</td>
336
 
        <td align="left">
337
 
            <!-- buttons -->
338
 
            <input type="submit" value="<?php print_string("savechanges") ?>"> &nbsp; &nbsp;
339
 
            <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" /><br />
340
 
            <?php
341
 
                if (isset($CFG->release) && substr($CFG->release, 0, 3)>=1.5) {
342
 
                    $options = array(
343
 
                        HOTPOT_DISPLAYNEXT_QUIZ => get_string("displayhotpotnext", "hotpot"),
344
 
                        HOTPOT_DISPLAYNEXT_COURSE => get_string("displaycoursenext", "hotpot"),
345
 
                        HOTPOT_DISPLAYNEXT_INDEX => get_string("displayindexnext", "hotpot")
346
 
                    );
347
 
                    choose_from_menu($options, "displaynext", "$form->displaynext", "");
348
 
                } else {
349
 
                    print '<input type="hidden" name="displaynext" value="'.HOTPOT_NO.'" />'."\n";
350
 
                }
351
 
            ?>
352
 
</table>
353
 
 
354
 
<!-- hidden fields -->
355
 
<input type="hidden" name="course"        value="<?php p($form->course) ?>">
356
 
<input type="hidden" name="coursemodule"  value="<?php p($form->coursemodule) ?>">
357
 
<input type="hidden" name="section"       value="<?php p($form->section) ?>">
358
 
<input type="hidden" name="module"        value="<?php p($form->module) ?>">
359
 
<input type="hidden" name="modulename"    value="<?php p($form->modulename) ?>">
360
 
<input type="hidden" name="instance"      value="<?php p($form->instance) ?>">
361
 
<input type="hidden" name="mode"          value="<?php p($form->mode) ?>">
362
 
<?php if (isset($USER->sesskey)) { ?>
363
 
<input type="hidden" name="sesskey"       value="<?php p($USER->sesskey) ?>">
364
 
<?php } ?>
365
 
 
366
 
</form>
367
 
</center>
368
 
<script type="text/javascript">
369
 
<!--
370
 
    hotpot_lockoptions('form', 'namesource', namelockitems, nameoffvalues);
371
 
    hotpot_lockoptions('form', 'enabletimeopen', timeopenlockitems, timeoffvalues);
372
 
    hotpot_lockoptions('form', 'enabletimeclose', timecloselockitems, timeoffvalues);
373
 
    hotpot_lockoptions('form', 'studentfeedback', feedbacklockitems, feedbackoffvalues);
374
 
 
375
 
    // override the standard Moodle "setfocus" function, 
376
 
    // which gives a js error if the "name" field is hidden
377
 
    function setfocus() {
378
 
        var Frm = document.getElementById('form');
379
 
        if (Frm) {
380
 
                if (canfocus(Frm, 'namesource')) {
381
 
                        Frm.namesource.focus();
382
 
                } else if (canfocus(Frm, 'name')) {
383
 
                        Frm.name.focus();
384
 
                }
385
 
        }
386
 
    }
387
 
    function canfocus(Frm, name) {
388
 
        var obj = eval('Frm.' + name);
389
 
        return (obj==null || obj.type=='hidden' || obj.focus==null || (obj.style && obj.style.display=='none')) ? false : true;
390
 
    }
391
 
//-->
392
 
</script>
393
 
<?php
394
 
 
395
 
// ======================
396
 
//  functions
397
 
// ======================
398
 
 
399
 
function set_form_fields(&$form) {
400
 
    set_form_field($form, 'name');
401
 
    set_form_field($form, 'summary');
402
 
    set_form_field($form, 'timeopen', get_user_preferences('hotpot_timeopen', 0));
403
 
    set_form_field($form, 'enabletimeopen', empty($form->timeopen) ? HOTPOT_NO : HOTPOT_YES);
404
 
    set_form_field($form, 'timeclose', get_user_preferences('hotpot_timeclose', 0));
405
 
    set_form_field($form, 'enabletimeclose', empty($form->timeclose) ? HOTPOT_NO : HOTPOT_YES);
406
 
    set_form_field($form, 'location', HOTPOT_LOCATION_COURSEFILES);
407
 
    set_form_field($form, 'reference');
408
 
    set_form_field($form, 'navigation', get_user_preferences('hotpot_navigation', HOTPOT_NAVIGATION_BAR));
409
 
    set_form_field($form, 'outputformat', get_user_preferences('hotpot_outputformat', HOTPOT_OUTPUTFORMAT_BEST));
410
 
    set_form_field($form, 'studentfeedback', get_user_preferences('hotpot_studentfeedback', HOTPOT_FEEDBACK_NONE));
411
 
    set_form_field($form, 'studentfeedbackurl', get_user_preferences('hotpot_studentfeedbackurl', 'http://'));
412
 
    set_form_field($form, 'forceplugins', get_user_preferences('hotpot_forceplugins', HOTPOT_NO));
413
 
    if ($form->mode=='add') {
414
 
        set_form_field($form, 'namesource', get_user_preferences('hotpot_namesource', HOTPOT_TEXTSOURCE_QUIZ));
415
 
        set_form_field($form, 'summarysource', get_user_preferences('hotpot_summarysource', HOTPOT_TEXTSOURCE_QUIZ));
416
 
        $quizchain = get_user_preferences('hotpot_quizchain', HOTPOT_NO);
417
 
    } else {
418
 
        $quizchain = empty($form->quizchain) ? HOTPOT_NO : HOTPOT_YES;
419
 
    }
420
 
    set_form_field($form, 'quizchain', $quizchain);
421
 
    set_form_field($form, 'shownextquiz', get_user_preferences('hotpot_shownextquiz', HOTPOT_NO));
422
 
    set_form_field($form, 'review', get_user_preferences('hotpot_review', HOTPOT_YES));
423
 
    set_form_field($form, 'grade', get_user_preferences('hotpot_grade', 100));
424
 
    set_form_field($form, 'grademethod', get_user_preferences('hotpot_grademethod', HOTPOT_GRADEMETHOD_HIGHEST));
425
 
    set_form_field($form, 'attempts', get_user_preferences('hotpot_attempts', 0)); // 0=unlimited
426
 
    set_form_field($form, 'password');
427
 
    set_form_field($form, 'subnet', get_user_preferences('hotpot_subnet'));
428
 
    set_form_field($form, 'clickreporting', HOTPOT_NO);
429
 
    set_form_field($form, 'displaynext', get_user_preferences('hotpot_displaynext', HOTPOT_DISPLAYNEXT_QUIZ));
430
 
}
431
 
function set_form_field(&$form, $fieldname, $defaultvalue='') {
432
 
    if (!isset($form->$fieldname)) {
433
 
        $form->$fieldname = $defaultvalue;
434
 
    }
435
 
}
436
 
?>