Annotation of loncom/html/adm/helper/newslot.helper, revision 1.4

1.1       albertel    1: <helper title="Slot Creation" requiredpriv="mgq">
                      2:   <state name="START" title="Specify Required Attributes">
                      3:     <message nextstate="OPTIONAL">
                      4:       <message_text>
                      5:           Name: <br />&nbsp;&nbsp;&nbsp;
                      6:       </message_text>
                      7:     </message>
1.3       albertel    8:     <string variable="name" size="30">
1.1       albertel    9:       <validator>
                     10:           if ($val=~/^\s*$/) { return 'Must specify a name'; }
                     11:           if ($val=~/\s$/) { return 'Must not contain spaces'; }
                     12:           return undef;
                     13:       </validator>
                     14:     </string>
                     15:     <message>
                     16:       <message_text><br />Start time:<br />&nbsp;&nbsp;&nbsp;</message_text>
                     17:     </message>
                     18:     <date variable="starttime" hoursminutes="1"></date>
                     19:     <message>
                     20:       <message_text><br />End time:<br />&nbsp;&nbsp;&nbsp;</message_text>
                     21:     </message>
                     22:     <date variable="endtime" hoursminutes="1"></date>
                     23:     <message>
                     24:       <message_text><br />Type:</message_text>
                     25:     </message>
                     26:     <choices variable="type">
                     27:       <choice computer='preassigned'>Instructor asssignable.</choice>
                     28:       <choice computer='student_schedulable'>Student selectable.</choice>
                     29:       <defaultvalue>
                     30:          return 'preassigned';
                     31:       </defaultvalue>
                     32:     </choices>
                     33:   </state>
                     34: 
                     35:   <state name="OPTIONAL" title="Specify Optional Attributes">
                     36:     <message>
                     37:       <message_text>
1.2       albertel   38:           <p>Description:<br />&nbsp;&nbsp;&nbsp;
1.1       albertel   39:       </message_text>
                     40:     </message>
1.2       albertel   41:     <string variable="description" size="60"></string>
1.1       albertel   42:     <message>
                     43:       <message_text>
1.2       albertel   44:           </p><p>Time students can start reserving:<br />&nbsp;&nbsp;&nbsp;
1.1       albertel   45:       </message_text>
                     46:     </message>
1.2       albertel   47:     <date variable="startreserve" hoursminutes="1" anytime="1">
                     48: 	<defaultvalue>'anytime'</defaultvalue>
                     49:     </date>
1.1       albertel   50:     <message>
                     51:       <message_text>
                     52:           </p><p>Maxium number of students allowed in this slot:<br />&nbsp;&nbsp;&nbsp;
                     53:       </message_text>
                     54:     </message>
                     55:     <string variable="maxspace" size="4">
                     56:       <validator>
                     57:           if ($val ne '' && $val=~/\D/) { return 'Must be numeric.'; }
                     58:           return undef;
                     59:       </validator>
                     60:     </string>
                     61:     <message>
                     62:       <message_text>
1.3       albertel   63:           </p><p>Secret word proctors use to checkin users:<br />&nbsp;&nbsp;&nbsp;
                     64:       </message_text>
                     65:     </message>
                     66:     <string variable="secret" size="12">
                     67:       <validator>
                     68:           return undef;
                     69:       </validator>
                     70:     </string>
                     71:     <message>
                     72:       <message_text>
1.1       albertel   73:           </p><p>Period of time in which this slot is can only be uniquely chosen:<br />&nbsp;&nbsp;&nbsp;Start:
                     74:       </message_text>
                     75:     </message>
1.2       albertel   76:     <date variable="startunique" hoursminutes="1" anytime="1">
                     77: 	<defaultvalue>'anytime'</defaultvalue>
                     78:     </date>
1.1       albertel   79:     <message><message_text><br />&nbsp;&nbsp;&nbsp;End: </message_text></message>
1.2       albertel   80:     <date variable="endunique" hoursminutes="1" anytime="1">
                     81: 	<defaultvalue>'anytime'</defaultvalue>
                     82:     </date>
1.1       albertel   83:     <message>
                     84:       <message_text>
                     85:           </p><p>Slot is:
                     86:       </message_text>
                     87:     </message>
                     88:     <choices variable="restricttosymb">
1.4     ! albertel   89:       <choice nextstate="PROCTOR" computer='any'>usable for any resource.</choice>
1.1       albertel   90:       <choice nextstate="RESOURCESELECT" computer='resource'>restricted to a specific resource.</choice>
                     91:       <defaultvalue>'any'</defaultvalue>
                     92:     </choices>
1.2       albertel   93:     <message>
                     94:       <message_text> 
                     95: 	</p><p>IP restrictions:<br />&nbsp;&nbsp;&nbsp;
                     96:       </message_text>
                     97:     </message>
                     98:     <string variable="ip" size="30">
                     99:       <validator>
                    100:           return undef;
                    101:       </validator>
                    102:     </string>
1.1       albertel  103:     <message> <message_text> </p> </message_text> </message>
                    104:   </state>
                    105:   <state name="RESOURCESELECT" title="Specify Optional Attributes">
                    106:     <resource variable="symb">
                    107:       <filterfunc>return $res->is_problem()</filterfunc>
                    108:       <valuefunc>return $res->symb()</valuefunc>
1.4     ! albertel  109:       <nextstate>PROCTOR</nextstate>
1.1       albertel  110:     </resource>    
                    111:   </state>
1.4     ! albertel  112:   <state name="PROCTOR" title="Specify Proctors">
        !           113:     <student variable="proctor" multichoice="1" coursepersonnel="1"
        !           114:              nextstate="FINISH" activeonly="1" emptyallowed="1">
        !           115:     </student>
        !           116:   </state>
1.3       albertel  117:   <state name="FINISH" title="Creating/Modfying Slot">
                    118: 	    <message> <message_text> Created Slot </message_text> </message>	
                    119:     <final>
                    120:       <finalcode>
                    121:         my $result;
                    122: 	if ($helper->{'STATE'} ne 'FINISH') { return; }
                    123: 	my %slot;
                    124: 	foreach my $which ('type','starttime','endtime') {
                    125: 	    $slot{$which} = $helper->{'VARS'}{$which};
                    126: 	}
1.4     ! albertel  127: 	foreach my $which ('ip','description','maxspace',
1.3       albertel  128: 			   'secret','symb') {
                    129: 	    if ( $helper->{'VARS'}{$which} =~/\S/ ) {
                    130: 		$slot{$which} = $helper->{'VARS'}{$which};
                    131: 	    }
                    132: 	}
                    133: 	if ( $helper->{'VARS'}{'startunique'} > 0 &&
                    134: 	     $helper->{'VARS'}{'endunique'} > 0 ) {
                    135: 	    $slot{'uniqueperiod'} = [$helper->{'VARS'}{'startunique'},
                    136: 				     $helper->{'VARS'}{'endunique'}];
                    137: 	}
1.4     ! albertel  138:         if ( $helper->{'VARS'}{'proctor'} =~/\S/ ) {
        !           139: 	    my @names;
        !           140: 	    foreach my $user (split(/\|\|\|/, $helper->{'VARS'}{'proctor'})) {
        !           141: 		my ($uname,$udomain)=split(/:/,$user);
        !           142: 		push(@names,"$uname\@$udomain");
        !           143: 	    }
        !           144: 	    $slot{'proctor'}=join(',',@names);
        !           145: 	}
1.3       albertel  146:         my $cname = $env{'course.'.$env{'request.course.id'}.'.num'};
                    147:         my $cdom  = $env{'course.'.$env{'request.course.id'}.'.domain'};
                    148: 
                    149:         my $ret = &Apache::lonnet::cput('slots',
                    150: 					{$helper->{'VARS'}{'name'} => \%slot},
                    151: 					$cdom,$cname);
1.4     ! albertel  152:         $result.="\n$ret ".'Name: '.&HTML::Entities::encode($helper->{'VARS'}{'name'}).'</li>'.
        !           153:     "\n".'<li> Starts: '.&Apache::lonlocal::locallocaltime($slot{'starttime'}).'</li>'.
        !           154:                  "\n".'<li> Ends: '.&Apache::lonlocal::locallocaltime($slot{'endtime'}).'</li>'.
1.3       albertel  155:                  "\n".'<li> Type: '.$slot{'type'}.'</li>';
                    156:         my %labels =
                    157:              map {($_->[0],$_->[1])} &Apache::slotrequest::csvupload_fields();
                    158:         foreach my $which ('ip','proctor','description','maxspace',
                    159: 			   'secret','symb') {
                    160: 	    if (exists($slot{$which})) {
                    161: 		$result.="\n".'<li> '.$labels{$which}.': '.
                    162: 		    &HTML::Entities::encode($slot{$which}).'</li>';
                    163: 	    }
                    164: 	}
                    165:         if (exists($slot{'uniqueperiod'})) {
                    166: 	    $result.=
                    167:                  "\n".'<li> '.$labels{'uniqueperiod'}.': '.
                    168: 		 &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[0]).
                    169: 		 ', '.
                    170: 		 &Apache::lonlocal::locallocaltime($slot{'uniqueperiod'}[1]).
                    171: 		 '</li>';
                    172: 	}
                    173:         return $result;
                    174:       </finalcode>
1.4     ! albertel  175:       <exitpage>/adm/slotrequest?command=showslots</exitpage>
1.3       albertel  176:     </final>
1.1       albertel  177:   </state>
                    178: </helper>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>