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