--- loncom/interface/lonrequestcourse.pm 2009/09/08 13:20:27 1.32 +++ loncom/interface/lonrequestcourse.pm 2009/09/11 12:53:10 1.35 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.32 2009/09/08 13:20:27 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.35 2009/09/11 12:53:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -631,7 +631,7 @@ sub course_types { official => 'Official course', unofficial => 'Unofficial course', community => 'Community', - ); + ); return (\@types,\%typename); } @@ -724,7 +724,9 @@ END END - $r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb.'<div>'. + $r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb. + '<p>'.&mt('Request creation of a new course, or review your pending course requests.').'</p>'. + '<div>'. &Apache::lonhtmlcommon::start_pick_box(). &Apache::lonhtmlcommon::row_title(&mt('Course Domain')). '<form name="domforcourse" method="post" action="/adm/requestcourse">'. @@ -755,7 +757,7 @@ END if ($type eq 'official') { $selected = ' selected="selected"'; } - $r->print('<option value="'.$type.'"'.$selected.'>'.$typename->{$type}. + $r->print('<option value="'.$type.'"'.$selected.'>'.&mt($typename->{$type}). '</option>'."\n"); } } @@ -1134,7 +1136,7 @@ sub print_request_form { next => 'Next', ); $crstype = $env{'form.crstype'}; - $r->print('<form name="'.$formname.'" method="post" action="/adm/requestcourse">'); + $r->print('<br /><form name="'.$formname.'" method="post" action="/adm/requestcourse">'); my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk, @disallowed); if ($crstype eq 'official') { @@ -1171,7 +1173,9 @@ sub print_request_form { $codepicker = &coursecode_form($dom,'instcode',\@codetitles, \%cat_titles,\%cat_order); if ($codepicker) { - $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker. + $r->print(&mt('Specify the course to be created.'). + '<div>'.&Apache::lonhtmlcommon::start_pick_box(). + $codepicker. &Apache::lonhtmlcommon::end_pick_box().'</div>'); } else { $next = $states->{$action}[$page+2]; @@ -1411,7 +1415,7 @@ sub get_excluded_elements { sub print_enrollment_menu { my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order, $invalidcrosslist) =@_; - my ($sections,$autoenroll,$access_dates,$output); + my ($sections,$autoenroll,$access_dates,$output,$hasauto); my $starttime = time; my $endtime = time+(6*30*24*60*60); # 6 months from now, approx @@ -1430,7 +1434,8 @@ sub print_enrollment_menu { $section_form = &inst_section_selector($dom,$instcode); if ($section_form) { $sections = &Apache::lonhtmlcommon::row_headline(). - '<h3>'.&mt('Sections for auto-enrollment').'</h3>'. + '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Sections'). + ' '.&mt('Sections for auto-enrollment').'</h3>'. &Apache::lonhtmlcommon::row_closure(1). $section_form; } @@ -1457,26 +1462,29 @@ sub print_enrollment_menu { &Apache::lonhtmlcommon::row_closure(1). $crosslist_form; } + $hasauto = 1; $autoenroll = - &Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')). + &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic('Course_Request_Autoadd').' '.&mt('Add registered students automatically')). '<span class="LC_nobreak"><label>'. '<input type="radio" name="autoadds" value="1">'. &mt('Yes').'</label>'.(' 'x3).'<label>'. '<input type="radio" name="autoadds" value="0" checked="checked">'. &mt('No').'</label></span>'. &Apache::lonhtmlcommon::row_closure(1). - &Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')). + &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic('Course_Request_Autodrop').' '.&mt('Drop unregistered students automatically')). '<span class="LC_nobreak"><label>'. '<input type="radio" name="autodrops" value="1">'. &mt('Yes').'</label>'.(' 'x3).'<label>'. '<input type="radio" name="autodrops" value="0" checked="checked">'. &mt('No').'</label></span>'. &Apache::lonhtmlcommon::row_closure(1). - &date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles); + &date_setting_table($starttime,$endtime,$formname,'enroll', + $hasauto,%enrolltitles); } } my $access_dates = - &date_setting_table($starttime,$endtime,$formname,'access',%accesstitles); + &date_setting_table($starttime,$endtime,$formname,'access',$hasauto, + %accesstitles); $output .= &Apache::lonhtmlcommon::start_pick_box(); if ($sections) { $output .= $sections; @@ -1530,7 +1538,8 @@ sub inst_section_selector { '<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '. 'value="'.$sectotal.'" /></th>'. '<th>'.&mt('Institutional Section').'</th>'. - '<th>'.&mt('LON-CAPA section').'</th>'. + '<th>'.&Apache::loncommon::help_open_topic('Course_Request_LCSection'). + ' '.&mt('LON-CAPA section').'</th>'. &Apache::loncommon::end_data_table_row(); for (my $i=0; $i<@sections; $i++) { my $colflag = $i%2; @@ -1559,7 +1568,7 @@ sub inst_section_selector { } sub date_setting_table { - my ($starttime,$endtime,$formname,$prefix,%datetitles) = @_; + my ($starttime,$endtime,$formname,$prefix,$hasauto,%datetitles) = @_; my ($perpetual,$table); my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start', $starttime,'','','',1,'','','',1); @@ -1572,11 +1581,27 @@ sub date_setting_table { &mt('No end date').'</label></span>'; $closure = '1'; } - $table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}). - $startform. + + my %help_item = ( + access => { + start => 'Course_Request_Access_Start', + end => 'Course_Request_Access_End', + }, + enroll => { + start => 'Course_Request_Enroll_Start', + end => 'Course_Request_Enroll_End', + }, + ); + if ($hasauto) { + $help_item{'access'}{'start'} = 'Course_Request_RegAccess_Start'; + $help_item{'access'}{'end'} = 'Course_Request_RegAccess_End'; + } + + $table = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'start'}). + ' '.$datetitles{'start'}).$startform. &Apache::lonhtmlcommon::row_closure(1). - &Apache::lonhtmlcommon::row_title($datetitles{'end'}). - $endform.$perpetual. + &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'end'}). + ' '.$datetitles{'end'}).$endform.$perpetual. &Apache::lonhtmlcommon::row_closure($closure); return $table; } @@ -1645,7 +1670,7 @@ sub print_personnel_menu { ); $lt{'unofficial'} = $lt{'official'}; $output .= &Apache::lonhtmlcommon::row_headline(). - '<h3>'.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>'; + '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>'; } for (my $i=0; $i<$persontotal; $i++) { my @linkargs = map { 'person_'.$i.'_'.$_ } (@items); @@ -1687,8 +1712,9 @@ sub print_personnel_menu { '<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'firstname'}.'</td>'."\n". '<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'lastname'}.'</td>'."\n". '<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{'emailaddr'}.'</td></tr>'."\n". - '<tr><td align="center" valign="top">'.&mt('Role').'<br />'.$roleselector.'</td>'."\n". - '<td'.$seccolspan.' align="center" valign="top">'.&mt('Section(s)').'<br />'.$sectionselector.'</td>'."\n". + '<tr><td align="center" valign="top">'.&Apache::loncommon::help_open_topic('Course_Roles').' '.&mt('Role').'<br />'.$roleselector.'</td>'."\n". + '<td'.$seccolspan.' align="center" valign="top">'. + &Apache::loncommon::help_open_topic('Course_Request_Rolesection').' '.&mt('LON-CAPA Section(s)').'<br />'.$sectionselector.'</td>'."\n". '</tr></table>'.&Apache::lonhtmlcommon::row_closure(); } $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')). @@ -1696,7 +1722,8 @@ sub print_personnel_menu { '<input name="addperson" type="checkbox" value="'.$persontotal.'"'. ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}. "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1). - &Apache::lonhtmlcommon::end_pick_box().'</div>'; + &Apache::lonhtmlcommon::end_pick_box().'</div>'. + '<p>'.&mt('You may also add users later, once the course has been created, by using the "Manage course users" link, accessible from the "Main Menu".').'</p>'; return $output; } @@ -1721,14 +1748,8 @@ sub print_request_status { my ($dom) = @_; my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'}, $env{'user.name'},'^status:'.$dom); - my ($output,$formname,%queue_by_date,%typenames); - if ($env{'form.crstype'} eq 'any') { - %typenames = &Apache::lonlocal::texthash ( - official => 'Official course', - unofficial => 'Unofficial course', - community => 'Community', - ); - } + my ($output,$formname,%queue_by_date); + my ($types,$typenames) = &course_types(); foreach my $key (keys(%statusinfo)) { if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) { (undef,my($cdom,$cnum)) = split(':',$key); @@ -1799,7 +1820,10 @@ sub print_request_status { '<td>'.&unescape($desc).'</td>'. '<td>'.$cdom.'</td>'; if ($env{'form.crstype'} eq 'any') { - my $typename = $typenames{$type}; + my $typename; + if (ref($typenames) eq 'HASH') { + $typename = &mt($typenames->{$type}); + } if ($typename eq '') { $typename = &mt('Unknown type'); } @@ -1952,7 +1976,7 @@ sub print_review { $crstypename = $env{'form.crstype'}; if (ref($typename) eq 'HASH') { unless ($typename->{$env{'form.crstype'}} eq '') { - $crstypename = $typename->{$env{'form.crstype'}}; + $crstypename = &mt($typename->{$env{'form.crstype'}}); } } my $category = 'Course'; @@ -2241,7 +2265,7 @@ ENDJS } my $output .= $js_validate."\n".'<div>'.&Apache::lonhtmlcommon::start_pick_box(). &Apache::lonhtmlcommon::row_headline(). - '<h3>'.$title.'</h3>'. + '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Description').' '.$title.'</h3>'. &Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::row_title(&mt('Description')). '<input type="text" size="40" name="cdescr" />'; @@ -2255,7 +2279,7 @@ ENDJS $output .= $home_server_pick. &Apache::lonhtmlcommon::row_closure(). &Apache::lonhtmlcommon::row_headline(). - '<h3>'.&mt('Clone content and settings from an existing course?').'</h3>'. + '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Clone').' '.&mt('Clone content and settings from an existing course?').'</h3>'. &Apache::lonhtmlcommon::row_closure(1). &clone_form($dom,$formname,$crstype). &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n"; @@ -2268,14 +2292,14 @@ sub clone_form { if ($crstype eq 'community') { $type = 'Community'; } - my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom'). + my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom').' '. &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type); my %lt = &clone_text(); my $output .= &Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'. '<input type="text" size="25" name="clonecrs" value="" />'. - '</label>'.&Apache::lonhtmlcommon::row_closure(1).'<label>'. - &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'</label>'. + '</label>'.&Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'<label>'. $cloneform.'</label>'.&Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'. '<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}. @@ -2307,6 +2331,10 @@ sub coursecode_form { instcode => 'Course Category', crosslist => 'Cross Listed Course', ); + my %helpitem = ( + instcode => 'Course_Request_Category', + crosslist => 'Course_Request_Crosslist', + ); if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') && (ref($cat_order))) { my ($sel,$instsec,$lcsec); @@ -2322,7 +2350,7 @@ sub coursecode_form { my $lastitem = pop(@{$codetitles}); my $lastinput = '<input type="text" size="5" name="'.$sel.'_'. $lastitem.'" />'; if (@{$codetitles} > 0) { - $output = &Apache::lonhtmlcommon::row_title($rowtitle{$context}). + $output = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($helpitem{$context}).' '.$rowtitle{$context}). '<table><tr>'; if ($context eq 'crosslist') { $output .= '<td>'.&mt('Include?').'<br />'. @@ -2826,85 +2854,90 @@ sub update_requestors_roles { my $owner = $env{'user.name'}.':'.$env{'user.domain'}; if (ref($details) eq 'HASH') { if (ref($details->{'personnel'}) eq 'HASH') { - if (ref($details->{'personnel'}{$owner}) eq 'HASH') { - my @roles; - if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') { - @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}}); - unless (grep(/^cc$/,@roles)) { - push(@roles,'cc'); - } - } else { - @roles = ('cc'); + unless (ref($details->{'personnel'}{$owner}) eq 'HASH') { + $details->{'personnel'}{$owner} = { + 'roles' => ['cc'], + 'cc' => { 'usec' => [] }, + }; + } + my @roles; + if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') { + @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}}); + unless (grep(/^cc$/,@roles)) { + push(@roles,'cc'); } - foreach my $role (@roles) { - my $start = $now; - my $end = '0'; - if ($role eq 'st') { - if ($details->{'accessstart'} ne '') { - $start = $details->{'accessstart'}; - } - if ($details->{'accessend'} ne '') { - $end = $details->{'accessend'}; - } - } - my @usecs; - if ($role ne 'cc') { - if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') { - @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}}; - } - } - if ($role eq 'st') { - if (@usecs > 1) { - my $firstsec = $usecs[0]; - @usecs = ($firstsec); - } - } - if (@usecs == 0) { - push(@usecs,''); - } - foreach my $usec (@usecs) { - my (%userroles,%newrole,%newgroups,$spec,$area); - my $area = '/'.$dom.'/'.$cnum; - my $spec = $role.'.'.$area; - if ($usec ne '') { - $spec .= '/'.$usec; - $area .= '/'.$usec; - } + } else { + @roles = ('cc'); + } + foreach my $role (@roles) { + my $start = $now; + my $end = '0'; + if ($role eq 'st') { + if ($details->{'accessstart'} ne '') { + $start = $details->{'accessstart'}; + } + if ($details->{'accessend'} ne '') { + $end = $details->{'accessend'}; + } + } + my @usecs; + if ($role ne 'cc') { + if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') { + @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}}; + } + } + if ($role eq 'st') { + if (@usecs > 1) { + my $firstsec = $usecs[0]; + @usecs = ($firstsec); + } + } + if (@usecs == 0) { + push(@usecs,''); + } + foreach my $usec (@usecs) { + my (%userroles,%newrole,%newgroups,$spec,$area); + my $area = '/'.$dom.'/'.$cnum; + my $spec = $role.'.'.$area; + if ($usec ne '') { + $spec .= '/'.$usec; + $area .= '/'.$usec; + } + if ($role =~ /^cr\//) { + &Apache::lonnet::custom_roleprivs(\%newrole,$role,$dom, + $cnum,$spec,$area); + } else { + &Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom, + $spec,$cnum,$area); + } + &Apache::lonnet::set_userprivs(\%userroles,\%newrole, + \%newgroups); + $userroles{'user.role.'.$spec} = $start.'.'.$end; + &Apache::lonnet::appenv(\%userroles,[$role,'cm']); + if (($end == 0) || ($end > $now)) { + my $showrole = $role; if ($role =~ /^cr\//) { - &Apache::lonnet::custom_roleprivs(\%newrole,$role,$dom, - $cnum,$spec,$area); - } else { - &Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom, - $spec,$cnum,$area); + $showrole = &Apache::lonnet::plaintext($role,$crstype); + } elsif (ref($longroles) eq 'HASH') { + if ($longroles->{$role} ne '') { + $showrole = $longroles->{$role}; + } } - &Apache::lonnet::set_userprivs(\%userroles,\%newrole, - \%newgroups); - $userroles{'user.role.'.$spec} = $start.'.'.$end; - &Apache::lonnet::appenv(\%userroles,[$role,'cm']); - if (($end == 0) || ($end > $now)) { - my $showrole = $role; - if ($role =~ /^cr\//) { - $showrole = &Apache::lonnet::plaintext($role,$crstype); - } elsif (ref($longroles) eq 'HASH') { - if ($longroles->{$role} ne '') { - $showrole = $longroles->{$role}; - } + if ($start <= $now) { + $active .= '<li><a href="/adm/roles?selectrole=1&'. + $spec.'=1">'.$showrole; + if ($usec ne '') { + $active .= ' - '.&mt('section:').' '.$usec; } - if ($start <= $now) { - $active .= '<li><a href="/adm/roles?selectrole=1&'. $spec.'=1">'.$showrole; - if ($usec ne '') { - $active .= ' - '.&mt('section:').' '.$usec; - } - $active .= '</a></li>'; - $numactive ++; - } else { - $future .= '<li>'.$showrole; - if ($usec ne '') { - $future .= ' - '.&mt('section:').' '.$usec; - } - $future .= '</li>'; - $numfuture ++; + $active .= '</a></li>'; + $numactive ++; + } else { + $future .= '<li>'.$showrole; + if ($usec ne '') { + $future .= ' - '.&mt('section:').' '.$usec; } + $future .= '</li>'; + $numfuture ++; } } }