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