--- loncom/interface/slotrequest.pm 2009/03/27 11:39:07 1.92 +++ loncom/interface/slotrequest.pm 2010/05/27 04:44:33 1.107 @@ -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.92 2009/03/27 11:39:07 bisitz Exp $ +# $Id: slotrequest.pm,v 1.107 2010/05/27 04:44:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -707,7 +707,8 @@ $lt{'or'} STUFF if (!$inhibit_return_link) { - $r->print(&mt('or').'

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

'); + &return_link($r); } else { $r->print('

'); } @@ -846,7 +847,7 @@ sub show_choices { (keys(%slots))) { &Apache::lonxml::debug("Checking Slot $slot"); - next if (!&allowed_slot($slot,$slots{$slot},undef,\%slots, + next if (!&allowed_slot($slot,$slots{$slot},$symb,\%slots, $consumed_uniqueperiods)); push(@available,$slot); @@ -1025,6 +1026,7 @@ sub show_table { my ($r,$mgr)=@_; my ($cnum,$cdom)=&get_course(); + my $crstype=&Apache::loncommon::course_type($cdom.'_'.$cnum); my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum); if ( (keys(%slots))[0] =~ /^error: 2 /) { undef(%slots); @@ -1048,7 +1050,11 @@ sub show_table { } if (!keys(%slots)) { - $r->print('
'.&mt('No slots have been created in this course.').'
'); + 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.').'
'); + } return; } @@ -1084,6 +1090,10 @@ sub show_table { 'uniqueperiod' => 'Period of time slot is unique', 'scheduled' => 'Scheduled Students', 'proctor' => 'List of proctors'); + if ($crstype eq 'Community') { + $show_fields{'startreserve'} = &mt('Time members can start reserving'); + $show_fields{'scheduled'} = &mt('Scheduled Members'); + } my @show_order=('name','description','type','starttime','endtime', 'startreserve','secret','space','ip','symb', 'allowedsections','allowedusers','uniqueperiod', @@ -1351,9 +1361,13 @@ LOGLINK my $remove_all=&remove_link($slot,'remove all').'
'; - if ($ids ne '') { undef($delete); } - if ($slots{$slot}{'type'} ne 'schedulable_student' - || $ids eq '') { + if ($ids eq '') { + undef($remove_all); + } else { + undef($delete); + } + if ($slots{$slot}{'type'} ne 'schedulable_student') { + undef($showlog); undef($remove_all); } @@ -1424,21 +1438,23 @@ STUFF } sub manage_reservations { - my ($r,$type) = @_; + my ($r,$crstype) = @_; my $navmap = Apache::lonnavmaps::navmap->new(); $r->print('

' .&mt('Instructors may use a reservation system to place restrictions on when and where assignments can be worked on.') .'
' .&mt('One example is for management of laboratory space, which is only available at certain times, and has a limited number of seats.') - .'

' - .&mt('Your reservation status for any such assignments is listed below:') .'

' ); if (!defined($navmap)) { - $r->print('
'. - &mt('Unable to retrieve information about course contents'). - '
'); - &Apache::lonnet::logthis('Manage Reservations - could not create navmap object in '.lc($type).':'.$env{'request.course.id'}); + $r->print('
'); + if ($crstype eq 'Community') { + $r->print(&mt('Unable to retrieve information about community contents')); + } else { + $r->print(&mt('Unable to retrieve information about course contents')); + } + $r->print('
'); + &Apache::lonnet::logthis('Manage Reservations - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); return; } my (%parent,%shownparent,%container,%container_title,%contents); @@ -1446,7 +1462,11 @@ sub manage_reservations { my @backgrounds = ("LC_odd_row","LC_even_row"); my $numcolors = scalar(@backgrounds); my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif"); - $r->print(''."\n"); + my $slotheader = '

'. + &mt('Your reservation status for any such assignments is listed below:'). + '

'. + '
'."\n"; + my $shownheader = 0; my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); while (my $resource = $it->next()) { if ($resource == $it->BEGIN_MAP()) { @@ -1541,11 +1561,19 @@ sub manage_reservations { foreach my $item (@maprows) { $rownum ++; my $bgcolor = $backgrounds[$rownum % $numcolors]; + if (!$shownheader) { + $r->print($slotheader); + $shownheader = 1; + } $r->print(''.$item.''."\n"); } } $rownum ++; my $bgcolor = $backgrounds[$rownum % $numcolors]; + if (!$shownheader) { + $r->print($slotheader); + $shownheader = 1; + } $r->print('
'."\n"); for (my $i=0; $i<$depth; $i++) { $r->print(''); @@ -1580,11 +1608,19 @@ sub manage_reservations { } } } + if ($shownheader) { + $r->print('
'); + } if (!$reservable) { - $r->print(''.&mt('No course items currently require a reservation to gain access.').''); + $r->print(''); + if ($crstype eq 'Community') { + $r->print(&mt('No community items currently require a reservation to gain access.')); + } else { + $r->print(&mt('No course items currently require a reservation to gain access.')); + } + $r->print(''); } - $r->print(''. - '

'. + $r->print('

'. &mt('Reservation History').'

'); } @@ -1595,9 +1631,9 @@ sub show_map_row { $output .= ''; } if ($type eq 'page') { - $output .= ' '."\n"; + $output .= ' '."\n"; } else { - $output .= ' '."\n"; + $output .= ' '."\n"; } $output .= $title.' '."\n"; unshift (@{$maprows},$output); @@ -1615,12 +1651,21 @@ sub show_reservations { my $formname = 'slotlog'; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = &Apache::loncommon::course_type(); my %log=&Apache::lonnet::dump('nohist_'.$cdom.'_'.$cnum.'_slotlog',$udom,$uname); if ($env{'form.origin'} eq 'aboutme') { - $r->print('
'. - &mt('History of student-schedulable slots for: [_1]', - &Apache::loncommon::plainname($env{'form.uname'},$env{'form.udom'}, - 'firstname')).'
'); + $r->print('
'); + my $name = &Apache::loncommon::plainname($env{'form.uname'},$env{'form.udom'}, + 'firstname'); + if ($crstype eq 'Community') { + $r->print(&mt('History of member-reservable slots for: [_1]', + $name)); + } else { + $r->print(&mt('History of student-reservable slots for: [_1]', + $name)); + + } + $r->print('
'); } $r->print('
'); # set defaults @@ -1669,7 +1714,7 @@ sub show_reservations { } } my (%titles,%maptitles); - my %lt = &reservationlog_contexts(); + my %lt = &reservationlog_contexts($crstype); foreach my $id (sort { $log{$b}{'exe_time'}<=>$log{$a}{'exe_time'} } (keys(%log))) { next if (($log{$id}{'exe_time'} < $curr{'log_start_date'}) || ($log{$id}{'exe_time'} > $curr{'log_end_date'})); @@ -1731,7 +1776,7 @@ ENDSCRIPT } } else { $r->print('' - .&mt('There are no transactions to display') + .&mt('There are no transactions to display.') .'' ); } @@ -1748,6 +1793,33 @@ ENDSCRIPT sub show_reservations_log { my ($r) = @_; + my $badslot; + my $crstype = &Apache::loncommon::course_type(); + if ($env{'form.slotname'} eq '') { + $r->print('
'.&mt('No slot name provided').'
'); + $badslot = 1; + } else { + my %slot=&Apache::lonnet::get_slot($env{'form.slotname'}); + if (keys(%slot) == 0) { + $r->print('
'.&mt('Invalid slot name: [_1]',$env{'form.slotname'}).'
'); + $badslot = 1; + } elsif ($slot{type} ne 'schedulable_student') { + my $description = &get_description($env{'form.slotname'},\%slot); + $r->print('
'); + if ($crstype eq 'Community') { + $r->print(&mt('Reservation history unavailable for non-member-reservable slot: [_1].',$description)); + } else { + $r->print(&mt('Reservation history unavailable for non-student-reservable slot: [_1].',$description)); + } + $r->print('
'); + $badslot = 1; + } + } + if ($badslot) { + $r->print('

'. + &mt('Return to slot list').'

'); + return; + } my $formname = 'reservationslog'; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; @@ -1810,9 +1882,13 @@ sub show_reservations_log { my %slot=&Apache::lonnet::get_slot($env{'form.slotname'}); my $description = $slot{'description'}; - $r->print('
'. - &mt('Reservation changes for slot: [_1]',$description).'
'); - + $r->print(''); + if ($crstype eq 'Community') { + $r->print(&mt('Reservation changes for member-reservable slot: [_1]',$description)); + } else { + $r->print(&mt('Reservation changes for student-reservable slot: [_1]',$description)); + } + $r->print('
'); $r->print(&display_filter($formname,$cdom,$cnum,\%curr,$version,\@allsymbs)); my $showntablehdr = 0; my $tablehdr = &Apache::loncommon::start_data_table(). @@ -1830,7 +1906,7 @@ sub show_reservations_log { $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'}; } } - my %lt = &reservationlog_contexts(); + my %lt = &reservationlog_contexts($crstype); my (%titles,%maptitles); foreach my $id (sort { $log{$b}{'exe_time'}<=>$log{$a}{'exe_time'} } (keys(%log))) { next if (($log{$id}{'exe_time'} < $curr{'log_start_date'}) || @@ -1908,11 +1984,13 @@ function chgPage(caller) { ENDSCRIPT } } else { - $r->print(&mt('There are no records to display')); + $r->print(&mt('There are no records to display.')); } $r->print(''. ''. - '
'); + ''. + '

'. + &mt('Return to slot list').'

'); return; } @@ -1948,6 +2026,7 @@ sub get_resource_title { } sub reservationlog_contexts { + my ($crstype) = @_; my %lt = &Apache::lonlocal::texthash ( any => 'Any', user => 'By student', @@ -1957,6 +2036,10 @@ sub reservationlog_contexts { release => 'Dropped reservation', usermanage => 'By student', ); + if ($crstype eq 'Community') { + $lt{'user'} = &mt('By member'); + $lt{'usermanage'} = $lt{'user'}; + } return %lt; } @@ -1964,7 +2047,7 @@ sub display_filter { my ($formname,$cdom,$cnum,$curr,$version,$allsymbs) = @_; my $nolink = 1; my (%titles,%maptitles); - my $output = '
'. + my $output = '
'. ''.&mt('Changes/page:').'
'. &Apache::lonmeta::selectbox('show',$curr->{'show'},undef, (&mt('all'),5,10,20,50,100,1000,10000)). @@ -1977,7 +2060,8 @@ sub display_filter { &Apache::lonhtmlcommon::date_setter($formname,'log_end_date', $curr->{'log_end_date'},undef, undef,undef,undef,undef,undef,undef,$nolink); - my %lt = &reservationlog_contexts(); + my $crstype = &Apache::loncommon::course_type(); + my %lt = &reservationlog_contexts($crstype); $output .= '
'.&mt('Window during which changes occurred:'). '
'.&mt('After:'). ''.$startform.'
'.&mt('Before:').''. @@ -2025,36 +2109,41 @@ sub display_filter { } $output .= '  
'. - ''. - &mt('[_1]Note:[_2] Only changes made from servers running LON-CAPA 2.8.99.0 or later are displayed.'); + '

'. + &mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.' + ,'2.9.0'); if ($version) { - $output .= ' '.&mt('This server is version [_3].','','',$version); + $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version); } - $output .= '



'; + $output .= '



'; return $output; } sub upload_start { my ($r)=@_; - $r->print(&Apache::grades::checkforfile_js()); - my $result.=''."\n"; - $result.='
'."\n"; - $result.=' '. - &mt('Specify a file containing the slot definitions.'). - '
'."\n"; - my $upfile_select=&Apache::loncommon::upfile_select_html(); - my $ignore=&mt('Ignore First Line'); - $result.=< - -$upfile_select -
- - -ENDUPFORM - $result.='
'."\n"; - $result.='
'."\n"; - $r->print($result); + $r->print( + &Apache::grades::checkforfile_js() + .'

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

' + .'
' + .'' + .&Apache::lonhtmlcommon::start_pick_box() + .&Apache::lonhtmlcommon::row_title(&mt('File')) + .&Apache::loncommon::upfile_select_html() + .&Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title( + '') + .'' + .&Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::end_pick_box() + .'

' + .'' + .'

' + .'
' + ); } sub csvuploadmap_header { @@ -2076,8 +2165,8 @@ sub csvuploadmap_header { 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.
- - + + @@ -2101,7 +2190,7 @@ sub csvuploadmap_footer {
-
+
ENDPICK }