Annotation of loncom/html/adm/helper/newslot.helper, revision 1.7
1.1 albertel 1: <helper title="Slot Creation" requiredpriv="mgq">
2: <state name="START" title="Specify Required Attributes">
1.5 albertel 3: <exec>
4: if (!exists($helper->{'VARS'}{'name'}) ||
5: $helper->{'VARS'}{'name'} !~ /\S/) {
6: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
7: if (exists($env{'form.name'}) ||
8: $env{'form.name'} =~ /\S/) {
9: $helper->{'VARS'}{'name'}=$env{'form.name'};
10: }
11: }
12: $helper->{DATA}{origslot} = sub {
13: my ($which,$default)=@_;
14: if (!exists($helper->{'VARS'}{'name'}) ||
15: $helper->{'VARS'}{'name'} !~ /\S/) {
16: return $default;
17: }
18: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
19: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
20: my $name=$helper->{'VARS'}{'name'};
21: my %slot=&Apache::lonnet::get('slots', [$name], $cdom, $cnum);
22: if (!ref($slot{$name})) { return $default; }
23: if (!exists($slot{$name}{$which})) { return $default; }
24: return $slot{$name}{$which};
25: }
26: </exec>
1.1 albertel 27: <message nextstate="OPTIONAL">
28: <message_text>
29: Name: <br />
30: </message_text>
31: </message>
1.3 albertel 32: <string variable="name" size="30">
1.1 albertel 33: <validator>
34: if ($val=~/^\s*$/) { return 'Must specify a name'; }
35: if ($val=~/\s$/) { return 'Must not contain spaces'; }
36: return undef;
37: </validator>
1.5 albertel 38: <defaultvalue>
39: return $helper->{'VARS'}{'name'};
40: </defaultvalue>
1.1 albertel 41: </string>
42: <message>
43: <message_text><br />Start time:<br /> </message_text>
44: </message>
1.5 albertel 45: <date variable="starttime" hoursminutes="1">
46: <defaultvalue>
47: return &{$helper->{DATA}{origslot}}('starttime');
48: </defaultvalue>
49: </date>
1.1 albertel 50: <message>
51: <message_text><br />End time:<br /> </message_text>
52: </message>
1.5 albertel 53: <date variable="endtime" hoursminutes="1">
54: <defaultvalue>
55: return &{$helper->{DATA}{origslot}}('endtime');
56: </defaultvalue>
57: </date>
1.1 albertel 58: <message>
59: <message_text><br />Type:</message_text>
60: </message>
61: <choices variable="type">
62: <choice computer='preassigned'>Instructor asssignable.</choice>
1.5 albertel 63: <choice computer='schedulable_student'>Student selectable.</choice>
1.1 albertel 64: <defaultvalue>
1.5 albertel 65: return &{$helper->{DATA}{origslot}}('type','preassigned');
1.1 albertel 66: </defaultvalue>
67: </choices>
68: </state>
69:
70: <state name="OPTIONAL" title="Specify Optional Attributes">
71: <message>
72: <message_text>
1.2 albertel 73: <p>Description:<br />
1.1 albertel 74: </message_text>
75: </message>
1.5 albertel 76: <string variable="description" size="60">
77: <defaultvalue>
78: return &{$helper->{DATA}{origslot}}('description');
79: </defaultvalue>
80: </string>
1.7 ! albertel 81: <condition>
! 82: <clause>$helper->{'VARS'}{'type'} eq 'schedulable_student'</clause>
! 83: <message>
! 84: <message_text>
! 85: </p><p>Time students can start reserving:<br />
! 86: </message_text>
! 87: </message>
! 88: <date variable="startreserve" hoursminutes="1" anytime="1">
! 89: <defaultvalue>
! 90: return &{$helper->{DATA}{origslot}}('startreserve','anytime');
! 91: </defaultvalue>
! 92: </date>
! 93: <message>
! 94: <message_text>
! 95: </p><p>Maxium number of students allowed in this slot:<br />
! 96: </message_text>
! 97: </message>
! 98: <string variable="maxspace" size="4">
! 99: <validator>
! 100: if ($val ne '' && $val=~/\D/) { return 'Must be numeric.'; }
! 101: return undef;
! 102: </validator>
! 103: <defaultvalue>
! 104: return &{$helper->{DATA}{origslot}}('maxspace');
! 105: </defaultvalue>
! 106: </string>
! 107: <message>
! 108: <message_text>
! 109: </p><p>Period of time in which this slot is can only be uniquely chosen:<br /> Start:
! 110: </message_text>
! 111: </message>
! 112: <date variable="startunique" hoursminutes="1" anytime="1">
! 113: <defaultvalue>
! 114: my $default=&{$helper->{DATA}{origslot}}('uniqueperiod','anytime');
! 115: if ($default eq 'anytime') { return 'anytime' };
! 116: if (ref($default)) { return $default->[0]; }
! 117: return 'anytime';
! 118: </defaultvalue>
! 119: </date>
! 120: <message><message_text><br /> End: </message_text></message>
! 121: <date variable="endunique" hoursminutes="1" anytime="1">
! 122: <defaultvalue>
! 123: my $default=&{$helper->{DATA}{origslot}}('uniqueperiod','anytime');
! 124: if ($default eq 'anytime') { return 'anytime' };
! 125: if (ref($default)) { return $default->[1]; }
! 126: return 'anytime';
! 127: </defaultvalue>
! 128: </date>
! 129: </condition>
! 130: <condition>
! 131: <clause>$helper->{'VARS'}{'type'} eq 'preassigned'</clause>
! 132: <exec>
! 133: delete($helper->{'VARS'}{'startreserve'});
! 134: delete($helper->{'VARS'}{'maxspace'});
! 135: delete($helper->{'VARS'}{'startunique'});
! 136: delete($helper->{'VARS'}{'endunique'});
! 137: </exec>
! 138: </condition>
1.1 albertel 139: <message>
140: <message_text>
1.3 albertel 141: </p><p>Secret word proctors use to checkin users:<br />
142: </message_text>
143: </message>
144: <string variable="secret" size="12">
145: <validator>
146: return undef;
147: </validator>
1.5 albertel 148: <defaultvalue>
149: return &{$helper->{DATA}{origslot}}('secret');
150: </defaultvalue>
1.3 albertel 151: </string>
152: <message>
153: <message_text>
1.1 albertel 154: </p><p>Slot is:
155: </message_text>
156: </message>
157: <choices variable="restricttosymb">
1.4 albertel 158: <choice nextstate="PROCTOR" computer='any'>usable for any resource.</choice>
1.1 albertel 159: <choice nextstate="RESOURCESELECT" computer='resource'>restricted to a specific resource.</choice>
1.5 albertel 160: <defaultvalue>
161: my $default=&{$helper->{DATA}{origslot}}('symb');
162: if ($default) { return 'resource'; }
163: return 'any';
164: </defaultvalue>
1.1 albertel 165: </choices>
1.2 albertel 166: <message>
167: <message_text>
168: </p><p>IP restrictions:<br />
169: </message_text>
170: </message>
171: <string variable="ip" size="30">
172: <validator>
173: return undef;
174: </validator>
1.5 albertel 175: <defaultvalue>
176: return &{$helper->{DATA}{origslot}}('ip');
177: </defaultvalue>
1.2 albertel 178: </string>
1.1 albertel 179: <message> <message_text> </p> </message_text> </message>
180: </state>
181: <state name="RESOURCESELECT" title="Specify Optional Attributes">
182: <resource variable="symb">
183: <filterfunc>return $res->is_problem()</filterfunc>
184: <valuefunc>return $res->symb()</valuefunc>
1.4 albertel 185: <nextstate>PROCTOR</nextstate>
1.5 albertel 186: <defaultvalue>
187: return &{$helper->{DATA}{origslot}}('symb');
188: </defaultvalue>
1.1 albertel 189: </resource>
190: </state>
1.4 albertel 191: <state name="PROCTOR" title="Specify Proctors">
192: <student variable="proctor" multichoice="1" coursepersonnel="1"
193: nextstate="FINISH" activeonly="1" emptyallowed="1">
1.5 albertel 194: <defaultvalue>
195: my @defaults;
196: my $default=&{$helper->{DATA}{origslot}}('proctor');
197: if ($default) {
198: $default=~ tr/@/:/;
199: @defaults=(split(',',$default));
200: }
201: return @defaults;
202: </defaultvalue>
1.4 albertel 203: </student>
204: </state>
1.3 albertel 205: <state name="FINISH" title="Creating/Modfying Slot">
206: <message> <message_text> Created Slot </message_text> </message>
207: <final>
208: <finalcode>
209: my $result;
210: if ($helper->{'STATE'} ne 'FINISH') { return; }
211: my %slot;
212: foreach my $which ('type','starttime','endtime') {
213: $slot{$which} = $helper->{'VARS'}{$which};
214: }
1.4 albertel 215: foreach my $which ('ip','description','maxspace',
1.3 albertel 216: 'secret','symb') {
217: if ( $helper->{'VARS'}{$which} =~/\S/ ) {
218: $slot{$which} = $helper->{'VARS'}{$which};
219: }
220: }
221: if ( $helper->{'VARS'}{'startunique'} > 0 &&
222: $helper->{'VARS'}{'endunique'} > 0 ) {
223: $slot{'uniqueperiod'} = [$helper->{'VARS'}{'startunique'},
224: $helper->{'VARS'}{'endunique'}];
225: }
1.4 albertel 226: if ( $helper->{'VARS'}{'proctor'} =~/\S/ ) {
227: my @names;
228: foreach my $user (split(/\|\|\|/, $helper->{'VARS'}{'proctor'})) {
229: my ($uname,$udomain)=split(/:/,$user);
230: push(@names,"$uname\@$udomain");
231: }
232: $slot{'proctor'}=join(',',@names);
233: }
1.3 albertel 234: my $cname = $env{'course.'.$env{'request.course.id'}.'.num'};
235: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
236:
237: my $ret = &Apache::lonnet::cput('slots',
238: {$helper->{'VARS'}{'name'} => \%slot},
239: $cdom,$cname);
1.5 albertel 240: $result.="\n ".'Name: '.&HTML::Entities::encode($helper->{'VARS'}{'name'}).'</li>'.
1.4 albertel 241: "\n".'<li> Starts: '.&Apache::lonlocal::locallocaltime($slot{'starttime'}).'</li>'.
242: "\n".'<li> Ends: '.&Apache::lonlocal::locallocaltime($slot{'endtime'}).'</li>'.
1.3 albertel 243: "\n".'<li> Type: '.$slot{'type'}.'</li>';
244: my %labels =
245: map {($_->[0],$_->[1])} &Apache::slotrequest::csvupload_fields();
1.6 albertel 246: foreach my $which ('ip','description','maxspace','secret','symb') {
1.3 albertel 247: if (exists($slot{$which})) {
248: $result.="\n".'<li> '.$labels{$which}.': '.
249: &HTML::Entities::encode($slot{$which}).'</li>';
250: }
251: }
1.6 albertel 252: if (exists($slot{'proctor'})) {
253: my $proctors = $slot{'proctor'};
254: $proctors =~ s/,/, /g;
255: $result.="\n".'<li> '.$labels{'proctor'}.': '.
256: &HTML::Entities::encode($proctors).'</li>';
257: }
1.3 albertel 258: if (exists($slot{'uniqueperiod'})) {
259: $result.=
260: "\n".'<li> '.$labels{'uniqueperiod'}.': '.
261: &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[0]).
262: ', '.
263: &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[1]).
264: '</li>';
265: }
266: return $result;
267: </finalcode>
1.4 albertel 268: <exitpage>/adm/slotrequest?command=showslots</exitpage>
1.3 albertel 269: </final>
1.1 albertel 270: </state>
271: </helper>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>