--- loncom/interface/slotrequest.pm 2011/12/18 17:15:03 1.111 +++ loncom/interface/slotrequest.pm 2014/02/28 19:20:06 1.120 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for requesting to have slots added to a students record # -# $Id: slotrequest.pm,v 1.111 2011/12/18 17:15:03 raeburn Exp $ +# $Id: slotrequest.pm,v 1.120 2014/02/28 19:20:06 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -137,7 +137,7 @@ sub check_for_reservation { return 'error: Unable to determine current status'; } my @got; - my @sorted_slots = &Apache::loncommon::sorted_slots(\@slots,\%slots); + my @sorted_slots = &Apache::loncommon::sorted_slots(\@slots,\%slots,'starttime'); foreach my $slot_name (@sorted_slots) { next if (!defined($slots{$slot_name}) || !ref($slots{$slot_name})); @@ -339,12 +339,12 @@ sub store_slot_parm { context => $env{'form.context'}, ); - &Apache::lonnet::instructor_log('slotreservationslog',\%storehash, - '',$env{'user.name'},$env{'user.domain'}, - $cnum,$cdom); - &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash, - 1,$env{'user.name'},$env{'user.domain'}, - $env{'user.name'},$env{'user.domain'}); + &Apache::lonnet::write_log('course','slotreservationslog',\%storehash, + '',$env{'user.name'},$env{'user.domain'}, + $cnum,$cdom); + &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash, + 1,$env{'user.name'},$env{'user.domain'}, + $env{'user.name'},$env{'user.domain'}); return; } @@ -538,10 +538,10 @@ sub release_reservation { action => 'release', context => $env{'form.context'}, ); - &Apache::lonnet::instructor_log('slotreservationslog',\%storehash, - 1,$uname,$udom,$cnum,$cdom); - &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash, - 1,$uname,$udom,$uname,$udom); + &Apache::lonnet::write_log('slotreservationslog',\%storehash, + 1,$uname,$udom,$cnum,$cdom); + &Apache::lonnet::write_log($cdom.'_'.$cnum.'_slotlog',\%storehash, + 1,$uname,$udom,$uname,$udom); } } @@ -696,7 +696,7 @@ STUFF } my %lt = &Apache::lonlocal::texthash( - 'request' => 'Availibility list', + 'request' => 'Availability list', 'try' => 'Try again?', 'or' => 'or', ); @@ -842,7 +842,7 @@ sub show_choices { my ($r,$symb,$formname)=@_; my ($cnum,$cdom)=&get_course(); - my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum); + my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); my $consumed_uniqueperiods = &get_consumed_uniqueperiods(\%slots); if (ref($consumed_uniqueperiods) eq 'HASH') { if (&Apache::lonnet::error(%$consumed_uniqueperiods)) { @@ -877,11 +877,12 @@ sub show_choices { push(@available,$slot); } if (!@available) { - $output = &mt('No available times.'); + $output = '
'.&mt('No available times.'); if ($env{'form.command'} ne 'manageresv') { $output .= ' '. &mt('Return to last resource').''; } + $output .= '
'; $r->print($output); return; } @@ -1058,7 +1059,8 @@ sub show_table { my $available; if ($mgr eq 'F') { # FIXME: This line should be deleted once Slots uses breadcrumbs - $r->print(&Apache::loncommon::help_open_topic('Slot About', 'Help on slots')); + $r->print('
'.&Apache::loncommon::help_open_topic( + 'Slot About', &mt('Help on slots'))); $r->print('
'); $r->print('
@@ -1074,11 +1076,11 @@ sub show_table { } if (!keys(%slots)) { - if ($crstype eq 'Community') { - $r->print('
'.&mt('No slots have been created in this community.').'
'); - } else { - $r->print('
'.&mt('No slots have been created in this course.').'
'); - } + $r->print( + '

' + .&mt('No slots have been created in this '.lc($crstype).'.') + .'

' + ); return; } @@ -1209,11 +1211,11 @@ sub show_table { - - + + - +
Deleted slots:'.&mt('Deleted slots:').'
@@ -1566,6 +1568,8 @@ sub manage_reservations { } elsif ($slot_status == $resource->RESERVABLE) { $msg=&mt('Reservation needed'); $get_choices = 1; + } elsif ($slot_status == $resource->RESERVABLE_LATER) { + $msg=&mt('Reservation needed: will be reservable later.'); } elsif ($slot_status == $resource->NOTRESERVABLE) { $msg=&mt('Reservation needed: none available.'); } elsif ($slot_status == $resource->UNKNOWN) { @@ -2046,7 +2050,7 @@ sub get_resource_title { $maptitle = $maptitles->{$mapurl}; } else { if ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) { - $maptitle=&mt('Main Course Documents'); + $maptitle=&mt('Main Content'); } else { $maptitle=&Apache::lonnet::gettitle($mapurl); } @@ -2197,7 +2201,7 @@ sub upload_start { my ($r)=@_; $r->print( &Apache::grades::checkforfile_js() - .'

'.&mt('Specify a file containing the slot definitions.').'

' + .'

'.&mt('Upload a file containing the slot definitions').'

' .'' .'' @@ -2231,16 +2235,40 @@ sub csvuploadmap_header { my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); my $ignore=&mt('Ignore First Line'); - my $help_field = &Apache::loncommon::help_open_topic('Slot SelectingField'); + my $buttontext = &mt('Reverse Association'); + + $r->print( + '' + .'

'.&mt('Identify fields in uploaded list').'

' + .'
' + .&Apache::loncommon::help_open_topic( + 'Slot About',&mt('Help on slots')) + .' '.&Apache::loncommon::help_open_topic( + 'Slot SelectingField',&mt('Help on selecting Fields')) + ."
\n" + .'

' + .&mt('Total number of records found in file: [_1]',''.$distotal.'') + ."

\n" + ); + if ($distotal == 0) { + $r->print('

'.&mt('None found').'

'); + } + $r->print( + '

' + .&mt('Enter as many fields as you can.').'
' + .&mt('The system will inform you and bring you back to this page,[_1]if the data selected is insufficient to create the slots.','
') + .'

' + ); + $r->print( + '
' + .'
'.&mt('Functions').'' + .'' + .' ' + .'

' + ); $r->print(< -

Identify fields $help_field

-Total number of records found in file: $distotal
-Enter as many fields as you can. The system will inform you and bring you back -to this page if the data selected is insufficient to create the slots.
- - @@ -2248,9 +2276,10 @@ to this page if the data selected is ins -
ENDPICK return ''; @@ -2261,7 +2290,6 @@ sub csvuploadmap_footer { my ($request,$i,$keyfields) =@_; my $buttontext = &mt('Create Slots'); $request->print(<
@@ -2270,7 +2298,7 @@ ENDPICK } sub csvupload_javascript_reverse_associate { - my $error1=&mt('You need to specify the name, starttime, endtime and a type'); + my $error1=&mt('You need to specify the name, start time, end time and a type.'); return(<rflush(); $countdone++; } + if ($countdone) { + &Apache::lonnet::devalidate_slots_cache($cname,$cdom); + } $r->print('

'.&mt('Created [quant,_1,slot]',$countdone)."\n".'

'); foreach my $error (@errors) { $r->print('

'.$error.'

'."\n"); @@ -2587,8 +2618,9 @@ sub handler { if (ref($brcrum) eq 'ARRAY') { push(@{$brcrum},{href=>"/adm/slotrequest?command=$env{'form.command'}",text=>$crumb_titles{$env{'form.command'}}}); } - } + } else { + $brcrum =[]; } &start_page($r,$title,$brcrum);