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