File:
[LON-CAPA] /
loncom /
html /
adm /
helper /
newslot.helper
Revision
1.30:
download - view:
text,
annotated -
select for diffs
Wed Jul 24 18:21:46 2013 UTC (11 years ago) by
bisitz
Branches:
MAIN
CVS tags:
version_2_11_X,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0,
HEAD
Corrected wording typos
Updated related phrases in German translation file
1: <helper title="Slot Creation" requiredpriv="mgq">
2: <state name="START" title="Specify Required Attributes"
3: help="Slot_RequiredAttributes">
4:
5: <nextstate>OPTIONAL</nextstate>
6:
7: <exec>
8: if (!exists($helper->{'VARS'}{'name'}) ||
9: $helper->{'VARS'}{'name'} !~ /\S/) {
10: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
11: if (exists($env{'form.name'}) ||
12: $env{'form.name'} =~ /\S/) {
13: $helper->{'VARS'}{'name'}=$env{'form.name'};
14: $helper->{VARS}{'origname'}=$env{'form.name'};
15: $helper->{DATA}{copy} = 1;
16: }
17: }
18: $helper->{DATA}{origslot} = sub {
19: my ($which,$default)=@_;
20: if (!exists($helper->{'VARS'}{'name'}) ||
21: $helper->{'VARS'}{'name'} !~ /\S/) {
22: return $default;
23: }
24: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
25: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
26: my $name=$helper->{VARS}{'origname'};
27: my %slot=&Apache::lonnet::get('slots', [$name], $cdom, $cnum);
28: if (!ref($slot{$name})) { return $default; }
29: if (!exists($slot{$name}{$which})) { return $default; }
30: return $slot{$name}{$which};
31: }
32: </exec>
33: <message>
34: <br />Name: <br />
35: </message>
36: <string variable="name" size="30">
37: <validator>
38: if ($val=~/^\s*$/) { return 'Must specify a name'; }
39: if ($val=~/\s/) { return 'Must not contain spaces'; }
40: if ($val=~/\W/) { return 'Must contain only letters, numbers and _'; }
41: return undef;
42: </validator>
43: <defaultvalue>
44: return $helper->{'VARS'}{'name'};
45: </defaultvalue>
46: </string>
47: <condition>
48: <clause>$helper->{DATA}{copy}</clause>
49: <message>
50: <p>Changing the Name will create a new slot with the new name, and not rename the existing slot.</p>
51: </message>
52: </condition>
53: <message>
54: <br />Start time:<br />
55: </message>
56: <date variable="starttime" hoursminutes="1">
57: <defaultvalue>
58: return &{$helper->{DATA}{origslot}}('starttime');
59: </defaultvalue>
60: </date>
61: <message>
62: <br />End time:<br />
63: </message>
64: <date variable="endtime" hoursminutes="1">
65: <defaultvalue>
66: return &{$helper->{DATA}{origslot}}('endtime');
67: </defaultvalue>
68: <validator>
69: if ($val < $helper->{'VARS'}{'starttime'}) {
70: return 'End time must be later than the start time.';
71: }
72: return undef;
73: </validator>
74: </date>
75: <message>
76: <br />Type:
77: </message>
78: <choices variable="type">
79: <choice computer='preassigned'>Instructor assignable.</choice>
80: <choice computer='schedulable_student'>Student selectable.</choice>
81: <defaultvalue>
82: return &{$helper->{DATA}{origslot}}('type','preassigned');
83: </defaultvalue>
84: </choices>
85: </state>
86:
87:
88: <state name="OPTIONAL" title="Specify Optional Attributes"
89: help="Slot_OptionalAttributes">
90: <message>
91: <p>Description:<br />
92: </message>
93: <string variable="description" size="60">
94: <defaultvalue>
95: return &{$helper->{DATA}{origslot}}('description');
96: </defaultvalue>
97: </string>
98: <condition>
99: <clause>$helper->{'VARS'}{'type'} eq 'schedulable_student'</clause>
100: <message>
101: </p><p>Time students can start reserving:<br />
102: </message>
103: <date variable="startreserve" hoursminutes="1" anytime="1">
104: <defaultvalue>
105: return &{$helper->{DATA}{origslot}}('startreserve','anytime');
106: </defaultvalue>
107: <validator>
108: if (defined($val) && $val > $helper->{'VARS'}{'starttime'}) {
109: return 'Reservation time must come before the slot has started.';
110: }
111: return undef;
112: </validator>
113: </date>
114: <message>
115: </p><p>Time students can no longer reserve:<br />
116: </message>
117: <date variable="endreserve" hoursminutes="1" anytime="1">
118: <defaultvalue>
119: return &{$helper->{DATA}{origslot}}('endreserve','anytime');
120: </defaultvalue>
121: <validator>
122: if (defined($val) && $val > $helper->{'VARS'}{'starttime'}) {
123: return 'Reservation end time must come before the slot has started.';
124: }
125: return undef;
126: </validator>
127: </date>
128: <message>
129: </p><p>Maximum number of students allowed in this slot:<br />
130: </message>
131: <string variable="maxspace" size="4">
132: <validator>
133: if ($val ne '' && $val=~/\D/) { return 'Must be numeric.'; }
134: return undef;
135: </validator>
136: <defaultvalue>
137: return &{$helper->{DATA}{origslot}}('maxspace');
138: </defaultvalue>
139: </string>
140: <message>
141: </p><p>Period of time when this slot can only be uniquely chosen:<br /> Start:
142: </message>
143: <date variable="startunique" hoursminutes="1" anytime="1">
144: <defaultvalue>
145: my $default=&{$helper->{DATA}{origslot}}('uniqueperiod','anytime');
146: if ($default eq 'anytime') { return 'anytime' };
147: if (ref($default)) { return $default->[0]; }
148: return 'anytime';
149: </defaultvalue>
150: </date>
151: <message><br /> End: </message>
152: <date variable="endunique" hoursminutes="1" anytime="1">
153: <defaultvalue>
154: my $default=&{$helper->{DATA}{origslot}}('uniqueperiod','anytime');
155: if ($default eq 'anytime') { return 'anytime' };
156: if (ref($default)) { return $default->[1]; }
157: return 'anytime';
158: </defaultvalue>
159: <validator>
160: if (defined($val) && $val < $helper->{'VARS'}{'startunique'}) {
161: return 'End time must be later than the start time.';
162: }
163: return undef;
164: </validator>
165: </date>
166: <message>
167: </p><p>Message(s) triggered by reservation change by student
168: </message>
169: <choices variable="reservationmsg">
170: <choice computer='only_student'>Sent to student</choice>
171: <choice computer='student_and_user_notes_screen'>Sent to student and added to user notes</choice>
172: <choice computer='none'>None sent and no record in user notes</choice>
173: <defaultvalue>
174: my $default=&{$helper->{DATA}{origslot}}('reservationmsg');
175: if ($default eq 'only_student') { return $default; }
176: if ($default eq 'student_and_user_notes_screen') { return $default; }
177: return 'none';
178: </defaultvalue>
179: </choices>
180: </condition>
181: <condition>
182: <clause>$helper->{'VARS'}{'type'} eq 'preassigned'</clause>
183: <exec>
184: delete($helper->{'VARS'}{'startreserve'});
185: delete($helper->{'VARS'}{'endreserve'});
186: delete($helper->{'VARS'}{'maxspace'});
187: delete($helper->{'VARS'}{'startunique'});
188: delete($helper->{'VARS'}{'endunique'});
189: </exec>
190: </condition>
191:
192: <message>
193: </p><p>Proctored access:
194: </message>
195: <choices variable="useproctor">
196: <choice computer='no'>No proctor checkin required for access.</choice>
197: <choice computer='yes'>Require proctored checkin for access.</choice>
198: <defaultvalue>
199: my $default=&{$helper->{DATA}{origslot}}('proctor');
200: if ($default) { return 'yes'; }
201: return 'no';
202: </defaultvalue>
203: </choices>
204:
205: <message>
206: </p><p>Secret word proctors use to checkin users:<br />
207: </message>
208: <string variable="secret" size="12">
209: <validator>
210: return undef;
211: </validator>
212: <defaultvalue>
213: return &{$helper->{DATA}{origslot}}('secret');
214: </defaultvalue>
215: </string>
216: <message>
217: </p><p>Slot is:
218: </message>
219: <helpicon file="Slot_ChoosingResources" />
220:
221: <choices variable="restricttosymb">
222: <choice nextstate="PROCTOR" computer='any'>usable for any resource.</choice>
223: <choice nextstate="RESOURCESELECT" computer='resource'>restricted to a specific resource.</choice>
224: <defaultvalue>
225: my $default=&{$helper->{DATA}{origslot}}('symb');
226: if ($default) { return 'resource'; }
227: return 'any';
228: </defaultvalue>
229: </choices>
230:
231: <message>
232: </p><p>IP restrictions:<br />
233: </message>
234: <string variable="ip" size="30">
235: <validator>
236: return undef;
237: </validator>
238: <defaultvalue>
239: return &{$helper->{DATA}{origslot}}('ip');
240: </defaultvalue>
241: </string>
242: <message> </p> </message>
243: </state>
244:
245:
246: <state name="RESOURCESELECT" title="Specify Optional Attributes">
247:
248: <nextstate>PROCTOR</nextstate>
249:
250: <resource variable="symb">
251: <filterfunc>return $res->is_problem()</filterfunc>
252: <valuefunc>return $res->symb()</valuefunc>
253: <defaultvalue>
254: return &{$helper->{DATA}{origslot}}('symb');
255: </defaultvalue>
256: </resource>
257: </state>
258:
259:
260: <state name="PROCTOR" title="Specify Proctors"
261: help="Slot_SpecifyProctors">
262:
263: <skip>
264: <clause>$helper->{'VARS'}{'useproctor'} eq 'no'</clause>
265: <nextstate>RESTRICTUSER</nextstate>
266: </skip>
267:
268: <nextstate>RESTRICTUSER</nextstate>
269:
270: <student variable="proctor" multichoice="1" coursepersonnel="1"
271: activeonly="1" emptyallowed="0">
272: <defaultvalue>
273: my @defaults;
274: my $default=&{$helper->{DATA}{origslot}}('proctor');
275: if ($default) {
276: @defaults=(split(',',$default));
277: }
278: return @defaults;
279: </defaultvalue>
280: </student>
281: </state>
282:
283:
284: <state name="RESTRICTUSER" title="Restrict slot availability"
285: help="Slot_RestrictAvailibility">
286: <skip>
287: <clause>$helper->{'VARS'}{'type'} ne 'schedulable_student'</clause>
288: <nextstate>FINISH</nextstate>
289: </skip>
290:
291: <nextstate>FINISH</nextstate>
292: <message>
293: <p>Slots are by default available to all users in a course, if you would like this slot to be restricted to a subset of users you can specify restrictions.</p>
294: </message>
295:
296: <message>
297: Select sections to limit slot availability to: <br />
298: </message>
299: <section variable="allowedsections" multichoice="1" allowempty="1">
300: <defaultvalue>
301: return join('|||',
302: split(',',&{$helper->{DATA}{origslot}}('allowedsections')));
303: </defaultvalue>
304: </section>
305: <message>
306: Select users to limit slot availability to: <br />
307: </message>
308: <student variable="allowedusers" multichoice="1" coursepersonnel="1"
309: activeonly="1" emptyallowed="1">
310: <defaultvalue>
311: return split(',',&{$helper->{DATA}{origslot}}('allowedusers'));
312: </defaultvalue>
313: </student>
314: </state>
315:
316:
317: <state name="FINISH" title="Creating/Modifying Slot">
318: <message> Created Slot </message>
319: <final>
320: <finalcode>
321: my $result;
322: if ($helper->{'STATE'} ne 'FINISH') { return; }
323: my %slot;
324:
325: foreach my $which ('type','starttime','endtime') {
326: $slot{$which} = $helper->{'VARS'}{$which};
327: }
328:
329: foreach my $which ('ip','description','maxspace','secret','symb') {
330: if ( $helper->{'VARS'}{$which} =~/\S/ ) {
331: $slot{$which} = $helper->{'VARS'}{$which};
332: }
333: }
334:
335: if ($helper->{'VARS'}{'type'} eq 'schedulable_student') {
336: if (($helper->{'VARS'}{'reservationmsg'} eq 'only_student') ||
337: ($helper->{'VARS'}{'reservationmsg'} eq 'student_and_user_notes_screen')) {
338: $slot{'reservationmsg'} = $helper->{'VARS'}{'reservationmsg'};
339: } else {
340: $slot{'reservationmsg'} = 'none';
341: }
342: }
343:
344: if ( $helper->{'VARS'}{'startreserve'} > 0) {
345: $slot{'startreserve'} = $helper->{'VARS'}{'startreserve'};
346: }
347:
348: if ( $helper->{'VARS'}{'endreserve'} > 0) {
349: $slot{'endreserve'} = $helper->{'VARS'}{'endreserve'};
350: }
351:
352: if ( $helper->{'VARS'}{'startunique'} > 0 &&
353: $helper->{'VARS'}{'endunique'} > 0 ) {
354: $slot{'uniqueperiod'} = [$helper->{'VARS'}{'startunique'},
355: $helper->{'VARS'}{'endunique'}];
356: }
357:
358: if ( $helper->{'VARS'}{'useproctor'} eq 'yes'
359: && $helper->{'VARS'}{'proctor'} =~/\S/ ) {
360: my @names;
361: # just need the username/domain throw away the other data
362: # that <student> returns
363: foreach my $user (split(/\|\|\|/, $helper->{'VARS'}{'proctor'})) {
364: my ($uname,$udomain)=split(/:/,$user);
365: push(@names,"$uname:$udomain");
366: }
367: # make sure the usernmaes are unique
368: my %proctors = map { ($_,1) } @names;
369: $slot{'proctor'}=join(',',sort(keys(%proctors)));
370: }
371:
372: if ( $helper->{'VARS'}{'allowedsections'} =~/\S/ ) {
373: $slot{'allowedsections'}=
374: join(',',sort(split(/\|\|\|/,
375: $helper->{'VARS'}{'allowedsections'})));
376: }
377:
378: if ( $helper->{'VARS'}{'allowedusers'} =~/\S/ ) {
379: my @names;
380: # just need the username/domain throw away the other data
381: # that <student> returns
382: foreach my $item (split(/\|\|\|/,
383: $helper->{'VARS'}{'allowedusers'})) {
384: my ($uname,$udomain)=split(/:/,$item);
385: push(@names,"$uname:$udomain");
386: }
387:
388: # make sure the choices are unique
389: my %users = map { ($_,1) } @names;
390: $slot{'allowedusers'}=join(',',sort(keys(%users)));
391: }
392:
393: my $cname = $env{'course.'.$env{'request.course.id'}.'.num'};
394: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
395:
396: my $ret = &Apache::lonnet::cput('slots',
397: {$helper->{'VARS'}{'name'} => \%slot},
398: $cdom,$cname);
399: if ($ret eq 'ok') {
400: &Apache::lonnet::devalidate_slots_cache($cname,$cdom);
401: }
402: $result.="\n ".'Name: '.&HTML::Entities::encode($helper->{'VARS'}{'name'}).'</li>'.
403: "\n".'<li> Starts: '.&Apache::lonlocal::locallocaltime($slot{'starttime'}).'</li>'.
404: "\n".'<li> Ends: '.&Apache::lonlocal::locallocaltime($slot{'endtime'}).'</li>'.
405: "\n".'<li> Type: '.$slot{'type'}.'</li>';
406: my %labels =
407: map {($_->[0],$_->[1])} &Apache::slotrequest::csvupload_fields();
408: foreach my $which ('ip','description','maxspace','secret','symb',
409: 'allowedsections','allowedusers') {
410: if (exists($slot{$which})) {
411: $result.="\n".'<li> '.$labels{$which}.': '.
412: &HTML::Entities::encode($slot{$which}).'</li>';
413: }
414: }
415: if (exists($slot{'startreserve'})) {
416: $result.="\n".'<li> '.$labels{'startreserve'}.': '.
417: &Apache::lonlocal::locallocaltime($slot{'startreserve'}).'</li>';
418: }
419:
420: if (exists($slot{'endreserve'})) {
421: $result.="\n".'<li> '.$labels{'endreserve'}.': '.
422: &Apache::lonlocal::locallocaltime($slot{'endreserve'}).'</li>';
423: }
424:
425: if (exists($slot{'reservationmsg'})) {
426: my %options = &Apache::slotrequest::slot_reservationmsg_options();
427: $result.="\n".'<li> '.$labels{'reservationmsg'}.': '.
428: $options{$slot{'reservationmsg'}}.'</li>';
429: }
430:
431: if (exists($slot{'proctor'})) {
432: my $proctors = $slot{'proctor'};
433: $proctors =~ s/,/, /g;
434: $result.="\n".'<li> '.$labels{'proctor'}.': '.
435: &HTML::Entities::encode($proctors).'</li>';
436: }
437: if (exists($slot{'uniqueperiod'})) {
438: $result.=
439: "\n".'<li> '.$labels{'uniqueperiod'}.': '.
440: &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[0]).
441: ', '.
442: &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[1]).
443: '</li>';
444: }
445: return $result;
446: </finalcode>
447: <exitpage>/adm/slotrequest?command=showslots</exitpage>
448: </final>
449: </state>
450: </helper>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>