Annotation of loncom/html/adm/helper/newslot.helper, revision 1.33
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.28 raeburn 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>
1.24 raeburn 129: </p><p>Maximum number of students allowed in this slot:<br />
1.7 albertel 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>
1.25 felicia 141: </p><p>Period of time when this slot can only be uniquely chosen:<br /> Start:
1.7 albertel 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>
1.11 albertel 151: <message><br /> End: </message>
1.7 albertel 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>
1.15 albertel 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>
1.7 albertel 165: </date>
1.27 raeburn 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>
1.7 albertel 180: </condition>
181: <condition>
182: <clause>$helper->{'VARS'}{'type'} eq 'preassigned'</clause>
183: <exec>
184: delete($helper->{'VARS'}{'startreserve'});
1.28 raeburn 185: delete($helper->{'VARS'}{'endreserve'});
1.7 albertel 186: delete($helper->{'VARS'}{'maxspace'});
187: delete($helper->{'VARS'}{'startunique'});
188: delete($helper->{'VARS'}{'endunique'});
189: </exec>
190: </condition>
1.20 albertel 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:
1.1 albertel 205: <message>
1.11 albertel 206: </p><p>Secret word proctors use to checkin users:<br />
1.3 albertel 207: </message>
208: <string variable="secret" size="12">
209: <validator>
210: return undef;
211: </validator>
1.5 albertel 212: <defaultvalue>
213: return &{$helper->{DATA}{origslot}}('secret');
214: </defaultvalue>
1.3 albertel 215: </string>
216: <message>
1.11 albertel 217: </p><p>Slot is:
1.1 albertel 218: </message>
1.22 albertel 219: <helpicon file="Slot_ChoosingResources" />
1.21 rezaferr 220:
1.1 albertel 221: <choices variable="restricttosymb">
1.4 albertel 222: <choice nextstate="PROCTOR" computer='any'>usable for any resource.</choice>
1.32 raeburn 223: <choice nextstate="MAPSELECT" computer='map'>restricted to resources in specific folder(s)/composite page(s).</choice>
224: <choice nextstate="RESOURCESELECT" computer='resource'>restricted to specific resource(s).</choice>
1.5 albertel 225: <defaultvalue>
226: my $default=&{$helper->{DATA}{origslot}}('symb');
1.31 raeburn 227: if ($default) {
1.32 raeburn 228: my @symbs;
229: if ($default =~ /,/) {
230: @symbs = split(/\s*,\s*/,$default);
231: } else {
232: @symbs = ($default);
233: }
234: if (grep(/\.(page|sequence)$/,@symbs)) {
1.31 raeburn 235: return 'map';
236: } else {
237: return 'resource';
238: }
239: } else {
240: return 'any';
241: }
1.5 albertel 242: </defaultvalue>
1.1 albertel 243: </choices>
1.21 rezaferr 244:
1.2 albertel 245: <message>
1.13 albertel 246: </p><p>IP restrictions:<br />
1.2 albertel 247: </message>
248: <string variable="ip" size="30">
249: <validator>
250: return undef;
251: </validator>
1.5 albertel 252: <defaultvalue>
253: return &{$helper->{DATA}{origslot}}('ip');
254: </defaultvalue>
1.2 albertel 255: </string>
1.33 ! raeburn 256:
! 257: <message>
! 258: </p><p>Does each student need to use a unique IP address to access a resource with this slot?</p>
! 259: </message>
! 260: <choices variable="iptied">
! 261: <choice computer='no'>No. The student's IP address is not tied for later access to the same resource. </choice>
! 262: <choice computer='yes'>Yes. The IP address on a student's first access to a resource is tied for later access.</choice>
! 263: <choice computer='answer'>Yes. The IP address on a student's first access to a resource is tied for later access (including post-answer date).</choice>
! 264: <defaultvalue>
! 265: my $default=&{$helper->{DATA}{origslot}}('iptied');
! 266: if ($default eq 'yes') { return 'yes'; }
! 267: if ($default eq 'answer') { return 'answer'; }
! 268: return 'no';
! 269: </defaultvalue>
! 270: </choices>
1.11 albertel 271: <message> </p> </message>
1.1 albertel 272: </state>
1.13 albertel 273:
274:
1.1 albertel 275: <state name="RESOURCESELECT" title="Specify Optional Attributes">
1.13 albertel 276:
277: <nextstate>PROCTOR</nextstate>
278:
1.32 raeburn 279: <resource variable="symb" multichoice="1">
280: <filterfunc>return $res->is_map() || $res->is_problem()</filterfunc>
281: <choicefunc>return $res->is_problem()</choicefunc>
1.1 albertel 282: <valuefunc>return $res->symb()</valuefunc>
1.5 albertel 283: <defaultvalue>
1.32 raeburn 284: my @defaults;
285: my $default=&{$helper->{DATA}{origslot}}('symb');
286: if ($default) {
287: @defaults=(split(/\s*,\s*/,$default));
288: }
289: return @defaults;
1.5 albertel 290: </defaultvalue>
1.1 albertel 291: </resource>
292: </state>
1.13 albertel 293:
1.31 raeburn 294: <state name="MAPSELECT" title="Specify Optional Attributes">
295:
296: <nextstate>PROCTOR</nextstate>
297:
1.32 raeburn 298: <resource variable="symb" multichoice="1">
1.31 raeburn 299: <filterfunc>return $res->is_map()</filterfunc>
300: <valuefunc>return $res->symb()</valuefunc>
301: <defaultvalue>
1.32 raeburn 302: my @defaults;
303: my $default=&{$helper->{DATA}{origslot}}('symb');
304: if ($default) {
305: @defaults=(split(/\s*,\s*/,$default));
306: }
307: return @defaults;
1.31 raeburn 308: </defaultvalue>
309: </resource>
310: </state>
1.13 albertel 311:
1.22 albertel 312: <state name="PROCTOR" title="Specify Proctors"
313: help="Slot_SpecifyProctors">
1.13 albertel 314:
1.20 albertel 315: <skip>
316: <clause>$helper->{'VARS'}{'useproctor'} eq 'no'</clause>
317: <nextstate>RESTRICTUSER</nextstate>
318: </skip>
1.13 albertel 319:
1.20 albertel 320: <nextstate>RESTRICTUSER</nextstate>
1.18 albertel 321:
1.4 albertel 322: <student variable="proctor" multichoice="1" coursepersonnel="1"
1.23 albertel 323: activeonly="1" emptyallowed="0">
1.5 albertel 324: <defaultvalue>
325: my @defaults;
326: my $default=&{$helper->{DATA}{origslot}}('proctor');
327: if ($default) {
328: @defaults=(split(',',$default));
329: }
330: return @defaults;
331: </defaultvalue>
1.4 albertel 332: </student>
333: </state>
1.13 albertel 334:
335:
1.22 albertel 336: <state name="RESTRICTUSER" title="Restrict slot availability"
337: help="Slot_RestrictAvailibility">
1.20 albertel 338: <skip>
339: <clause>$helper->{'VARS'}{'type'} ne 'schedulable_student'</clause>
340: <nextstate>FINISH</nextstate>
341: </skip>
342:
1.13 albertel 343: <nextstate>FINISH</nextstate>
344: <message>
345: <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>
346: </message>
347:
348: <message>
1.32 raeburn 349: <h3>Select sections to limit slot availability to: </h3>
1.13 albertel 350: </message>
351: <section variable="allowedsections" multichoice="1" allowempty="1">
352: <defaultvalue>
1.32 raeburn 353: return join('|||',
1.13 albertel 354: split(',',&{$helper->{DATA}{origslot}}('allowedsections')));
355: </defaultvalue>
356: </section>
357: <message>
1.32 raeburn 358: <br /><h3>Select users to limit slot availability to: </h3>
1.13 albertel 359: </message>
360: <student variable="allowedusers" multichoice="1" coursepersonnel="1"
361: activeonly="1" emptyallowed="1">
362: <defaultvalue>
363: return split(',',&{$helper->{DATA}{origslot}}('allowedusers'));
364: </defaultvalue>
365: </student>
366: </state>
367:
368:
1.30 bisitz 369: <state name="FINISH" title="Creating/Modifying Slot">
1.11 albertel 370: <message> Created Slot </message>
1.3 albertel 371: <final>
372: <finalcode>
373: my $result;
374: if ($helper->{'STATE'} ne 'FINISH') { return; }
375: my %slot;
1.13 albertel 376:
1.3 albertel 377: foreach my $which ('type','starttime','endtime') {
378: $slot{$which} = $helper->{'VARS'}{$which};
379: }
1.13 albertel 380:
1.32 raeburn 381: foreach my $which ('ip','description','maxspace','secret') {
1.3 albertel 382: if ( $helper->{'VARS'}{$which} =~/\S/ ) {
383: $slot{$which} = $helper->{'VARS'}{$which};
384: }
385: }
1.13 albertel 386:
1.27 raeburn 387: if ($helper->{'VARS'}{'type'} eq 'schedulable_student') {
388: if (($helper->{'VARS'}{'reservationmsg'} eq 'only_student') ||
389: ($helper->{'VARS'}{'reservationmsg'} eq 'student_and_user_notes_screen')) {
390: $slot{'reservationmsg'} = $helper->{'VARS'}{'reservationmsg'};
391: } else {
392: $slot{'reservationmsg'} = 'none';
393: }
394: }
395:
1.32 raeburn 396: if (($helper->{'VARS'}{'restricttosymb'} =~ /^(map|resource)$/) &&
397: ($helper->{'VARS'}{'symb'} =~ /\S/)) {
398: my @symbs;
399: foreach my $symb (split(/\|\|\|/, $helper->{'VARS'}{'symb'})) {
400: push(@symbs,$symb);
401: }
402: # make sure the symbs are unique
403: my %symbs = map { ($_,1) } @symbs;
404: $slot{'symb'}=join(',',sort(keys(%symbs)));
405: }
406:
1.12 albertel 407: if ( $helper->{'VARS'}{'startreserve'} > 0) {
408: $slot{'startreserve'} = $helper->{'VARS'}{'startreserve'};
409: }
1.13 albertel 410:
1.28 raeburn 411: if ( $helper->{'VARS'}{'endreserve'} > 0) {
412: $slot{'endreserve'} = $helper->{'VARS'}{'endreserve'};
413: }
414:
1.3 albertel 415: if ( $helper->{'VARS'}{'startunique'} > 0 &&
416: $helper->{'VARS'}{'endunique'} > 0 ) {
417: $slot{'uniqueperiod'} = [$helper->{'VARS'}{'startunique'},
418: $helper->{'VARS'}{'endunique'}];
419: }
1.13 albertel 420:
1.33 ! raeburn 421: if ( $helper->{'VARS'}{'iptied'} =~ /^(yes|answer)$/ ) {
! 422: $slot{'iptied'} = lc($helper->{'VARS'}{'iptied'});
! 423: }
! 424:
1.19 albertel 425: if ( $helper->{'VARS'}{'useproctor'} eq 'yes'
426: && $helper->{'VARS'}{'proctor'} =~/\S/ ) {
1.4 albertel 427: my @names;
1.16 albertel 428: # just need the username/domain throw away the other data
429: # that <student> returns
1.4 albertel 430: foreach my $user (split(/\|\|\|/, $helper->{'VARS'}{'proctor'})) {
431: my ($uname,$udomain)=split(/:/,$user);
1.16 albertel 432: push(@names,"$uname:$udomain");
1.4 albertel 433: }
1.32 raeburn 434: # make sure the usernames are unique
1.8 albertel 435: my %proctors = map { ($_,1) } @names;
436: $slot{'proctor'}=join(',',sort(keys(%proctors)));
1.4 albertel 437: }
1.13 albertel 438:
1.14 albertel 439: if ( $helper->{'VARS'}{'allowedsections'} =~/\S/ ) {
440: $slot{'allowedsections'}=
441: join(',',sort(split(/\|\|\|/,
442: $helper->{'VARS'}{'allowedsections'})));
1.13 albertel 443: }
444:
1.14 albertel 445: if ( $helper->{'VARS'}{'allowedusers'} =~/\S/ ) {
1.13 albertel 446: my @names;
1.16 albertel 447: # just need the username/domain throw away the other data
448: # that <student> returns
1.14 albertel 449: foreach my $item (split(/\|\|\|/,
450: $helper->{'VARS'}{'allowedusers'})) {
1.13 albertel 451: my ($uname,$udomain)=split(/:/,$item);
452: push(@names,"$uname:$udomain");
453: }
454:
455: # make sure the choices are unique
1.14 albertel 456: my %users = map { ($_,1) } @names;
457: $slot{'allowedusers'}=join(',',sort(keys(%users)));
1.13 albertel 458: }
459:
1.3 albertel 460: my $cname = $env{'course.'.$env{'request.course.id'}.'.num'};
461: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
462:
463: my $ret = &Apache::lonnet::cput('slots',
464: {$helper->{'VARS'}{'name'} => \%slot},
465: $cdom,$cname);
1.29 raeburn 466: if ($ret eq 'ok') {
467: &Apache::lonnet::devalidate_slots_cache($cname,$cdom);
468: }
1.5 albertel 469: $result.="\n ".'Name: '.&HTML::Entities::encode($helper->{'VARS'}{'name'}).'</li>'.
1.4 albertel 470: "\n".'<li> Starts: '.&Apache::lonlocal::locallocaltime($slot{'starttime'}).'</li>'.
471: "\n".'<li> Ends: '.&Apache::lonlocal::locallocaltime($slot{'endtime'}).'</li>'.
1.3 albertel 472: "\n".'<li> Type: '.$slot{'type'}.'</li>';
473: my %labels =
474: map {($_->[0],$_->[1])} &Apache::slotrequest::csvupload_fields();
1.32 raeburn 475: foreach my $which ('ip','description','maxspace','secret',
1.13 albertel 476: 'allowedsections','allowedusers') {
1.3 albertel 477: if (exists($slot{$which})) {
478: $result.="\n".'<li> '.$labels{$which}.': '.
479: &HTML::Entities::encode($slot{$which}).'</li>';
480: }
481: }
1.33 ! raeburn 482: if (exists($slot{'iptied'})) {
! 483: $result.="\n".'<li> '.$labels{'iptied'}.': ';
! 484: if ($slot{'iptied'} eq 'yes') {
! 485: $result.=&Apache::lonlocal::mt('yes');
! 486: } elsif ($slot{'iptied'} eq 'answer') {
! 487: $result.=&Apache::lonlocal::mt('yes, including post-answer date');
! 488: }
! 489: $result.='</li>';
! 490: }
1.32 raeburn 491: if (exists($slot{'symb'})) {
492: $result.="\n".'<li> '.$labels{'symb'}.': ';
493: if ($slot{'symb'} =~ /,/) {
494: $result.='<ul>';
495: foreach my $symb (split(/\s*,\s*/,$slot{'symb'})) {
496: $result.='<li>'.&HTML::Entities::encode($symb).'</li>';
497: }
498: $result.='</ul>';
499: } else {
500: $result.=&HTML::Entities::encode($slot{'symb'});
501: }
502: $result.='</li>';
503: }
1.12 albertel 504: if (exists($slot{'startreserve'})) {
505: $result.="\n".'<li> '.$labels{'startreserve'}.': '.
506: &Apache::lonlocal::locallocaltime($slot{'startreserve'}).'</li>';
507: }
1.27 raeburn 508:
1.28 raeburn 509: if (exists($slot{'endreserve'})) {
510: $result.="\n".'<li> '.$labels{'endreserve'}.': '.
511: &Apache::lonlocal::locallocaltime($slot{'endreserve'}).'</li>';
512: }
513:
1.27 raeburn 514: if (exists($slot{'reservationmsg'})) {
515: my %options = &Apache::slotrequest::slot_reservationmsg_options();
516: $result.="\n".'<li> '.$labels{'reservationmsg'}.': '.
517: $options{$slot{'reservationmsg'}}.'</li>';
518: }
519:
1.6 albertel 520: if (exists($slot{'proctor'})) {
521: my $proctors = $slot{'proctor'};
522: $proctors =~ s/,/, /g;
523: $result.="\n".'<li> '.$labels{'proctor'}.': '.
524: &HTML::Entities::encode($proctors).'</li>';
525: }
1.3 albertel 526: if (exists($slot{'uniqueperiod'})) {
527: $result.=
528: "\n".'<li> '.$labels{'uniqueperiod'}.': '.
529: &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[0]).
530: ', '.
531: &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[1]).
532: '</li>';
533: }
534: return $result;
535: </finalcode>
1.4 albertel 536: <exitpage>/adm/slotrequest?command=showslots</exitpage>
1.3 albertel 537: </final>
1.1 albertel 538: </state>
539: </helper>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>