version 1.26, 2009/08/27 00:06:18
|
version 1.30, 2009/09/07 06:30:49
|
Line 44 described at http://www.lon-capa.org.
|
Line 44 described at http://www.lon-capa.org.
|
|
|
=item handler() |
=item handler() |
|
|
|
=item get_breadcrumbs() |
|
|
=item header() |
=item header() |
|
|
=item form_elements() |
=item form_elements() |
Line 58 described at http://www.lon-capa.org.
|
Line 60 described at http://www.lon-capa.org.
|
|
|
=item request_administration() |
=item request_administration() |
|
|
|
=item close_popup_form() |
|
|
|
=item get_instcode() |
|
|
=item print_request_form() |
=item print_request_form() |
|
|
=item print_enrollment_menu() |
=item print_enrollment_menu() |
|
|
|
=item show_invalid_crosslists() |
|
|
=item inst_section_selector() |
=item inst_section_selector() |
|
|
=item date_setting_table() |
=item date_setting_table() |
Line 94 described at http://www.lon-capa.org.
|
Line 102 described at http://www.lon-capa.org.
|
|
|
=item check_autolimit() |
=item check_autolimit() |
|
|
=item build_batchcreatehash() |
|
|
|
=item retrieve_settings() |
=item retrieve_settings() |
|
|
=item get_request_settings() |
=item get_request_settings() |
|
|
|
=item extract_instcode() |
|
|
|
=item generate_date_items() |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 112 use Apache::lonnet;
|
Line 122 use Apache::lonnet;
|
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::loncoursequeueadmin; |
use Apache::loncoursequeueadmin; |
|
use Apache::lonuserutils; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
sub handler { |
sub handler { |
Line 122 sub handler {
|
Line 133 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','showdom','cnum']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['action','showdom','cnum','state']); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
my $dom = &get_course_dom(); |
my $dom = &get_course_dom(); |
my $action = $env{'form.action'}; |
my $action = $env{'form.action'}; |
my $state = $env{'form.state'}; |
my $state = $env{'form.state'}; |
my %stored; |
my (%states,%stored); |
my $jscript; |
my ($jscript,$uname,$udom,$result,$warning); |
my ($uname,$udom,$result,$warning); |
|
|
$states{'display'} = ['details']; |
|
$states{'view'} = ['pick_request','details','cancel','removal']; |
|
$states{'log'} = ['filter','display']; |
|
$states{'new'} = ['courseinfo','enrollment','personnel','review','process']; |
|
|
|
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) { |
|
unless ($env{'form.state'} eq 'crstype') { |
|
unshift(@{$states{'new'}},'codepick'); |
|
} |
|
} |
|
|
|
foreach my $key (keys(%states)) { |
|
if (ref($states{$key}) eq 'ARRAY') { |
|
unshift (@{$states{$key}},'crstype'); |
|
} |
|
} |
|
|
|
my @invalidcrosslist; |
|
my %trail = ( |
|
crstype => 'Course Request Action', |
|
codepick => 'Category', |
|
courseinfo => 'Description', |
|
enrollment => 'Access Dates', |
|
personnel => 'Personnel', |
|
review => 'Review', |
|
process => 'Result', |
|
pick_request => 'Display Summary', |
|
details => 'Request Details', |
|
cancel => 'Cancel Request', |
|
removal => 'Outcome', |
|
); |
|
|
|
if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) { |
|
$trail{'enrollment'} = 'Enrollment'; |
|
} |
|
|
|
my ($page,$crumb,$newinstcode,$codechk,$checkedcode) = |
|
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail); |
if ($action eq 'display') { |
if ($action eq 'display') { |
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { |
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { |
my $namespace = 'courserequestqueue'; |
my $namespace = 'courserequestqueue'; |
Line 162 sub handler {
|
Line 212 sub handler {
|
if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) { |
if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) { |
my $result = &retrieve_settings($env{'form.showdom'},$env{'form.cnum'}); |
my $result = &retrieve_settings($env{'form.showdom'},$env{'form.cnum'}); |
} |
} |
|
} elsif ($env{'form.crstype'} eq 'official') { |
|
if (&Apache::lonnet::auto_run('',$dom)) { |
|
if (($action eq 'new') && (($state eq 'enrollment') || |
|
($state eq 'personnel'))) { |
|
my $checkcrosslist = 0; |
|
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) { |
|
if ($env{'form.crosslist_'.$i}) { |
|
$checkcrosslist ++; |
|
} |
|
} |
|
if ($checkcrosslist) { |
|
my %codechk; |
|
my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem); |
|
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles, |
|
\%cat_titles, |
|
\%cat_order, |
|
\@code_order); |
|
my $numtitles = scalar(@codetitles); |
|
if ($numtitles) { |
|
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) { |
|
if ($env{'form.crosslist_'.$i}) { |
|
my $codecheck; |
|
my $crosslistcode = ''; |
|
foreach my $item (@code_order) { |
|
$crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item}; |
|
} |
|
if ($crosslistcode ne '') { |
|
$codechk{$i} = |
|
&Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode); |
|
} |
|
unless ($codechk{$i} eq 'valid') { |
|
$env{'form.crosslist_'.$i} = ''; |
|
push(@invalidcrosslist,$crosslistcode); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
} |
my %elements = &form_elements($dom); |
my %elements = &form_elements($dom); |
my $elementsref = {}; |
my $elementsref = {}; |
Line 173 sub handler {
|
Line 263 sub handler {
|
if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) { |
if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) { |
$env{'form.clonedom'} = $dom; |
$env{'form.clonedom'} = $dom; |
} |
} |
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored); |
if ($state eq 'crstype') { |
|
$jscript = &mainmenu_javascript(); |
|
} else { |
|
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored); |
|
} |
} |
} |
|
|
if ($state eq 'personnel') { |
if ($state eq 'personnel') { |
Line 182 sub handler {
|
Line 276 sub handler {
|
|
|
my $loaditems = &onload_action($action,$state); |
my $loaditems = &onload_action($action,$state); |
|
|
my %states; |
|
$states{'display'} = ['details']; |
|
$states{'view'} = ['pick_request','details','cancel','removal']; |
|
$states{'log'} = ['filter','display']; |
|
$states{'new'} = ['courseinfo','enrollment','personnel','review','process']; |
|
|
|
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) { |
|
unless ($env{'form.state'} eq 'crstype') { |
|
unshift(@{$states{'new'}},'codepick'); |
|
} |
|
} |
|
|
|
foreach my $key (keys(%states)) { |
|
if (ref($states{$key}) eq 'ARRAY') { |
|
unshift (@{$states{$key}},'crstype'); |
|
} |
|
} |
|
|
|
my %trail = ( |
|
crstype => 'Course Request Action', |
|
codepick => 'Category', |
|
courseinfo => 'Description', |
|
enrollment => 'Access Dates', |
|
personnel => 'Personnel', |
|
review => 'Review', |
|
process => 'Result', |
|
pick_request => 'Display Summary', |
|
details => 'Request Details', |
|
cancel => 'Cancel Request', |
|
removal => 'Outcome', |
|
); |
|
|
|
if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) { |
|
$trail{'enrollment'} = 'Enrollment'; |
|
} |
|
|
|
my $page = 0; |
|
my $crumb; |
|
if (defined($action)) { |
|
my $done = 0; |
|
my $i=0; |
|
if (ref($states{$action}) eq 'ARRAY') { |
|
while ($i<@{$states{$action}} && !$done) { |
|
if ($states{$action}[$i] eq $state) { |
|
$page = $i; |
|
$done = 1; |
|
} |
|
$i++; |
|
} |
|
} |
|
for (my $i=0; $i<@{$states{$action}}; $i++) { |
|
if ($state eq $states{$action}[$i]) { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{text=>"$trail{$state}"}); |
|
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
|
last; |
|
} else { |
|
if (($state eq 'process') && ($i > 0)) { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{href=>"javascript:backPage(document.requestcrs,'$states{$action}[0]')", |
|
text=>"$trail{$states{$action}[$i]}"}); |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{href=>"javascript:backPage(document.requestcrs,'$states{$action}[$i]')", |
|
text=>"$trail{$states{$action}[$i]}"}); |
|
} |
|
} |
|
} |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{text=>'Pick Action'}); |
|
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
|
} |
|
|
|
my %can_request; |
my %can_request; |
my $canreq = &check_can_request($dom,\%can_request); |
my $canreq = &check_can_request($dom,\%can_request); |
if ($action eq 'new') { |
if ($action eq 'new') { |
Line 264 sub handler {
|
Line 284 sub handler {
|
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems, |
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems, |
$crumb); |
$crumb); |
} else { |
} else { |
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
&request_administration($r,$action,$state,$page,\%states,$dom, |
$loaditems,$crumb); |
$jscript,$loaditems,$crumb,$newinstcode, |
|
$codechk,$checkedcode,\@invalidcrosslist); |
} |
} |
} else { |
} else { |
$r->print(&header('Course Requests').$crumb. |
$r->print(&header('Course Requests').$crumb. |
Line 275 sub handler {
|
Line 296 sub handler {
|
} |
} |
} elsif ($action eq 'view') { |
} elsif ($action eq 'view') { |
if ($state eq 'crstype') { |
if ($state eq 'crstype') { |
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb); |
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb); |
} else { |
} else { |
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
$loaditems,$crumb); |
$loaditems,$crumb); |
Line 289 sub handler {
|
Line 310 sub handler {
|
&close_popup_form()); |
&close_popup_form()); |
} else { |
} else { |
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
$loaditems,$crumb,$uname,$udom); |
$loaditems,$crumb,'','','','',$uname,$udom); |
} |
} |
} elsif ($action eq 'log') { |
} elsif ($action eq 'log') { |
&print_request_logs($jscript,$loaditems,$crumb); |
&print_request_logs($jscript,$loaditems,$crumb); |
Line 299 sub handler {
|
Line 320 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
|
sub mainmenu_javascript { |
|
return <<"END"; |
|
function setType(courseForm) { |
|
for (var i=0; i<courseForm.crstype.length; i++) { |
|
if (courseForm.crstype.options[i].value == "$env{'form.crstype'}") { |
|
courseForm.crstype.options[i].selected = true; |
|
} else { |
|
courseForm.crstype.options[i].selected = false; |
|
} |
|
} |
|
} |
|
|
|
function setAction(courseForm) { |
|
for (var i=0; i<courseForm.action.length; i++) { |
|
if (courseForm.action.options[i].value == "$env{'form.action'}") { |
|
courseForm.action.options[i].selected = true; |
|
} else { |
|
courseForm.action.options[i].selected = false; |
|
} |
|
} |
|
} |
|
END |
|
} |
|
|
|
sub get_breadcrumbs { |
|
my ($dom,$action,$state,$states,$trail) = @_; |
|
my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles); |
|
my $page = 0; |
|
if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) { |
|
if (defined($action)) { |
|
my $done = 0; |
|
my $i=0; |
|
if (ref($states->{$action}) eq 'ARRAY') { |
|
while ($i<@{$states->{$action}} && !$done) { |
|
if ($states->{$action}[$i] eq $$state) { |
|
$page = $i; |
|
$done = 1; |
|
} |
|
$i++; |
|
} |
|
} |
|
if ($env{'form.crstype'} eq 'official') { |
|
if ($page > 1) { |
|
if ($states->{$action}[$page-1] eq 'codepick') { |
|
if ($env{'form.instcode'} eq '') { |
|
($newinstcode,$numtitles) = &get_instcode($dom); |
|
if ($numtitles) { |
|
if ($newinstcode eq '') { |
|
$$state = 'codepick'; |
|
$page --; |
|
} else { |
|
$codechk = |
|
&Apache::lonnet::auto_validate_instcode('', |
|
$dom,$newinstcode); |
|
if ($codechk ne 'valid') { |
|
$$state = 'codepick'; |
|
$page --; |
|
} |
|
$checkedcode = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
for (my $i=0; $i<@{$states->{$action}}; $i++) { |
|
if ($$state eq $states->{$action}[$i]) { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{text=>"$trail->{$$state}"}); |
|
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
|
last; |
|
} else { |
|
if (($$state eq 'process') || ($$state eq 'removal')) { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{ href => '/adm/requestcourse', |
|
text => "$trail->{$states->{$action}[$i]}", |
|
} |
|
); |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{ href => "javascript:backPage(document.requestcrs,'$states->{$action}[$i]')", |
|
text => "$trail->{$states->{$action}[$i]}", } |
|
); |
|
} |
|
} |
|
} |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{text=>'Pick Action'}); |
|
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
|
} |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{text=>'Pick Action'}); |
|
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
|
} |
|
return ($page,$crumb,$newinstcode,$codechk,$checkedcode); |
|
} |
|
|
sub header { |
sub header { |
my ($bodytitle,$jscript,$loaditems,$jsextra,$args) = @_; |
my ($bodytitle,$jscript,$loaditems,$jsextra,$args) = @_; |
if ($jscript) { |
if ($jscript) { |
Line 401 sub form_elements {
|
Line 521 sub form_elements {
|
enrollend_year => 'text', |
enrollend_year => 'text', |
enrollend_minute => 'text', |
enrollend_minute => 'text', |
enrollend_second => 'text', |
enrollend_second => 'text', |
crosslisttotal => 'hidden', |
|
addcrosslist => 'checkbox', |
addcrosslist => 'checkbox', |
autoadds => 'radio', |
autoadds => 'radio', |
autodrops => 'radio', |
autodrops => 'radio', |
Line 420 sub form_elements {
|
Line 539 sub form_elements {
|
if (!$crosslisttotal) { |
if (!$crosslisttotal) { |
$crosslisttotal = 1; |
$crosslisttotal = 1; |
} |
} |
|
|
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) { |
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) { |
if ($numtitles) { |
if ($numtitles) { |
$extras{'crosslist_'.$i.'_'.$lastitem} = 'text'; |
$extras{'crosslist_'.$i.'_'.$lastitem} = 'text'; |
Line 464 sub onload_action {
|
Line 584 sub onload_action {
|
my ($action,$state) = @_; |
my ($action,$state) = @_; |
my %loaditems; |
my %loaditems; |
if (($action eq 'new') || ($action eq 'view')) { |
if (($action eq 'new') || ($action eq 'view')) { |
$loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)'; |
if ($state eq 'crstype') { |
|
$loaditems{'onload'} = 'javascript:setAction(document.mainmenu_action);javascript:setType(document.mainmenu_coursetype)'; |
|
} else { |
|
$loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)'; |
|
} |
} |
} |
return \%loaditems; |
return \%loaditems; |
} |
} |
Line 536 sub print_main_menu {
|
Line 660 sub print_main_menu {
|
my $js = <<"END"; |
my $js = <<"END"; |
|
|
function nextPage(formname) { |
function nextPage(formname) { |
var crschoice = document.requestcrs.crstype.value; |
var crschoice = document.mainmenu_coursetype.crstype.value; |
var actionchoice = document.requestcrs.action.value; |
var actionchoice = document.mainmenu_action.action.value; |
if (check_can_request(crschoice,actionchoice) == true) { |
if (check_can_request(crschoice,actionchoice) == true) { |
if ((actionchoice == 'new') && (crschoice == 'official')) { |
if ((actionchoice == 'new') && (crschoice == 'official')) { |
nextstate = 'codepick'; |
nextstate = 'codepick'; |
} else { |
} else { |
$nextstate_setter |
$nextstate_setter |
} |
} |
|
formname.crstype.value = crschoice; |
|
formname.action.value = actionchoice; |
formname.state.value= nextstate; |
formname.state.value= nextstate; |
formname.submit(); |
formname.submit(); |
} |
} |
Line 598 END
|
Line 724 END
|
|
|
END |
END |
|
|
$r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb. |
$r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb.'<div>'. |
'<div>'. |
|
'<form name="domforcourse" method="post" action="/adm/requestcourse">'. |
|
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title('Course Domain'). |
&Apache::lonhtmlcommon::row_title(&mt('Course Domain')). |
|
'<form name="domforcourse" method="post" action="/adm/requestcourse">'. |
&Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange)); |
&Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange)); |
if (!$onchange) { |
if (!$onchange) { |
$r->print(' <input type="submit" name="godom" value="'. |
$r->print(' <input type="submit" name="godom" value="'. |
&mt('Change').'" />'); |
&mt('Change').'" />'); |
} |
} |
$r->print(&Apache::lonhtmlcommon::row_closure(1). |
$r->print('</form>'.&Apache::lonhtmlcommon::row_closure()); |
&Apache::lonhtmlcommon::end_pick_box().'</form></div>'); |
|
|
|
my $formname = 'requestcrs'; |
my $formname = 'requestcrs'; |
my $nexttext = &mt('Next'); |
my $nexttext = &mt('Next'); |
$r->print( |
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Action')).' |
'<div><form name="'.$formname.'" method="post" action="/adm/requestcourse">'. |
<form name="mainmenu_action" method="post" action=""> |
&Apache::lonhtmlcommon::start_pick_box(). |
|
&Apache::lonhtmlcommon::row_title('Action').' |
|
<input type="hidden" name="showdom" value="'.$dom.'" /> |
|
<select size="1" name="action" > |
<select size="1" name="action" > |
<option value="new">'.&mt('New request').'</option> |
<option value="new">'.&mt('New request').'</option> |
<option value="view">'.&mt('View/Modify/Cancel pending requests').'</option> |
<option value="view">'.&mt('View/Modify/Cancel pending requests').'</option> |
<option value="log">'.&mt('View request history').'</option> |
<option value="log">'.&mt('View request history').'</option> |
</select>'. |
</select></form>'. |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title('Course Type').' |
&Apache::lonhtmlcommon::row_title(&mt('Course Type')).' |
|
<form name="mainmenu_coursetype" method="post" action=""> |
<select size="1" name="crstype"> |
<select size="1" name="crstype"> |
<option value="any">'.&mt('All types').'</option>'); |
<option value="any">'.&mt('All types').'</option>'); |
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) { |
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) { |
Line 637 END
|
Line 759 END
|
'</option>'."\n"); |
'</option>'."\n"); |
} |
} |
} |
} |
$r->print('</select> |
$r->print('</select></form>'."\n". |
<input type="hidden" name="state" value="crstype" />'. |
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n". |
&Apache::lonhtmlcommon::end_pick_box().'<br /> |
'<div><form name="'.$formname.'" method="post" action="">'."\n". |
<input type="button" name="next" value="'.$nexttext.'" onclick="javascript:nextPage(document.'.$formname.')" /> |
'<input type="hidden" name="state" value="crstype" />'."\n". |
</form></div>'); |
'<input type="hidden" name="showdom" value="'.$dom.'" />'."\n". |
|
'<input type="hidden" name="crstype" value="" />'."\n". |
|
'<input type="hidden" name="action" value="" />'."\n". |
|
'<input type="button" name="next" value="'.$nexttext. |
|
'" onclick="javascript:nextPage(document.'.$formname.')" />'."\n". |
|
'</form></div>'); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
|
|
sub request_administration { |
sub request_administration { |
my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,$uname,$udom) = @_; |
my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb, |
|
$newinstcode,$codechk,$checkedcode,$invalidcrosslist,$uname,$udom) = @_; |
my $js; |
my $js; |
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) { |
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) { |
$js = <<END; |
$js = <<END; |
Line 676 END
|
Line 804 END
|
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); |
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); |
} |
} |
$r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb); |
$r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb); |
&print_request_form($r,$action,$state,$page,$states,$dom); |
&print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode, |
|
$codechk,$checkedcode,$invalidcrosslist); |
} elsif ($action eq 'view') { |
} elsif ($action eq 'view') { |
my $jsextra; |
my $jsextra; |
my $formname = 'requestcrs'; |
my $formname = 'requestcrs'; |
Line 696 END
|
Line 825 END
|
my $form = '<form method="post" name="'.$formname.'" action="/adm/requestcourse" />'; |
my $form = '<form method="post" name="'.$formname.'" action="/adm/requestcourse" />'; |
if ($state eq 'pick_request') { |
if ($state eq 'pick_request') { |
$r->print('<h3>'.&mt('Pending course requests').'</h3><div>'."\n".$form."\n". |
$r->print('<h3>'.&mt('Pending course requests').'</h3><div>'."\n".$form."\n". |
&print_request_status($dom).'</form>'); |
&print_request_status($dom).'</form></div>'); |
} elsif ($state eq 'details') { |
} elsif ($state eq 'details') { |
my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk); |
my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk); |
my $origcnum = $env{'form.cnum'}; |
my $origcnum = $env{'form.cnum'}; |
Line 809 sub close_popup_form {
|
Line 938 sub close_popup_form {
|
END |
END |
} |
} |
|
|
|
sub get_instcode { |
|
my ($dom) = @_; |
|
my ($instcode,$numtitles); |
|
my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk); |
|
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
|
\%cat_order,\@code_order); |
|
$numtitles = scalar(@codetitles); |
|
if (@code_order > 0) { |
|
my $message; |
|
foreach my $item (@code_order) { |
|
$instcode .= $env{'form.instcode_'.$item}; |
|
} |
|
} |
|
return ($instcode,$numtitles); |
|
} |
|
|
sub print_request_form { |
sub print_request_form { |
my ($r,$action,$state,$page,$states,$dom) = @_; |
my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode, |
|
$invalidcrosslist) = @_; |
my $formname = 'requestcrs'; |
my $formname = 'requestcrs'; |
my ($next,$prev,$message,$output,$codepicker,$crstype); |
my ($next,$prev,$message,$output,$codepicker,$crstype); |
$prev = $states->{$action}[$page-1]; |
$prev = $states->{$action}[$page-1]; |
Line 821 sub print_request_form {
|
Line 967 sub print_request_form {
|
); |
); |
$crstype = $env{'form.crstype'}; |
$crstype = $env{'form.crstype'}; |
$r->print('<form name="'.$formname.'" method="post" action="/adm/requestcourse">'); |
$r->print('<form name="'.$formname.'" method="post" action="/adm/requestcourse">'); |
my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk); |
my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk, |
|
@disallowed); |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
if ($env{'form.instcode'} ne '') { |
if ($env{'form.instcode'} ne '') { |
$instcode = $env{'form.instcode'}; |
$instcode = $env{'form.instcode'}; |
|
} elsif ($newinstcode ne '') { |
|
$instcode = $newinstcode; |
} |
} |
} |
if ($checkedcode) { |
if ($prev eq 'codepick') { |
if ($codechk eq 'valid') { |
if ($crstype eq 'official') { |
$message = '<div class="LC_info">'. |
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
&mt('The chosen course category [_1] is valid.','<b>'. |
\%cat_order,\@code_order); |
$instcode.'</b>'). |
} |
'<input type="hidden" name="instcode" value="'. |
if (@code_order > 0) { |
$instcode.'" /></div>'; |
my $message; |
|
if ($instcode eq '') { |
|
foreach my $item (@code_order) { |
|
$instcode .= $env{'form.instcode_'.$item}; |
|
} |
|
$r->print('<input type="hidden" name="instcode" value="'.$instcode.'" />'."\n"); |
|
} |
|
if ($instcode ne '') { |
|
$code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode); |
|
if ($code_chk eq 'valid') { |
|
$message = '<div class="LC_info">'. |
|
&mt('The chosen course category [_1] is valid.','<b>'. |
|
$instcode.'</b>').'</div>'; |
|
} else { |
|
$message = '<div class="LC_warning">'. |
|
&mt('No course was found matching your choice of institutional course category.'); |
|
if ($code_chk ne '') { |
|
$message .= '<br />'.$code_chk; |
|
} |
|
$message .= '</div>'; |
|
} |
|
} else { |
} else { |
$message = '<div class="LC_warning">'. |
$message = '<div class="LC_warning">'. |
&mt('No course was found matching your choice of institutional course category.'); |
&mt('No course was found matching your choice of institutional course category.'); |
} |
if ($codechk ne '') { |
unless ($code_chk eq 'valid') { |
$message .= '<br />'.$codechk; |
|
} |
|
$message .= '</div>'; |
$prev = 'crstype'; |
$prev = 'crstype'; |
} |
} |
$r->print($message); |
$r->print($message); |
Line 886 sub print_request_form {
|
Line 1016 sub print_request_form {
|
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
} |
} |
} elsif ($prev eq 'codepick') { |
} elsif ($prev eq 'codepick') { |
if ($env{'form.instcode'} eq '') { |
if ($instcode eq '') { |
$prev = $states->{$action}[$page-2]; |
$prev = $states->{$action}[$page-2]; |
} |
} |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
Line 896 sub print_request_form {
|
Line 1026 sub print_request_form {
|
\%cat_order,\@code_order); |
\%cat_order,\@code_order); |
} |
} |
$r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles, |
$r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles, |
\%cat_titles,\%cat_order,\@code_order)); |
\%cat_titles,\%cat_order,\@code_order, |
|
$invalidcrosslist)); |
} elsif ($state eq 'personnel') { |
} elsif ($state eq 'personnel') { |
$r->print(&print_personnel_menu($dom,$formname,$crstype)); |
$r->print(&print_personnel_menu($dom,$formname,$crstype,$invalidcrosslist)); |
} elsif ($state eq 'review') { |
} elsif ($state eq 'review') { |
|
my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg); |
|
my $now = time; |
|
for (my $i=0; $i<$env{'form.persontotal'}; $i++) { |
|
my $personname = $env{'form.person_'.$i.'_uname'}; |
|
my $persondom = $env{'form.person_'.$i.'_dom'}; |
|
if (($personname =~ /^$match_username$/) && |
|
($persondom =~ /^$match_domain$/)) { |
|
if (&Apache::lonnet::domain($persondom)) { |
|
my $personhome = |
|
&Apache::lonnet::homeserver($personname,$persondom); |
|
if ($personhome eq 'no_host') { |
|
if ($persondom ne $dom) { |
|
my $skipuser = 1; |
|
if ($env{'user.role.dc./'.$persondom.'/'}) { |
|
my ($start,$end) = split('.',$env{'user.role.dc./'.$persondom.'/'}); |
|
if (((!$start) || ($start < $now)) && |
|
((!$end) || ($end > $now))) { |
|
$skipuser = 0; |
|
} |
|
} |
|
if ($skipuser) { |
|
push(@disallowed,$i); |
|
$disallowmsg{$i} = &mt('[_1] was excluded because new users need be from the course domain','<tt>'.$personname.':'.$persondom.'</tt>'); |
|
next; |
|
} |
|
} |
|
if (&get_cancreate_status($persondom,$personname,$dom)) { |
|
my ($allowed,$msg) = |
|
&check_newuser_rules($persondom,$personname, |
|
\%alerts,\%rulematch,\%inst_results, |
|
\%curr_rules,\%got_rules); |
|
if ($allowed) { |
|
if (ref($inst_results{$personname.':'.$persondom}) eq 'HASH') { |
|
if ($inst_results{$personname.':'.$persondom}{'lastname'} ne '') { |
|
$env{'form.person_'.$i.'_lastname'} = $inst_results{$personname.':'.$persondom}{'lastname'}; |
|
} |
|
if ($inst_results{$personname.':'.$persondom}{'firstname'} ne '') { |
|
$env{'form.person_'.$i.'_firstname'} = $inst_results{$personname.':'.$persondom}{'firstname'}; |
|
} |
|
if ($inst_results{$personname.':'.$persondom}{'permanentemail'} ne '') { |
|
$env{'form.person_'.$i.'_emailaddr'} = $inst_results{$personname.':'.$persondom}{'permanentemail'}; |
|
} |
|
} |
|
} else { |
|
push(@disallowed,$i); |
|
$disallowmsg{$i} = &mt('[_1] was excluded because the username violated format rules for the domain','<tt>'.$personname.':'.$persondom.'</tt>'); |
|
} |
|
} else { |
|
push(@disallowed,$i); |
|
$disallowmsg{$i} = &mt('[_1] was excluded because you may not request new users in the domain','<tt>'.$personname.':'.$persondom.'</tt>'); |
|
} |
|
} else { |
|
my %userenv = |
|
&Apache::lonnet::userenvironment($persondom,$personname,'lastname','firstname','permanentemail'); |
|
if ($env{'form.person_'.$i.'_lastname'} eq '') { |
|
$env{'form.person_'.$i.'_lastname'} = $userenv{'lastname'}; |
|
} |
|
if ($env{'form.person_'.$i.'_firstname'} eq '') { |
|
$env{'form.person_'.$i.'_firstname'} = $userenv{'firstname'}; |
|
} |
|
if ($env{'form.person_'.$i.'_emailaddr'} eq '') { |
|
$env{'form.person_'.$i.'_emailaddr'} = $userenv{'permanentemail'}; |
|
} |
|
} |
|
} elsif ($personname ne '') { |
|
push(@disallowed,$i); |
|
$disallowmsg{$i} = &mt('[_1] was excluded because the domain is invalid','<tt>'.$personname.':'.$persondom.'</tt>'); |
|
} |
|
} elsif ($personname ne '') { |
|
push(@disallowed,$i); |
|
$disallowmsg{$i} = &mt('[_1] was excluded because the username or domain is invalid.','<tt>'.$personname.':'.$persondom.'</tt>'); |
|
} |
|
} |
my $cnum; |
my $cnum; |
if ($env{'form.origcnum'} =~ /^($match_courseid)$/) { |
if ($env{'form.origcnum'} =~ /^($match_courseid)$/) { |
$cnum = $env{'form.origcnum'}; |
$cnum = $env{'form.origcnum'}; |
Line 908 sub print_request_form {
|
Line 1112 sub print_request_form {
|
} |
} |
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
\%cat_order,\@code_order); |
\%cat_order,\@code_order); |
$r->print('<p>'.&mt('Review the details of the course request before submission.').'</p>'. |
$r->print('<h3>'.&mt('Review course request details before submission').'</h3>'. |
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order). |
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg). |
'<input type="hidden" name="cnum" value="'.$cnum.'" />'); |
'<input type="hidden" name="cnum" value="'.$cnum.'" />'); |
$navtxt{'next'} = &mt('Submit course request'); |
$navtxt{'next'} = &mt('Submit course request'); |
} elsif ($state eq 'process') { |
} elsif ($state eq 'process') { |
Line 917 sub print_request_form {
|
Line 1121 sub print_request_form {
|
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
\%cat_order,\@code_order); |
\%cat_order,\@code_order); |
} |
} |
my $result = &print_request_outcome($dom,\@codetitles,\@code_order); |
my ($storeresult,$result) = &print_request_outcome($dom,\@codetitles, |
|
\@code_order); |
$r->print($result); |
$r->print($result); |
|
if (($storeresult eq 'ok') || ($storeresult eq 'created')) { |
|
$r->print('<p>'); |
|
if ($storeresult eq 'ok') { |
|
$r->print('<a href="/adm/requestcourse?action=view&state=details&showdom='.$dom.'&cnum='. $env{'form.cnum'}.'">'. |
|
&mt('Modify this request').'</a>'.(' 'x4)); |
|
} |
|
$r->print('<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>'); |
|
return; |
|
} |
} |
} |
my @excluded = &get_excluded_elements($dom,$states,$action,$state); |
my @excluded = &get_excluded_elements($dom,$states,$action,$state); |
if ($state eq 'personnel') { |
if ($state eq 'personnel') { |
push(@excluded,'persontotal'); |
push(@excluded,'persontotal'); |
} |
} |
|
if ($state eq 'review') { |
|
if (@disallowed > 0) { |
|
my @items = qw(uname dom lastname firstname emailaddr hidedom role newsec); |
|
my @currsecs = ¤t_lc_sections(); |
|
if (@currsecs) { |
|
push(@items,'sec'); |
|
} |
|
my $count = 0; |
|
for (my $i=0; $i<$env{'form.persontotal'}; $i++) { |
|
unless ($env{'form.person_'.$i.'_uname'} eq '') { |
|
if (grep(/^$i$/,@disallowed)) { |
|
foreach my $item (@items) { |
|
$env{'form.person_'.$i.'_'.$item} = ''; |
|
} |
|
} else { |
|
foreach my $item (@items) { |
|
$env{'form.person_'.$count.'_'.$item} = $env{'form.person_'.$i.'_'.$item}; |
|
} |
|
} |
|
} |
|
$count ++; |
|
} |
|
$env{'form.persontotal'} = $count; |
|
|
|
} |
|
} |
|
if ($state eq 'enrollment') { |
|
push(@excluded,'crosslisttotal'); |
|
} |
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>'); |
&display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state); |
&display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state); |
return; |
return; |
} |
} |
|
|
|
sub get_cancreate_status { |
|
my ($persondom,$personname,$dom) = @_; |
|
my ($rules,$ruleorder) = |
|
&Apache::lonnet::inst_userrules($persondom,'username'); |
|
my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname, |
|
$rules); |
|
return &Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype); |
|
} |
|
|
|
sub check_newuser_rules { |
|
my ($persondom,$personname,$alerts,$rulematch,$inst_results,$curr_rules, |
|
$got_rules) = @_; |
|
my $allowed = 1; |
|
my $newuser = 1; |
|
my ($checkhash,$userchkmsg); |
|
my $checks = { 'username' => 1 }; |
|
$checkhash->{$personname.':'.$persondom} = { 'newuser' => $newuser }; |
|
&Apache::loncommon::user_rule_check($checkhash,$checks,$alerts,$rulematch, |
|
$inst_results,$curr_rules,$got_rules); |
|
if (ref($alerts->{'username'}) eq 'HASH') { |
|
if (ref($alerts->{'username'}{$persondom}) eq 'HASH') { |
|
my $domdesc = |
|
&Apache::lonnet::domain($persondom,'description'); |
|
if ($alerts->{'username'}{$persondom}{$personname}) { |
|
if (ref($curr_rules->{$persondom}) eq 'HASH') { |
|
$userchkmsg = |
|
&Apache::loncommon::instrule_disallow_msg('username', |
|
$domdesc,1). |
|
&Apache::loncommon::user_rule_formats($persondom, |
|
$domdesc,$curr_rules->{$persondom}{'username'}, |
|
'username'); |
|
} |
|
$allowed = 0; |
|
} |
|
} |
|
} |
|
return ($allowed,$userchkmsg); |
|
} |
|
|
sub get_excluded_elements { |
sub get_excluded_elements { |
my ($dom,$states,$action,$state) = @_; |
my ($dom,$states,$action,$state) = @_; |
my @excluded = ('counter'); |
my @excluded = ('counter'); |
Line 958 sub get_excluded_elements {
|
Line 1240 sub get_excluded_elements {
|
} |
} |
|
|
sub print_enrollment_menu { |
sub print_enrollment_menu { |
my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order) =@_; |
my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order, |
my ($sections,$autoenroll,$access_dates); |
$invalidcrosslist) =@_; |
|
my ($sections,$autoenroll,$access_dates,$output); |
my $starttime = time; |
my $starttime = time; |
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx |
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx |
|
|
Line 973 sub print_enrollment_menu {
|
Line 1256 sub print_enrollment_menu {
|
); |
); |
if ($env{'form.crstype'} eq 'official') { |
if ($env{'form.crstype'} eq 'official') { |
if (&Apache::lonnet::auto_run('',$dom)) { |
if (&Apache::lonnet::auto_run('',$dom)) { |
my ($section_form,$crosslist_form,$autoenroll_form); |
$output = &show_invalid_crosslists($invalidcrosslist); |
|
my ($section_form,$crosslist_form); |
$section_form = &inst_section_selector($dom,$instcode); |
$section_form = &inst_section_selector($dom,$instcode); |
|
if ($section_form) { |
|
$sections = &Apache::lonhtmlcommon::row_headline(). |
|
'<h3>'.&mt('Sections for auto-enrollment').'</h3>'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
$section_form; |
|
} |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
if (!$crosslisttotal) { |
if (!$crosslisttotal) { |
$crosslisttotal = 1; |
$crosslisttotal = 1; |
Line 992 sub print_enrollment_menu {
|
Line 1282 sub print_enrollment_menu {
|
'<input name="crosslisttotal" type="hidden" value="'.$crosslisttotal.'" />'. |
'<input name="crosslisttotal" type="hidden" value="'.$crosslisttotal.'" />'. |
'<input name="addcrosslist" type="checkbox" value="'.$crosslisttotal.'"'. |
'<input name="addcrosslist" type="checkbox" value="'.$crosslisttotal.'"'. |
' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}. |
' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}. |
"'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1); |
"'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(); |
} |
$sections .= &Apache::lonhtmlcommon::row_headline. |
if ($section_form || $crosslist_form) { |
'<h3>'.&mt('Crosslisted courses for auto-enrollment').'</h3>'. |
$sections = '<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_closure(1). |
$section_form.$crosslist_form. |
$crosslist_form; |
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n"; |
|
} |
} |
$autoenroll_form = |
$autoenroll = |
&Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')). |
&Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')). |
'<span class="LC_nobreak"><label>'. |
'<span class="LC_nobreak"><label>'. |
'<input type="radio" name="autoadds" value="1">'. |
'<input type="radio" name="autoadds" value="1">'. |
&mt('Yes').'</label>'.(' 'x3).'<label>'. |
&mt('Yes').'</label>'.(' 'x3).'<label>'. |
'<input type="radio" name="autoadds" value="0" checked="checked">'. |
'<input type="radio" name="autoadds" value="0" checked="checked">'. |
&mt('No').'</label></span>'. |
&mt('No').'</label></span>'. |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')). |
&Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')). |
'<span class="LC_nobreak"><label>'. |
'<span class="LC_nobreak"><label>'. |
'<input type="radio" name="autodrops" value="1">'. |
'<input type="radio" name="autodrops" value="1">'. |
&mt('Yes').'</label>'.(' 'x3).'<label>'. |
&mt('Yes').'</label>'.(' 'x3).'<label>'. |
'<input type="radio" name="autodrops" value="0" checked="checked">'. |
'<input type="radio" name="autodrops" value="0" checked="checked">'. |
&mt('No').'</label></span>'. |
&mt('No').'</label></span>'. |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(1). |
&date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles); |
&date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles); |
if ($autoenroll_form) { |
|
$autoenroll = '<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
|
$autoenroll_form. |
|
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n"; |
|
} |
|
} |
} |
} |
} |
my $access_dates_form = |
my $access_dates = |
&date_setting_table($starttime,$endtime,$formname,'access',%accesstitles); |
&date_setting_table($starttime,$endtime,$formname,'access',%accesstitles); |
if ($access_dates_form) { |
$output .= &Apache::lonhtmlcommon::start_pick_box(); |
$access_dates = '<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
if ($sections) { |
$access_dates_form. |
$output .= $sections; |
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n"; |
} |
|
if ($autoenroll) { |
|
$output .= &Apache::lonhtmlcommon::row_headline('Auto-enroll'). |
|
'<h3>'.&mt('Auto-enrollment settings').'</h3>'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
$autoenroll; |
|
} |
|
if ($access_dates) { |
|
my $header = &mt('Access dates for students'); |
|
if ($env{'form.crstype'} eq 'community') { |
|
$header = &mt('Access dates for community members'); |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_headline('Access'). |
|
'<h3>'.$header.'</h3>'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
$access_dates |
} |
} |
return $sections.$autoenroll.$access_dates; |
return '<div>'.&Apache::lonhtmlcommon::start_pick_box().$output. |
|
&Apache::lonhtmlcommon::end_pick_box().'</div>'; |
} |
} |
|
|
|
sub show_invalid_crosslists { |
|
my ($invalidcrosslist) = @_; |
|
my $output; |
|
if (ref($invalidcrosslist) eq 'ARRAY') { |
|
if (@{$invalidcrosslist} > 0) { |
|
$output = '<div class="LC_warning">'. |
|
&mt('The following crosslisted courses were invalid:').'<ul>'; |
|
foreach my $item (@{$invalidcrosslist}) { |
|
$output .= '<li>'.$item.'</li>'; |
|
} |
|
$output .= '</ul></div><br />'; |
|
} |
|
} |
|
return $output; |
|
} |
|
|
|
|
sub inst_section_selector { |
sub inst_section_selector { |
my ($dom,$instcode) = @_; |
my ($dom,$instcode) = @_; |
my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode); |
my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode); |
my $sectotal = scalar(@sections); |
my $sectotal = scalar(@sections); |
my $output; |
my $output; |
if ($sectotal) { |
if ($sectotal) { |
$output .= &Apache::lonhtmlcommon::row_title('Sections'). |
$output .= &Apache::lonhtmlcommon::row_title(&mt('Sections of [_1]',$instcode)). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_row(). |
&Apache::loncommon::start_data_table_row(). |
'<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '. |
'<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '. |
Line 1075 sub date_setting_table {
|
Line 1392 sub date_setting_table {
|
$starttime,'','','',1,'','','',1); |
$starttime,'','','',1,'','','',1); |
my $endform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'end', |
my $endform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'end', |
$endtime,'','','',1,'','','',1); |
$endtime,'','','',1,'','','',1); |
|
my $closure = ''; |
if ($prefix eq 'access') { |
if ($prefix eq 'access') { |
$perpetual = ' <span class="LC_nobreak"><label>'. |
$perpetual = ' <span class="LC_nobreak"><label>'. |
'<input type="checkbox" name="no_end_date" />'. |
'<input type="checkbox" name="no_end_date" />'. |
&mt('No end date').'</label></span>'; |
&mt('No end date').'</label></span>'; |
|
$closure = '1'; |
} |
} |
$table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}). |
$table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}). |
$startform. |
$startform. |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title($datetitles{'end'}). |
&Apache::lonhtmlcommon::row_title($datetitles{'end'}). |
$endform.$perpetual. |
$endform.$perpetual. |
&Apache::lonhtmlcommon::row_closure(1); |
&Apache::lonhtmlcommon::row_closure($closure); |
return $table; |
return $table; |
} |
} |
|
|
sub print_personnel_menu { |
sub print_personnel_menu { |
my ($dom,$formname,$crstype) = @_; |
my ($dom,$formname,$crstype,$invalidcrosslist) = @_; |
my $output = '<div>'.&Apache::lonhtmlcommon::start_pick_box(); |
my $output; |
|
if ($crstype eq 'official') { |
|
if (&Apache::lonnet::auto_run('',$dom)) { |
|
$output .= &show_invalid_crosslists($invalidcrosslist); |
|
} |
|
} |
|
$output .= '<div>'.&Apache::lonhtmlcommon::start_pick_box(); |
my $persontotal = $env{'form.persontotal'}; |
my $persontotal = $env{'form.persontotal'}; |
if ((!defined($persontotal)) || (!$persontotal)) { |
if ((!defined($persontotal)) || (!$persontotal)) { |
$persontotal = 1; |
$persontotal = 1; |
Line 1099 sub print_personnel_menu {
|
Line 1424 sub print_personnel_menu {
|
if ($env{'form.addperson'}) { |
if ($env{'form.addperson'}) { |
$persontotal ++; |
$persontotal ++; |
} |
} |
my $userlinktxt = &mt('Set User'); |
|
my @items = ('uname','dom','lastname','firstname','emailaddr','hidedom'); |
my @items = ('uname','dom','lastname','firstname','emailaddr','hidedom'); |
|
|
my $roleoptions; |
my $roleoptions; |
Line 1109 sub print_personnel_menu {
|
Line 1433 sub print_personnel_menu {
|
$type = 'Community'; |
$type = 'Community'; |
} |
} |
foreach my $role (@roles) { |
foreach my $role (@roles) { |
my $plrole=&Apache::lonnet::plaintext($role,$type); |
my $plrole = &Apache::lonnet::plaintext($role,$type); |
$roleoptions .= ' <option value="'.$role.'">'.$plrole.'</option>'."\n"; |
$roleoptions .= ' <option value="'.$role.'">'.$plrole.'</option>'."\n"; |
} |
} |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
if (keys(%customroles) > 0) { |
if (keys(%customroles) > 0) { |
foreach my $cust (sort(keys(%customroles))) { |
foreach my $cust (sort(keys(%customroles))) { |
my $custrole='cr_cr_'.$env{'user.domain'}. |
my $custrole="cr/$env{'user.domain'}/$env{'user.name'}/$cust"; |
'_'.$env{'user.name'}.'_'.$cust; |
|
$roleoptions .= ' <option value="'.$custrole.'">'.$cust.'</option>'."\n"; |
$roleoptions .= ' <option value="'.$custrole.'">'.$cust.'</option>'."\n"; |
} |
} |
} |
} |
|
|
my @currsecs; |
my @currsecs = ¤t_lc_sections(); |
if ($env{'form.sectotal'}) { |
|
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
|
if (defined($env{'form.loncapasec_'.$i})) { |
|
my $lcsec = $env{'form.loncapasec_'.$i}; |
|
unless (grep(/^\Q$lcsec\E$/,@currsecs)) { |
|
push(@currsecs,$lcsec); |
|
} |
|
} |
|
} |
|
} |
|
|
|
my ($existtitle,$existops,$existmult,$newtitle,$seccolspan); |
my ($existtitle,$existops,$existmult,$newtitle,$seccolspan); |
if (@currsecs) { |
if (@currsecs) { |
Line 1152 sub print_personnel_menu {
|
Line 1465 sub print_personnel_menu {
|
$newtitle = &mt('Other').': '; |
$newtitle = &mt('Other').': '; |
} |
} |
|
|
|
if ($persontotal) { |
|
$output .= &Apache::lonhtmlcommon::row_headline(). |
|
'<h3>'.&mt('Requestor is automatically assigned Course Coordinator role.').' '.&mt('Include other personnel?').'</h3>'; |
|
} |
for (my $i=0; $i<$persontotal; $i++) { |
for (my $i=0; $i<$persontotal; $i++) { |
my @linkargs = map { 'person_'.$i.'_'.$_ } (@items); |
my @linkargs = map { 'person_'.$i.'_'.$_ } (@items); |
my $linkargstr = join("','",@linkargs); |
my $linkargstr = join("','",@linkargs); |
my $userlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,$userlinktxt); |
my $uname_form = '<input type="text" name="person_'.$i.'_uname" value="" size="20" />'; |
my $uname_form = '<input type="text" name="person_'.$i.'_uname" value=""'. |
|
' onFocus="this.blur();'. |
|
'openuserbrowser('."'$formname','$linkargstr','$dom'".');" />'; |
|
my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',". |
my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',". |
"'person_".$i."_hidedom'".');'. |
"'person_".$i."_hidedom','person_".$i."_uname'".');'; |
'openuserbrowser('."'$formname','$linkargstr','$dom'".');'; |
|
my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','', |
my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','', |
1,$onchange). |
1,$onchange). |
'<input type="hidden" name="person_'.$i.'_hidedom" value="'.$dom.'" />'; |
'<input type="hidden" name="person_'.$i.'_hidedom" value="" />'; |
my %form_elems; |
my %form_elems; |
foreach my $item (@items) { |
foreach my $item (@items) { |
next if (($item eq 'dom') || ($item eq 'uname') || ($item eq 'hidedom')); |
next if (($item eq 'dom') || ($item eq 'uname') || ($item eq 'hidedom')); |
Line 1180 sub print_personnel_menu {
|
Line 1493 sub print_personnel_menu {
|
} |
} |
$sectionselector .= $newtitle. |
$sectionselector .= $newtitle. |
'<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'."\n"; |
'<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'."\n"; |
|
my $usersrchlinktxt = &mt('Search for user'); |
|
my $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, |
|
$usersrchlinktxt); |
|
my $userchklinktxt = &mt('Check username'); |
|
my $userchklink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, |
|
$userchklinktxt,'checkusername'); |
$output .= |
$output .= |
&Apache::lonhtmlcommon::row_title(&mt('Additional Personnel').'<br />'. |
&Apache::lonhtmlcommon::row_title(&mt('Additional Personnel')). |
'<span class="LC_nobreak">'.$userlink. |
'<table><tr><td align="center" valign="middle"><b>'.$usersrchlink.'</b></td>'."\n". |
'</span>'). |
'<td align="left" valign="top" colspan="2"><span class="LC_nobreak">'. |
'<table><tr><td align="center" valign="top">'.&mt('Username').'<br />'.$uname_form.'</td>'."\n". |
&mt('Username').': '.$uname_form.' '.$userchklink.'</span><br />'."\n". |
'<td align="center" valign="top" colspan="2">'.&mt('Domain').'<br />'.$udom_form.'</td></tr><tr>'."\n". |
'<span class="LC_nobreak">'.&mt('Domain').': '.$udom_form.'</span></td>'. |
|
'</tr>'."\n".'<tr>'. |
'<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'firstname'}.'</td>'."\n". |
'<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('Last Name').'<br />'.$form_elems{'lastname'}.'</td>'."\n". |
'<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{'emailaddr'}.'</td></tr>'."\n". |
'<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{'emailaddr'}.'</td></tr>'."\n". |
Line 1202 sub print_personnel_menu {
|
Line 1522 sub print_personnel_menu {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub current_lc_sections { |
|
my @currsecs; |
|
if ($env{'form.sectotal'}) { |
|
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
|
if (defined($env{'form.loncapasec_'.$i})) { |
|
my $lcsec = $env{'form.loncapasec_'.$i}; |
|
unless (grep(/^\Q$lcsec\E$/,@currsecs)) { |
|
push(@currsecs,$lcsec); |
|
} |
|
} |
|
} |
|
} |
|
return @currsecs; |
|
} |
|
|
sub print_request_status { |
sub print_request_status { |
my ($dom) = @_; |
my ($dom) = @_; |
my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'}, |
my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'}, |
Line 1310 sub print_request_status {
|
Line 1645 sub print_request_status {
|
$output .= '<div>'.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'</div>'; |
$output .= '<div>'.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'</div>'; |
} |
} |
$output .= ' |
$output .= ' |
<br /><input type="button" name="prev" value="'.&mt('Back').'" onclick="javascript:backPage(document.'.$formname.",'crstype'".')" /> |
<br /><input type="button" name="prev" value="'.&mt('Back').'" onclick="javascript:backPage(document.'.$formname.",'crstype'".')" />'; |
</form></div>'; |
|
return $output; |
return $output; |
} |
} |
|
|
Line 1417 sub print_request_logs {
|
Line 1751 sub print_request_logs {
|
} |
} |
|
|
sub print_review { |
sub print_review { |
my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom) = @_; |
my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom, |
|
$disallowed,$disallowmsg) = @_; |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &course_types(); |
my ($owner,$ownername,$owneremail); |
my ($owner,$ownername,$owneremail); |
if ($uname eq '' || $udom eq '') { |
if ($uname eq '' || $udom eq '') { |
Line 1595 sub print_review {
|
Line 1930 sub print_review {
|
'<td>'.&mt('None').'</td></tr>'; |
'<td>'.&mt('None').'</td></tr>'; |
for (my $i=0; $i<$env{'form.persontotal'}; $i++) { |
for (my $i=0; $i<$env{'form.persontotal'}; $i++) { |
if ($env{'form.person_'.$i.'_uname'} ne '') { |
if ($env{'form.person_'.$i.'_uname'} ne '') { |
|
if (ref($disallowed) eq 'ARRAY') { |
|
next if (grep(/^$i$/,@{$disallowed})); |
|
} |
my @allsecs = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec'); |
my @allsecs = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec'); |
my $newsec = $env{'form.person_'.$i.'_newsec'}; |
my $newsec = $env{'form.person_'.$i.'_newsec'}; |
$newsec =~ s/^\s+//; |
$newsec =~ s/^\s+//; |
Line 1619 sub print_review {
|
Line 1957 sub print_review {
|
if ($env{'form.person_'.$i.'_role'} eq 'cc') { |
if ($env{'form.person_'.$i.'_role'} eq 'cc') { |
$showsec = &mt('None'); |
$showsec = &mt('None'); |
} |
} |
|
my $role = $env{'form.person_'.$i.'_role'}; |
$personnel_values .= |
$personnel_values .= |
'<tr><td>'.$env{'form.person_'.$i.'_firstname'}.' '. |
'<tr><td>'.$env{'form.person_'.$i.'_firstname'}.' '. |
$env{'form.person_'.$i.'_lastname'}.'</td>'. |
$env{'form.person_'.$i.'_lastname'}.'</td>'. |
'<td>'.$env{'form.person_'.$i.'_uname'}.':'. |
'<td>'.$env{'form.person_'.$i.'_uname'}.':'. |
$env{'form.person_'.$i.'_dom'}.'</td>'. |
$env{'form.person_'.$i.'_dom'}.'</td>'. |
'<td>'.&Apache::lonnet::plaintext($env{'form.person_'.$i.'_role'}, |
'<td>'.&Apache::lonnet::plaintext($role,$container).'</td>'. |
$container).'</td>'. |
|
'<td>'.$showsec.'</td></tr>'; |
'<td>'.$showsec.'</td></tr>'; |
} |
} |
} |
} |
my $output = |
my $output; |
'<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
if (ref($disallowed) eq 'ARRAY') { |
|
if (@{$disallowed} > 0) { |
|
if (ref($disallowmsg) eq 'HASH') { |
|
$output = '<p class="LC_warning">'. |
|
&mt('Not all requested personnel could be included.').'<ul>'; |
|
foreach my $item (@{$disallowed}) { |
|
$output .= '<li>'.$disallowmsg->{$item}.'</li>'; |
|
} |
|
$output .= '</ul></p>'; |
|
} |
|
} |
|
} |
|
$output .= '<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title(&mt('Owner')). |
&Apache::lonhtmlcommon::row_title(&mt('Owner')). |
'<table class="LC_innerpickbox"><tr>'. |
'<table class="LC_innerpickbox"><tr>'. |
'<th>'.&mt('Name').'</th>'. |
'<th>'.&mt('Name').'</th>'. |
Line 1693 function validateForm() {
|
Line 2043 function validateForm() {
|
</script> |
</script> |
|
|
ENDJS |
ENDJS |
|
my $title = &mt('Brief Course Description'); |
|
if ($crstype eq 'community') { |
|
$title = &mt('Brief Community Description'); |
|
} |
my $output .= $js_validate."\n".'<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
my $output .= $js_validate."\n".'<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title('Course Description'). |
&Apache::lonhtmlcommon::row_headline(). |
|
'<h3>'.$title.'</h3>'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
&Apache::lonhtmlcommon::row_title(&mt('Description')). |
'<input type="text" size="40" name="cdescr" />'; |
'<input type="text" size="40" name="cdescr" />'; |
my ($home_server_pick,$numlib) = |
my ($home_server_pick,$numlib) = |
&Apache::loncommon::home_server_form_item($dom,'chome', |
&Apache::loncommon::home_server_form_item($dom,'chome', |
Line 1705 ENDJS
|
Line 2061 ENDJS
|
&Apache::lonhtmlcommon::row_title(&mt('Home Server for Course')); |
&Apache::lonhtmlcommon::row_title(&mt('Home Server for Course')); |
} |
} |
$output .= $home_server_pick. |
$output .= $home_server_pick. |
|
&Apache::lonhtmlcommon::row_closure(). |
|
&Apache::lonhtmlcommon::row_headline(). |
|
'<h3>'.&mt('Clone content and settings from an existing course?').'</h3>'. |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::end_pick_box().'</div>'. |
&clone_form($dom,$formname,$crstype). |
'<div>'.&clone_form($dom,$formname,$crstype).'</div>'."\n"; |
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n"; |
return $output; |
return $output; |
} |
} |
|
|
Line 1721 sub clone_form {
|
Line 2080 sub clone_form {
|
&Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type); |
&Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type); |
my %lt = &clone_text(); |
my %lt = &clone_text(); |
my $output .= |
my $output .= |
&Apache::lonhtmlcommon::start_pick_box(). |
|
&Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'. |
&Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'. |
'<input type="text" size="25" name="clonecrs" value="" onfocus="this.blur();'. |
'<input type="text" size="25" name="clonecrs" value="" />'. |
'opencrsbrowser('."'$formname','clonecrs','clonedom','','','','$type'".');" />'. |
|
'</label>'.&Apache::lonhtmlcommon::row_closure(1).'<label>'. |
'</label>'.&Apache::lonhtmlcommon::row_closure(1).'<label>'. |
&Apache::lonhtmlcommon::row_title($lt{'dmn'}).'</label>'. |
&Apache::lonhtmlcommon::row_title($lt{'dmn'}).'</label>'. |
$cloneform.'</label>'.&Apache::lonhtmlcommon::row_closure(). |
$cloneform.'</label>'.&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'. |
&Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'. |
'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}. |
'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}. |
'</label><br /><label>'. |
'</label><br /><label>'. |
Line 1736 sub clone_form {
|
Line 2093 sub clone_form {
|
'<input type="radio" name="datemode" value="shift" checked="checked" /> '. |
'<input type="radio" name="datemode" value="shift" checked="checked" /> '. |
$lt{'shd'}.'</label>'. |
$lt{'shd'}.'</label>'. |
'<input type="text" size="5" name="dateshift" value="365" />'. |
'<input type="text" size="5" name="dateshift" value="365" />'. |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1); |
&Apache::lonhtmlcommon::end_pick_box(); |
|
return $output; |
return $output; |
} |
} |
|
|
Line 2077 sub print_request_outcome {
|
Line 2433 sub print_request_outcome {
|
accessend => $accessend, |
accessend => $accessend, |
personnel => \%personnel, |
personnel => \%personnel, |
}; |
}; |
my @inststatuses; |
my (@inststatuses,$storeresult,$creationresult); |
my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig); |
my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig); |
if ($val eq '') { |
if ($val eq '') { |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
Line 2089 sub print_request_outcome {
|
Line 2445 sub print_request_outcome {
|
} else { |
} else { |
$output = &mt('Unrecognized course type: [_1]',$crstype); |
$output = &mt('Unrecognized course type: [_1]',$crstype); |
} |
} |
|
$storeresult = 'notpermitted'; |
} else { |
} else { |
my ($disposition,$message,$reqstatus); |
my ($disposition,$message,$reqstatus); |
my %reqhash = ( |
my %reqhash = ( |
Line 2139 sub print_request_outcome {
|
Line 2496 sub print_request_outcome {
|
if ($message) { |
if ($message) { |
$output .= '<div class="LC_warning">'.$message.'</div>'; |
$output .= '<div class="LC_warning">'.$message.'</div>'; |
} |
} |
|
$storeresult = 'rejected'; |
} elsif ($disposition eq 'process') { |
} elsif ($disposition eq 'process') { |
my %domdefs = &Apache::lonnet::get_domain_defaults($dom); |
my %domdefs = &Apache::lonnet::get_domain_defaults($dom); |
my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles); |
my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles); |
Line 2156 sub print_request_outcome {
|
Line 2514 sub print_request_outcome {
|
if ($result eq 'created') { |
if ($result eq 'created') { |
$disposition = 'created'; |
$disposition = 'created'; |
$reqstatus = 'created'; |
$reqstatus = 'created'; |
$output = &mt('Your course request has been processed and the course has been created.'). |
my $role_result = &update_requestors_roles($dom,$cnum,$crstype,$details, |
'<br />'. |
\%longroles); |
&mt('You will need to logout and log-in again to be able to select a role in the course.'); |
$output = '<p>'.&mt('Your course request has been processed and the course has been created.'). |
|
'<br />'.$role_result.'</p>'; |
|
$creationresult = 'created'; |
} else { |
} else { |
$output = '<span class="LC_error">'. |
$output = '<span class="LC_error">'. |
&mt('An error occurred when processing your course request.'). |
&mt('An error occurred when processing your course request.'). |
'<br />'. |
'<br />'. |
&mt('You may want to review the request details and submit the request again.'). |
&mt('You may want to review the request details and submit the request again.'). |
'</span>'; |
'</span>'; |
|
$creationresult = 'error'; |
} |
} |
} else { |
} else { |
my $requestid = $cnum.'_'.$disposition; |
my $requestid = $cnum.'_'.$disposition; |
Line 2206 sub print_request_outcome {
|
Line 2567 sub print_request_outcome {
|
} |
} |
} |
} |
} |
} |
my ($storeresult,$statusresult); |
my ($statusresult); |
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
$storeresult = &Apache::lonnet::store_userdata(\%reqhash,$requestkey, |
$storeresult = &Apache::lonnet::store_userdata(\%reqhash,$requestkey, |
'courserequests'); |
'courserequests'); |
Line 2214 sub print_request_outcome {
|
Line 2575 sub print_request_outcome {
|
my %status = ( |
my %status = ( |
'status:'.$dom.':'.$cnum => $reqstatus, |
'status:'.$dom.':'.$cnum => $reqstatus, |
); |
); |
$statusresult = &Apache::lonnet::put('courserequests',\%status); |
$statusresult = &Apache::lonnet::put('courserequests',\%status); |
} |
} |
} else { |
} else { |
$storeresult = 'error: invalid requestkey format'; |
$storeresult = 'error: invalid requestkey format'; |
Line 2223 sub print_request_outcome {
|
Line 2584 sub print_request_outcome {
|
$output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the details of your request: [_1].',$storeresult).'</span><br />'; |
$output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the details of your request: [_1].',$storeresult).'</span><br />'; |
&Apache::lonnet::logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult"); |
&Apache::lonnet::logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult"); |
} elsif ($statusresult ne 'ok') { |
} elsif ($statusresult ne 'ok') { |
$output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the status of your request: [_1].',$statusresult).'</span><br />'; |
$output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the status of your request: [_1].',$statusresult).'</span><br />'; |
&Apache::lonnet::logthis("Error saving course request status for $requestkey (for $env{'user.name'}:$env{'user.domain'}) - $statusresult"); |
&Apache::lonnet::logthis("Error saving course request status for $requestkey (for $env{'user.name'}:$env{'user.domain'}) - $statusresult"); |
} |
} |
if ($modified && $queued && $storeresult eq 'ok') { |
if ($modified && $queued && $storeresult eq 'ok') { |
Line 2234 sub print_request_outcome {
|
Line 2595 sub print_request_outcome {
|
$output .= '<span class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>'; |
$output .= '<span class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>'; |
} |
} |
} |
} |
|
if ($creationresult ne '') { |
|
return ($creationresult,$output); |
|
} else { |
|
return ($storeresult,$output); |
|
} |
|
} |
|
|
|
sub update_requestors_roles { |
|
my ($dom,$cnum,$crstype,$details,$longroles) = @_; |
|
my $now = time; |
|
my ($active,$future,$numactive,$numfuture,$output); |
|
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'); |
|
} |
|
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\//) { |
|
$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; |
|
} |
|
$active .= '</a></li>'; |
|
$numactive ++; |
|
} else { |
|
$future .= '<li>'.$showrole; |
|
if ($usec ne '') { |
|
$future .= ' - '.&mt('section:').' '.$usec; |
|
} |
|
$future .= '</li>'; |
|
$numfuture ++; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($active) { |
|
if ($numactive == 1) { |
|
$output = &mt('Use the following link to enter the course:'); |
|
} else { |
|
$output = &mt('Use the following links to your new roles to enter the course:'); |
|
} |
|
$output .= ' <ul>'.$active.'</ul><br />'; |
|
} |
|
if ($future) { |
|
$output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'<a href="/adm/roles">','</a>',&Apache::lonlocal::locallocaltime($details->{'accessstart'})). |
|
' <ul>'.$future.'</ul>'; |
|
} |
return $output; |
return $output; |
} |
} |
|
|