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