Annotation of loncom/html/adm/helper/newslot.helper, revision 1.5
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.1 albertel 81: <message>
82: <message_text>
1.2 albertel 83: </p><p>Time students can start reserving:<br />
1.1 albertel 84: </message_text>
85: </message>
1.2 albertel 86: <date variable="startreserve" hoursminutes="1" anytime="1">
1.5 ! albertel 87: <defaultvalue>
! 88: return &{$helper->{DATA}{origslot}}('startreserve','anytime');
! 89: </defaultvalue>
1.2 albertel 90: </date>
1.1 albertel 91: <message>
92: <message_text>
93: </p><p>Maxium number of students allowed in this slot:<br />
94: </message_text>
95: </message>
96: <string variable="maxspace" size="4">
97: <validator>
98: if ($val ne '' && $val=~/\D/) { return 'Must be numeric.'; }
99: return undef;
100: </validator>
1.5 ! albertel 101: <defaultvalue>
! 102: return &{$helper->{DATA}{origslot}}('maxspace');
! 103: </defaultvalue>
1.1 albertel 104: </string>
105: <message>
106: <message_text>
1.3 albertel 107: </p><p>Secret word proctors use to checkin users:<br />
108: </message_text>
109: </message>
110: <string variable="secret" size="12">
111: <validator>
112: return undef;
113: </validator>
1.5 ! albertel 114: <defaultvalue>
! 115: return &{$helper->{DATA}{origslot}}('secret');
! 116: </defaultvalue>
1.3 albertel 117: </string>
118: <message>
119: <message_text>
1.1 albertel 120: </p><p>Period of time in which this slot is can only be uniquely chosen:<br /> Start:
121: </message_text>
122: </message>
1.2 albertel 123: <date variable="startunique" hoursminutes="1" anytime="1">
1.5 ! albertel 124: <defaultvalue>
! 125: my $default=&{$helper->{DATA}{origslot}}('uniqueperiod','anytime');
! 126: if ($default eq 'anytime') { return 'anytime' };
! 127: if (ref($default)) { return $default->[0]; }
! 128: return 'anytime';
! 129: </defaultvalue>
1.2 albertel 130: </date>
1.1 albertel 131: <message><message_text><br /> End: </message_text></message>
1.2 albertel 132: <date variable="endunique" hoursminutes="1" anytime="1">
1.5 ! albertel 133: <defaultvalue>
! 134: my $default=&{$helper->{DATA}{origslot}}('uniqueperiod','anytime');
! 135: if ($default eq 'anytime') { return 'anytime' };
! 136: if (ref($default)) { return $default->[1]; }
! 137: return 'anytime';
! 138: </defaultvalue>
1.2 albertel 139: </date>
1.1 albertel 140: <message>
141: <message_text>
142: </p><p>Slot is:
143: </message_text>
144: </message>
145: <choices variable="restricttosymb">
1.4 albertel 146: <choice nextstate="PROCTOR" computer='any'>usable for any resource.</choice>
1.1 albertel 147: <choice nextstate="RESOURCESELECT" computer='resource'>restricted to a specific resource.</choice>
1.5 ! albertel 148: <defaultvalue>
! 149: my $default=&{$helper->{DATA}{origslot}}('symb');
! 150: if ($default) { return 'resource'; }
! 151: return 'any';
! 152: </defaultvalue>
1.1 albertel 153: </choices>
1.2 albertel 154: <message>
155: <message_text>
156: </p><p>IP restrictions:<br />
157: </message_text>
158: </message>
159: <string variable="ip" size="30">
160: <validator>
161: return undef;
162: </validator>
1.5 ! albertel 163: <defaultvalue>
! 164: return &{$helper->{DATA}{origslot}}('ip');
! 165: </defaultvalue>
1.2 albertel 166: </string>
1.1 albertel 167: <message> <message_text> </p> </message_text> </message>
168: </state>
169: <state name="RESOURCESELECT" title="Specify Optional Attributes">
170: <resource variable="symb">
171: <filterfunc>return $res->is_problem()</filterfunc>
172: <valuefunc>return $res->symb()</valuefunc>
1.4 albertel 173: <nextstate>PROCTOR</nextstate>
1.5 ! albertel 174: <defaultvalue>
! 175: return &{$helper->{DATA}{origslot}}('symb');
! 176: </defaultvalue>
1.1 albertel 177: </resource>
178: </state>
1.4 albertel 179: <state name="PROCTOR" title="Specify Proctors">
180: <student variable="proctor" multichoice="1" coursepersonnel="1"
181: nextstate="FINISH" activeonly="1" emptyallowed="1">
1.5 ! albertel 182: <defaultvalue>
! 183: my @defaults;
! 184: my $default=&{$helper->{DATA}{origslot}}('proctor');
! 185: if ($default) {
! 186: $default=~ tr/@/:/;
! 187: @defaults=(split(',',$default));
! 188: }
! 189: return @defaults;
! 190: </defaultvalue>
1.4 albertel 191: </student>
192: </state>
1.3 albertel 193: <state name="FINISH" title="Creating/Modfying Slot">
194: <message> <message_text> Created Slot </message_text> </message>
195: <final>
196: <finalcode>
197: my $result;
198: if ($helper->{'STATE'} ne 'FINISH') { return; }
199: my %slot;
200: foreach my $which ('type','starttime','endtime') {
201: $slot{$which} = $helper->{'VARS'}{$which};
202: }
1.4 albertel 203: foreach my $which ('ip','description','maxspace',
1.3 albertel 204: 'secret','symb') {
205: if ( $helper->{'VARS'}{$which} =~/\S/ ) {
206: $slot{$which} = $helper->{'VARS'}{$which};
207: }
208: }
209: if ( $helper->{'VARS'}{'startunique'} > 0 &&
210: $helper->{'VARS'}{'endunique'} > 0 ) {
211: $slot{'uniqueperiod'} = [$helper->{'VARS'}{'startunique'},
212: $helper->{'VARS'}{'endunique'}];
213: }
1.4 albertel 214: if ( $helper->{'VARS'}{'proctor'} =~/\S/ ) {
215: my @names;
216: foreach my $user (split(/\|\|\|/, $helper->{'VARS'}{'proctor'})) {
217: my ($uname,$udomain)=split(/:/,$user);
218: push(@names,"$uname\@$udomain");
219: }
220: $slot{'proctor'}=join(',',@names);
221: }
1.3 albertel 222: my $cname = $env{'course.'.$env{'request.course.id'}.'.num'};
223: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
224:
225: my $ret = &Apache::lonnet::cput('slots',
226: {$helper->{'VARS'}{'name'} => \%slot},
227: $cdom,$cname);
1.5 ! albertel 228: $result.="\n ".'Name: '.&HTML::Entities::encode($helper->{'VARS'}{'name'}).'</li>'.
1.4 albertel 229: "\n".'<li> Starts: '.&Apache::lonlocal::locallocaltime($slot{'starttime'}).'</li>'.
230: "\n".'<li> Ends: '.&Apache::lonlocal::locallocaltime($slot{'endtime'}).'</li>'.
1.3 albertel 231: "\n".'<li> Type: '.$slot{'type'}.'</li>';
232: my %labels =
233: map {($_->[0],$_->[1])} &Apache::slotrequest::csvupload_fields();
234: foreach my $which ('ip','proctor','description','maxspace',
235: 'secret','symb') {
236: if (exists($slot{$which})) {
237: $result.="\n".'<li> '.$labels{$which}.': '.
238: &HTML::Entities::encode($slot{$which}).'</li>';
239: }
240: }
241: if (exists($slot{'uniqueperiod'})) {
242: $result.=
243: "\n".'<li> '.$labels{'uniqueperiod'}.': '.
244: &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[0]).
245: ', '.
246: &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[1]).
247: '</li>';
248: }
249: return $result;
250: </finalcode>
1.4 albertel 251: <exitpage>/adm/slotrequest?command=showslots</exitpage>
1.3 albertel 252: </final>
1.1 albertel 253: </state>
254: </helper>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>