version 1.85, 2008/12/21 04:14:39
|
version 1.89, 2009/03/01 03:23:18
|
Line 239 sub check_for_conflict {
|
Line 239 sub check_for_conflict {
|
} |
} |
|
|
sub make_reservation { |
sub make_reservation { |
my ($slot_name,$slot,$symb)=@_; |
my ($slot_name,$slot,$symb,$cnum,$cdom)=@_; |
|
|
my ($cnum,$cdom)=&get_course(); |
|
|
|
my $value=&Apache::lonnet::EXT("resource.0.availablestudent",$symb, |
my $value=&Apache::lonnet::EXT("resource.0.availablestudent",$symb, |
$env{'user.domain'},$env{'user.name'}); |
$env{'user.domain'},$env{'user.name'}); |
Line 315 sub make_reservation {
|
Line 313 sub make_reservation {
|
if ($value) { |
if ($value) { |
$new_value=$value.':'.$new_value; |
$new_value=$value.':'.$new_value; |
} |
} |
my $result=&Apache::lonparmset::storeparm_by_symb($symb, |
&store_slot_parm($symb,$slot_name,$parm_level,$new_value,$cnum,$cdom); |
'0_availablestudent', |
|
$parm_level, $new_value, |
|
'string', |
|
$env{'user.name'}, |
|
$env{'user.domain'}); |
|
&Apache::lonxml::debug("hrrm $result"); |
|
return $wanted; |
return $wanted; |
} |
} |
|
|
Line 329 sub make_reservation {
|
Line 321 sub make_reservation {
|
return undef; |
return undef; |
} |
} |
|
|
|
sub store_slot_parm { |
|
my ($symb,$slot_name,$parm_level,$new_value,$cnum,$cdom) = @_; |
|
my $result=&Apache::lonparmset::storeparm_by_symb($symb, |
|
'0_availablestudent', |
|
$parm_level, $new_value, |
|
'string', |
|
$env{'user.name'}, |
|
$env{'user.domain'}); |
|
&Apache::lonxml::debug("hrrm $result"); |
|
my %storehash = ( |
|
symb => $symb, |
|
slot => $slot_name, |
|
action => 'reserve', |
|
context => $env{'form.context'}, |
|
); |
|
|
|
&Apache::lonnet::instructor_log('slotreservationslog',\%storehash, |
|
'',$env{'user.name'},$env{'user.domain'}, |
|
$cnum,$cdom); |
|
return; |
|
} |
|
|
sub remove_registration { |
sub remove_registration { |
my ($r) = @_; |
my ($r) = @_; |
if ($env{'form.entry'} ne 'remove all') { |
if ($env{'form.entry'} ne 'remove all') { |
Line 345 sub remove_registration {
|
Line 359 sub remove_registration {
|
return; |
return; |
} |
} |
if (!%consumed) { |
if (!%consumed) { |
$r->print("<p>".&mt('Slot <tt>[_1]</tt> has no reservations.', |
$r->print('<p>'.&mt('Slot [_1] has no reservations.', |
$slot_name)."</p>"); |
'<tt>'.$slot_name.'</tt>').'</p>'); |
return; |
return; |
} |
} |
|
|
Line 354 sub remove_registration {
|
Line 368 sub remove_registration {
|
my $names = join(' ',@names); |
my $names = join(' ',@names); |
|
|
my $msg = &mt('Remove all of [_1] from slot [_2]?',$names,$slot_name); |
my $msg = &mt('Remove all of [_1] from slot [_2]?',$names,$slot_name); |
&remove_registration_confirmation($r,$msg,['entry','slotname']); |
&remove_registration_confirmation($r,$msg,['entry','slotname','context']); |
} |
} |
|
|
sub remove_registration_user { |
sub remove_registration_user { |
Line 371 sub remove_registration_user {
|
Line 385 sub remove_registration_user {
|
$name,$slot_name,$title); |
$name,$slot_name,$title); |
|
|
&remove_registration_confirmation($r,$msg,['uname','udom','slotname', |
&remove_registration_confirmation($r,$msg,['uname','udom','slotname', |
'entry','symb']); |
'entry','symb','context']); |
} |
} |
|
|
sub remove_registration_confirmation { |
sub remove_registration_confirmation { |
Line 510 sub release_reservation {
|
Line 524 sub release_reservation {
|
if ( $consumed{$entry}->{'name'} eq ($uname.':'.$udom) ) { |
if ( $consumed{$entry}->{'name'} eq ($uname.':'.$udom) ) { |
&Apache::lonnet::del('slot_reservations',[$entry], |
&Apache::lonnet::del('slot_reservations',[$entry], |
$cdom,$cnum); |
$cdom,$cnum); |
|
my %storehash = ( |
|
symb => $symb, |
|
slot => $slot_name, |
|
action => 'release', |
|
context => $env{'form.context'}, |
|
); |
|
&Apache::lonnet::instructor_log('slotreservationslog',\%storehash, |
|
1,$uname,$udom,$cnum,$cdom); |
} |
} |
} |
} |
|
|
Line 530 sub release_reservation {
|
Line 552 sub release_reservation {
|
'0_availablestudent', |
'0_availablestudent', |
$parm_level, $new_param, |
$parm_level, $new_param, |
'string', $uname, $udom); |
'string', $uname, $udom); |
|
|
my $msg; |
my $msg; |
if ($mgr eq 'F') { |
if ($mgr eq 'F') { |
$msg = &mt('Released Reservation for user: [_1]',"$uname:$udom"); |
$msg = &mt('Released Reservation for user: [_1]',"$uname:$udom"); |
Line 557 sub delete_slot {
|
Line 578 sub delete_slot {
|
my $ret = &Apache::lonnet::cput('slots', {$slot_name => \%slot}, |
my $ret = &Apache::lonnet::cput('slots', {$slot_name => \%slot}, |
$cdom, $cnum); |
$cdom, $cnum); |
if ($ret eq 'ok') { |
if ($ret eq 'ok') { |
$r->print("<p>Slot <tt>$slot_name</tt> marked as deleted.</p>"); |
$r->print('<p>'.&mt('Slot [_1] marked as deleted.','<tt>'.$slot_name.'</tt>').'</p>'); |
} else { |
} else { |
$r->print("<p><span class=\"LC_error\"> An error ($ret) occurse when attempting to delete Slot <tt>$slot_name</tt>.</span></p>"); |
$r->print('<p><span class="LC_error">'.&mt('An error occurred when attempting to delete slot: [_1]','<tt>'.$slot_name.'</tt>')." ($ret)</span></p>"); |
} |
} |
} else { |
} else { |
if (%consumed) { |
if (%consumed) { |
$r->print("<p>Slot <tt>$slot_name</tt> has active reservations.</p>"); |
$r->print('<p>'.&mt('Slot [_1] has active reservations.','<tt>'.$slot_name.'</tt>').'</p>'); |
} else { |
} else { |
$r->print("<p>Slot <tt>$slot_name</tt> does not exist.</p>"); |
$r->print('<p>'.&mt('Slot [_1] does not exist.','<tt>'.$slot_name.'</tt>').'</p>'); |
} |
} |
} |
} |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
Line 597 sub get_slot {
|
Line 618 sub get_slot {
|
my $description1=&get_description($slot_name,\%slot); |
my $description1=&get_description($slot_name,\%slot); |
%slot=&Apache::lonnet::get_slot($env{'form.slotname'}); |
%slot=&Apache::lonnet::get_slot($env{'form.slotname'}); |
my $description2=&get_description($env{'form.slotname'},\%slot); |
my $description2=&get_description($env{'form.slotname'},\%slot); |
$r->print("<p>Already have a reservation: $description1</p>"); |
$r->print('<p>'.&mt('Already have a reservation: [_1].',$description1).'</p>'); |
if ($slot_name ne $env{'form.slotname'}) { |
if ($slot_name ne $env{'form.slotname'}) { |
$r->print(<<STUFF); |
$r->print(<<STUFF); |
<form method="post" action="/adm/slotrequest"> |
<form method="post" action="/adm/slotrequest"> |
Line 606 sub get_slot {
|
Line 627 sub get_slot {
|
<input type="hidden" name="releaseslot" value="$slot_name" /> |
<input type="hidden" name="releaseslot" value="$slot_name" /> |
<input type="hidden" name="command" value="change" /> |
<input type="hidden" name="command" value="change" /> |
STUFF |
STUFF |
$r->print("<p>You can either "); |
$r->print('<p>' |
$r->print(<<STUFF); |
.&mt('You can either [_1]Change[_2] your reservation from [_3] to [_4] or' |
<input type="submit" name="change" value="Change" /> |
,'<input type="submit" name="change" value="' |
STUFF |
,'" />' |
$r->print(' your reservation from <b>'.$description1.'</b> to <b>'. |
,'<b>'.$description1.'</b>' |
$description2. |
,'<b>'.$description2.'</b>') |
'</b> <br />or </p>'); |
.'<br /></p>' |
|
); |
&return_link($r); |
&return_link($r); |
$r->print(<<STUFF); |
$r->print(<<STUFF); |
</form> |
</form> |
Line 623 STUFF
|
Line 645 STUFF
|
return 0; |
return 0; |
} |
} |
|
|
|
my ($cnum,$cdom)=&get_course(); |
my $reserved=&make_reservation($env{'form.slotname'}, |
my $reserved=&make_reservation($env{'form.slotname'}, |
\%slot,$symb); |
\%slot,$symb,$cnum,$cdom); |
my $description=&get_description($env{'form.slotname'},\%slot); |
my $description=&get_description($env{'form.slotname'},\%slot); |
if (defined($reserved)) { |
if (defined($reserved)) { |
my $retvalue = 0; |
my $retvalue = 0; |
Line 633 STUFF
|
Line 656 STUFF
|
.&mt('An error occurred while attempting to make a reservation. ([_1])',$1) |
.&mt('An error occurred while attempting to make a reservation. ([_1])',$1) |
.'</span></p>'); |
.'</span></p>'); |
} elsif ($reserved > -1) { |
} elsif ($reserved > -1) { |
$r->print("<p>Success: $description</p>"); |
$r->print('<p>'.&mt('Success: [_1]',$description).'</p>'); |
$retvalue = 1; |
$retvalue = 1; |
} elsif ($reserved < 0) { |
} elsif ($reserved < 0) { |
$r->print("<p>Already reserved: $description</p>"); |
$r->print('<p>'.&mt('Already reserved: [_1]',$description).'</p>'); |
} |
} |
if (!$inhibit_return_link) { &return_link($r); } |
if (!$inhibit_return_link) { &return_link($r); } |
return 1; |
return 1; |
} |
} |
|
|
my %lt=('request'=>"Availibility list", |
my %lt=('request'=>"Availibility list", |
'try' =>'Try again'); |
'try' =>'Try again?', |
|
'or' => 'or'); |
%lt=&Apache::lonlocal::texthash(%lt); |
%lt=&Apache::lonlocal::texthash(%lt); |
|
|
my $extra_input; |
my $extra_input; |
Line 651 STUFF
|
Line 675 STUFF
|
$extra_input='<input type="hidden" name="releaseslot" value="'.$env{'form.slotname'}.'" />'; |
$extra_input='<input type="hidden" name="releaseslot" value="'.$env{'form.slotname'}.'" />'; |
} |
} |
|
|
|
$r->print('<p>'.&mt('[_1]Failed[_2] to reserve a slot for [_3].','<span class="LC_warning">','</span>',$description).'</p>'); |
$r->print(<<STUFF); |
$r->print(<<STUFF); |
<p> <span class="LC_warning">Failed</span> to reserve a spot for $description. </p> |
|
<p> |
<p> |
<form method="post" action="/adm/slotrequest"> |
<form method="post" action="/adm/slotrequest"> |
<input type="submit" name="Try Again" value="$lt{'try'}" /> |
<input type="submit" name="Try Again" value="$lt{'try'}" /> |
Line 661 STUFF
|
Line 685 STUFF
|
<input type="hidden" name="command" value="$env{'form.command'}" /> |
<input type="hidden" name="command" value="$env{'form.command'}" /> |
$extra_input |
$extra_input |
</form> |
</form> |
? |
|
</p> |
</p> |
<p> |
<p> |
or |
$lt{'or'} |
<form method="post" action="/adm/slotrequest"> |
<form method="post" action="/adm/slotrequest"> |
<input type="hidden" name="symb" value="$env{'form.symb'}" /> |
<input type="hidden" name="symb" value="$env{'form.symb'}" /> |
<input type="submit" name="requestattempt" value="$lt{'request'}" /> |
<input type="submit" name="requestattempt" value="$lt{'request'}" /> |
</form> |
</form> |
</p> |
|
or |
|
STUFF |
STUFF |
|
|
if (!$inhibit_return_link) { &return_link($r); } |
if (!$inhibit_return_link) { |
|
$r->print(&mt('or').'</p>').&return_link($r); |
|
} else { |
|
$r->print('</p>'); |
|
} |
return 0; |
return 0; |
} |
} |
|
|
Line 756 sub allowed_slot {
|
Line 781 sub allowed_slot {
|
$consumed_uniqueperiods); |
$consumed_uniqueperiods); |
if ($conflict =~ /^error: /) { |
if ($conflict =~ /^error: /) { |
return 0; |
return 0; |
} else { |
} elsif ($conflict ne '') { |
if ($slots->{$conflict}{'starttime'} < time) { |
if ($slots->{$conflict}{'starttime'} < time) { |
return 0; |
return 0; |
} |
} |
Line 847 sub show_choices {
|
Line 872 sub show_choices {
|
<input type="hidden" name="symb" value="$escsymb" /> |
<input type="hidden" name="symb" value="$escsymb" /> |
<input type="hidden" name="slotname" value="$slot" /> |
<input type="hidden" name="slotname" value="$slot" /> |
<input type="hidden" name="command" value="$command" /> |
<input type="hidden" name="command" value="$command" /> |
|
<input type="hidden" name="context" value="user" /> |
</form> |
</form> |
STUFF |
STUFF |
} |
} |
Line 859 STUFF
|
Line 885 STUFF
|
} |
} |
|
|
if (!$available) { |
if (!$available) { |
$r->print('<tr><td>No available times. <a href="/adm/flip?postdata=return:">'. |
$r->print('<tr><td>'.&mt('No available times.'). |
|
' <a href="/adm/flip?postdata=return:">'. |
&mt('Return to last resource').'</a></td></tr>'); |
&mt('Return to last resource').'</a></td></tr>'); |
} |
} |
$r->print('</table>'); |
$r->print('</table>'); |
Line 946 sub remove_link {
|
Line 973 sub remove_link {
|
$symb = &escape($symb); |
$symb = &escape($symb); |
|
|
return <<"END_LINK"; |
return <<"END_LINK"; |
<a href="/adm/slotrequest?command=remove_registration&slotname=$slotname&entry=$entry&uname=$uname&udom=$udom&symb=$symb" |
<a href="/adm/slotrequest?command=remove_registration&slotname=$slotname&entry=$entry&uname=$uname&udom=$udom&symb=$symb&context=manage" |
>($remove)</a> |
>($remove)</a> |
END_LINK |
END_LINK |
|
|
Line 1346 sub upload_start {
|
Line 1373 sub upload_start {
|
$result.=' <b>'. |
$result.=' <b>'. |
&mt('Specify a file containing the slot definitions.'). |
&mt('Specify a file containing the slot definitions.'). |
'</b></td></tr>'."\n"; |
'</b></td></tr>'."\n"; |
$result.='<tr bgcolor=#ffffe6><td>'."\n"; |
$result.='<tr bgcolor="#ffffe6"><td>'."\n"; |
my $upfile_select=&Apache::loncommon::upfile_select_html(); |
my $upfile_select=&Apache::loncommon::upfile_select_html(); |
my $ignore=&mt('Ignore First Line'); |
my $ignore=&mt('Ignore First Line'); |
$result.=<<ENDUPFORM; |
$result.=<<ENDUPFORM; |
Line 1401 ENDPICK
|
Line 1428 ENDPICK
|
|
|
sub csvuploadmap_footer { |
sub csvuploadmap_footer { |
my ($request,$i,$keyfields) =@_; |
my ($request,$i,$keyfields) =@_; |
|
my $buttontext = &mt('Create Slots'); |
$request->print(<<ENDPICK); |
$request->print(<<ENDPICK); |
</table> |
</table> |
<input type="hidden" name="nfields" value="$i" /> |
<input type="hidden" name="nfields" value="$i" /> |
<input type="hidden" name="keyfields" value="$keyfields" /> |
<input type="hidden" name="keyfields" value="$keyfields" /> |
<input type="button" onClick="javascript:verify(this.form)" value="Create Slots" /><br /> |
<input type="button" onClick="javascript:verify(this.form)" value="$buttontext" /><br /> |
</form> |
</form> |
ENDPICK |
ENDPICK |
} |
} |
Line 1522 sub csv_upload_assign {
|
Line 1550 sub csv_upload_assign {
|
my @slotdata = &Apache::loncommon::upfile_record_sep(); |
my @slotdata = &Apache::loncommon::upfile_record_sep(); |
if ($env{'form.noFirstLine'}) { shift(@slotdata); } |
if ($env{'form.noFirstLine'}) { shift(@slotdata); } |
my %fields=&Apache::grades::get_fields(); |
my %fields=&Apache::grades::get_fields(); |
$r->print('<h3>Creating Slots</h3>'); |
$r->print('<h3>'.&mt('Creating Slots').'</h3>'); |
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $countdone=0; |
my $countdone=0; |
Line 1609 sub csv_upload_assign {
|
Line 1637 sub csv_upload_assign {
|
$r->rflush(); |
$r->rflush(); |
$countdone++; |
$countdone++; |
} |
} |
$r->print("<p>Created $countdone slots\n</p>"); |
$r->print('<p>'.&mt('Created [quant,_1,slot]',$countdone)."\n".'</p>'); |
foreach my $error (@errors) { |
foreach my $error (@errors) { |
$r->print("<p><span class=\"LC_warning\">$error</span></p>\n"); |
$r->print('<p><span class="LC_warning">'.$error.'</span></p>'."\n"); |
} |
} |
&show_table($r,$mgr); |
&show_table($r,$mgr); |
return ''; |
return ''; |
Line 1699 sub handler {
|
Line 1727 sub handler {
|
&release_slot($r,$symb,$env{'form.releaseslot'}); |
&release_slot($r,$symb,$env{'form.releaseslot'}); |
} |
} |
} else { |
} else { |
$r->print("<p>Unknown command: ".$env{'form.command'}."</p>"); |
$r->print('<p>'.&mt('Unknown command: [_1]',$env{'form.command'}).'</p>'); |
} |
} |
} |
} |
&end_page($r); |
&end_page($r); |