version 1.11, 2009/08/12 14:24:35
|
version 1.66, 2013/03/01 04:48:59
|
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 form_elements() |
|
|
|
=item onload_action() |
|
|
|
=item print_main_menu() |
|
|
|
=item request_administration() |
|
|
|
=item close_popup_form() |
|
|
|
=item get_instcode() |
|
|
|
=item print_request_form() |
|
|
|
=item print_enrollment_menu() |
|
|
|
=item show_invalid_crosslists() |
|
|
|
=item inst_section_selector() |
|
|
|
=item date_setting_table() |
|
|
|
=item print_personnel_menu() |
|
|
|
=item print_request_status() |
|
|
|
=item print_request_logs() |
|
|
|
=item print_review() |
|
|
|
=item dates_from_form() |
|
|
|
=item courseinfo_form() |
|
|
|
=item clone_form() |
|
|
|
=item clone_text() |
|
|
|
=item coursecode_form() |
|
|
|
=item get_course_dom() |
|
|
|
=item display_navbuttons() |
|
|
|
=item print_request_outcome() |
|
|
|
=item check_autolimit() |
|
|
|
=item retrieve_settings() |
|
|
|
=item get_request_settings() |
|
|
|
=item extract_instcode() |
|
|
|
=item generate_date_items() |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 56 use Apache::lonnet;
|
Line 116 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 { |
my ($r) = @_; |
my ($r) = @_; |
|
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
if ($r->header_only) { |
if ($r->header_only) { |
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
|
return OK; |
return OK; |
} |
} |
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
|
|
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['action','showdom','cnum','state','crstype','queue']); |
&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 (%states,%stored); |
my %stored; |
my ($jscript,$uname,$udom,$result,$warning,$showcredits,$instcredits); |
my $jscript; |
my %domdefs = &Apache::lonnet::get_domain_defaults($dom); |
if ((defined($state)) && (defined($action))) { |
if ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'}) { |
my %elements = &form_elements($dom); |
$showcredits = 1; |
if (($action eq 'view') && ($state ne 'crstype')) { |
|
if (defined($env{'form.request_id'})) { |
|
%stored = &retrieve_settings($dom,$env{'form.request_id'}); |
|
} |
|
} |
|
my $elementsref = {}; |
|
if (ref($elements{$action}) eq 'HASH') { |
|
if (ref($elements{$action}{$state}) eq 'HASH') { |
|
$elementsref = $elements{$action}{$state}; |
|
} |
|
} |
|
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored); |
|
} |
} |
|
|
if ($state eq 'personnel') { |
$states{'display'} = ['details']; |
$jscript .= "\n".&Apache::loncommon::userbrowser_javascript(); |
$states{'view'} = ['pick_request','details','cancel','removal']; |
} |
$states{'log'} = ['display']; |
|
|
my $loaditems = &onload_action($action,$state); |
|
|
|
my %states; |
|
$states{'view'} = ['pick_request','details','review','process']; |
|
$states{'log'} = ['filter','display']; |
|
$states{'new'} = ['courseinfo','enrollment','personnel','review','process']; |
$states{'new'} = ['courseinfo','enrollment','personnel','review','process']; |
|
|
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) { |
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) { |
unless ($env{'form.state'} eq 'crstype') { |
unless ($env{'form.state'} eq 'crstype') { |
unshift (@{$states{'new'}},'codepick'); |
unshift(@{$states{'new'}},'codepick'); |
|
} |
|
} |
|
|
|
if (($action eq 'new') && (&Apache::loncoursequeueadmin::author_prompt())) { |
|
if (ref($states{$action}) eq 'ARRAY') { |
|
push(@{$states{$action}},'reqauthor'); |
} |
} |
} |
} |
|
|
Line 113 sub handler {
|
Line 163 sub handler {
|
} |
} |
} |
} |
|
|
|
my @invalidcrosslist; |
my %trail = ( |
my %trail = ( |
crstype => 'Course Request Action', |
crstype => 'Request Action', |
codepick => 'Category', |
codepick => 'Category', |
courseinfo => 'Description', |
courseinfo => 'Description', |
enrollment => 'Enrollment', |
enrollment => 'Access Dates', |
personnel => 'Personnel', |
personnel => 'Personnel', |
review => 'Review', |
review => 'Review', |
process => 'Result', |
process => 'Result', |
|
reqauthor => 'Authoring Space Result', |
pick_request => 'Display Summary', |
pick_request => 'Display Summary', |
|
details => 'Request Details', |
|
cancel => 'Cancel Request', |
|
removal => 'Outcome', |
|
display => 'Request Logs', |
); |
); |
|
|
my $page = 0; |
if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) { |
my $crumb; |
$trail{'enrollment'} = 'Enrollment'; |
if (defined($action)) { |
} |
my $done = 0; |
|
my $i=0; |
my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) = |
if (ref($states{$action}) eq 'ARRAY') { |
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail); |
while ($i<@{$states{$action}} && !$done) { |
if ($action eq 'display') { |
if ($states{$action}[$i] eq $state) { |
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { |
$page = $i; |
if ($env{'form.cnum'} ne '') { |
$done = 1; |
my $cnum = $env{'form.cnum'}; |
} |
my $queue = $env{'form.queue'}; |
$i++; |
my $reqkey = $cnum.'_'.$queue; |
} |
my $namespace = 'courserequestqueue'; |
} |
my $domconfig = &Apache::lonnet::get_domainconfiguser($dom); |
for (my $i=0; $i<@{$states{$action}}; $i++) { |
my %queued = |
if ($state eq $states{$action}[$i]) { |
&Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig); |
&Apache::lonhtmlcommon::add_breadcrumb( |
if (ref($queued{$reqkey}) eq 'HASH') { |
{text=>"$trail{$state}"}); |
$uname = $queued{$reqkey}{'ownername'}; |
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
$udom = $queued{$reqkey}{'ownerdom'}; |
last; |
if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) { |
} else { |
$result = &retrieve_settings($dom,$cnum,$udom,$uname); |
if (($state eq 'process') && ($i > 0)) { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb( |
if ($env{'form.crstype'} eq 'community') { |
{href=>"javascript:backPage(document.requestcrs,'$states{$action}[0]')", |
$warning = &mt('Invalid username or domain for community requestor'); |
text=>"$trail{$states{$action}[$i]}"}); |
} else { |
|
$warning = &mt('Invalid username or domain for course requestor'); |
|
} |
|
} |
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb( |
if ($env{'form.crstype'} eq 'community') { |
{href=>"javascript:backPage(document.requestcrs,'$states{$action}[$i]')", |
$warning = &mt('No information was found for this community request.'); |
text=>"$trail{$states{$action}[$i]}"}); |
} else { |
|
$warning = &mt('No information was found for this course request.'); |
|
} |
} |
} |
|
} else { |
|
$warning = &mt('No course request ID provided.'); |
|
} |
|
} else { |
|
if ($env{'form.crstype'} eq 'any') { |
|
$warning = &mt('You do not have rights to view course or community request information.'); |
|
} elsif ($env{'form.crstype'} eq 'community') { |
|
$warning = &mt('You do not have rights to view community request information.'); |
|
} else { |
|
$warning = &mt('You do not have rights to view course request information.'); |
|
} |
|
} |
|
} elsif ((defined($state)) && (defined($action))) { |
|
if (($action eq 'view') && ($state eq 'details')) { |
|
if ((defined($env{'form.showdom'})) && (defined($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}, my $rest) = |
|
&Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode); |
|
} |
|
unless ($codechk{$i} eq 'valid') { |
|
$env{'form.crosslist_'.$i} = ''; |
|
push(@invalidcrosslist,$crosslistcode); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
(my $elements,$instcredits) = &form_elements($dom,$showcredits); |
|
my $elementsref = {}; |
|
if ((ref($elements) eq 'HASH') && (ref($elements->{$action}) eq 'HASH')) { |
|
if (ref($elements->{$action}{$state}) eq 'HASH') { |
|
$elementsref = $elements->{$action}{$state}; |
|
} |
|
} |
|
if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) { |
|
$env{'form.clonedom'} = $dom; |
|
} |
|
if ($state eq 'crstype') { |
|
$jscript = &mainmenu_javascript(); |
|
} else { |
|
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored); |
|
if ($state eq 'courseinfo') { |
|
$jscript .= &cloning_javascript(); |
} |
} |
} |
} |
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{text=>'Pick Action'}); |
|
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
|
} |
} |
|
|
my %can_request; |
if ($state eq 'personnel') { |
my $canreq = &check_can_request($dom,\%can_request); |
$jscript .= "\n".&Apache::loncommon::userbrowser_javascript(); |
|
} |
|
|
|
my $loaditems = &onload_action($action,$state); |
|
|
|
my (%can_request,%request_domains); |
|
my $canreq = |
|
&Apache::lonnet::check_can_request($dom,\%can_request,\%request_domains); |
if ($action eq 'new') { |
if ($action eq 'new') { |
if ($canreq) { |
if ($canreq) { |
if ($state eq 'crstype') { |
if ($state eq 'crstype') { |
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems, |
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems, |
$crumb); |
$crumb,\%request_domains); |
} 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,$description, |
|
$showcredits,$instcredits,\@invalidcrosslist); |
} |
} |
} else { |
} else { |
$r->print(&header('Course Requests').$crumb. |
$r->print(&header('Course/Community Requests').$crumb. |
'<div class="LC_warning">'. |
'<div class="LC_warning">'. |
&mt('You do not have privileges to request creation of courses.'). |
&mt('You do not have privileges to request creation of courses or communities.'). |
'</div>'.&Apache::loncommon::end_page()); |
'</div>'.&Apache::loncommon::end_page()); |
} |
} |
} 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,\%request_domains); |
|
} else { |
|
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
|
$loaditems,$crumb,'','','','',$showcredits); |
|
} |
|
} elsif ($action eq 'display') { |
|
if ($warning ne '') { |
|
my $args = { only_body => 1 }; |
|
$r->print(&header('Course/Community Requests','','' ,'',$args).$crumb. |
|
'<h3>'.&mt('Course/Community Request Details').'</h3>'. |
|
'<div class="LC_warning">'.$warning.'</div>'. |
|
&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); |
$loaditems,$crumb,'','','','',$showcredits,'','', |
|
$uname,$udom); |
} |
} |
} elsif ($action eq 'log') { |
} elsif ($action eq 'log') { |
&print_request_logs($jscript,$loaditems,$crumb); |
if ($state eq 'crstype') { |
|
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains); |
|
} else { |
|
$jscript .= <<ENDJS; |
|
|
|
function backPage(formname,prevstate) { |
|
formname.state.value = prevstate; |
|
formname.submit(); |
|
} |
|
|
|
function setPage(formname) { |
|
formname.page.value = '1'; |
|
return; |
|
} |
|
|
|
ENDJS |
|
&print_request_logs($r,$dom,$jscript,$loaditems,$crumb); |
|
} |
} else { |
} else { |
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb); |
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains); |
} |
} |
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 cloning_javascript { |
|
return <<"END"; |
|
function setCloneDisplay(courseForm) { |
|
if (courseForm.cloning.length > 1) { |
|
for (var i=0; i<courseForm.cloning.length; i++) { |
|
if (courseForm.cloning[i].checked) { |
|
if (courseForm.cloning[i].value == 1) { |
|
document.getElementById('cloneoptions').style.display="block";; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
END |
|
} |
|
|
|
sub get_breadcrumbs { |
|
my ($dom,$action,$state,$states,$trail) = @_; |
|
my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description); |
|
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,$description) = |
|
&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/Community Requests','Course_Requests'); |
|
last; |
|
} else { |
|
if (($$state eq 'process') || ($$state eq 'removal') || ($$state eq 'reqauthor')) { |
|
&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/Community Requests','Course_Requests'); |
|
} |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{text=>'Pick Action'}); |
|
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests'); |
|
} |
|
return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description); |
|
} |
|
|
sub header { |
sub header { |
my ($bodytitle,$jscript,$loaditems,$jsextra) = @_; |
my ($bodytitle,$jscript,$loaditems,$jsextra,$args) = @_; |
if ($jscript) { |
if ($jscript) { |
$jscript = '<script type="text/javascript">'."\n". |
$jscript = '<script type="text/javascript">'."\n". |
'// <![CDATA['."\n". |
'// <![CDATA['."\n". |
$jscript."\n".'// ]]>'."\n".'</script>'."\n"; |
$jscript."\n".'// ]]>'."\n".'</script>'."\n"; |
} |
} |
if ($loaditems) { |
if ($loaditems) { |
$loaditems = {'add_entries' => $loaditems,}; |
if (ref($args) eq 'HASH') { |
return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$loaditems); |
my %loadhash = ( |
} else { |
'add_entries' => $loaditems, |
return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra); |
); |
|
my %arghash = (%loadhash,%{$args}); |
|
$args = \%arghash; |
|
} else { |
|
$args = {'add_entries' => $loaditems,}; |
|
} |
} |
} |
|
return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$args); |
} |
} |
|
|
sub form_elements { |
sub form_elements { |
my ($dom) = @_; |
my ($dom,$showcredits) = @_; |
|
my $instcredits; |
my %elements = |
my %elements = |
( |
( |
new => { |
new => { |
crstype => { |
crstype => { |
crstype => 'selectbox', |
crstype => 'selectbox', |
action => 'selectbox', |
action => 'selectbox', |
|
origcnum => 'hidden', |
}, |
}, |
courseinfo => { |
courseinfo => { |
cdescr => 'text', |
cdescr => 'text', |
clonecourse => 'text', |
cloning => 'radio', |
clonedomain => 'selectbox', |
clonecrs => 'text', |
|
clonedom => 'selectbox', |
datemode => 'radio', |
datemode => 'radio', |
dateshift => 'text', |
dateshift => 'text', |
}, |
}, |
enrollment => { |
enrollment => { |
startaccess_month => 'selectbox', |
accessstart_month => 'selectbox', |
startaccess_hour => 'selectbox', |
accessstart_hour => 'selectbox', |
endaccess_month => 'selectbox', |
accessend_month => 'selectbox', |
endaccess_hour => 'selectbox', |
accessend_hour => 'selectbox', |
startaccess_day => 'text', |
accessstart_day => 'text', |
startaccess_year => 'text', |
accessstart_year => 'text', |
startaccess_minute => 'text', |
accessstart_minute => 'text', |
startaccess_second => 'text', |
accessstart_second => 'text', |
endaccess_day => 'text', |
accessend_day => 'text', |
endaccess_year => 'text', |
accessend_year => 'text', |
endaccess_minute => 'text', |
accessend_minute => 'text', |
endaccess_second => 'text', |
accessend_second => 'text', |
no_end_date => 'checkbox', |
no_end_date => 'checkbox', |
}, |
}, |
personnel => { |
personnel => { |
persontotal => 'hidden', |
|
addperson => 'checkbox', |
addperson => 'checkbox', |
}, |
}, |
|
review => { |
|
cnum => 'hidden', |
|
}, |
}, |
}, |
view => { |
view => { |
crstype => { |
crstype => { |
Line 252 sub form_elements {
|
Line 547 sub form_elements {
|
}, |
}, |
}, |
}, |
); |
); |
|
my %servers = &Apache::lonnet::get_servers($dom,'library'); |
|
my $numlib = keys(%servers); |
|
if ($numlib > 1) { |
|
$elements{'new'}{'courseinfo'}{'chome'} = 'selectbox'; |
|
} else { |
|
$elements{'new'}{'courseinfo'}{'chome'} = 'hidden'; |
|
} |
my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem); |
my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem); |
&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); |
Line 267 sub form_elements {
|
Line 569 sub form_elements {
|
} |
} |
if (&Apache::lonnet::auto_run('',$dom)) { |
if (&Apache::lonnet::auto_run('',$dom)) { |
my %extras = ( |
my %extras = ( |
sectotal => 'hidden', |
enrollstart_month => 'selectbox', |
startenroll_month => 'selectbox', |
enrollstart_hour => 'selectbox', |
startenroll_hour => 'selectbox', |
enrollend_month => 'selectbox', |
endenroll_month => 'selectbox', |
enrollend_hour => 'selectbox', |
endenroll_hour => 'selectbox', |
enrollstart_day => 'text', |
startenroll_day => 'text', |
enrollstart_year => 'text', |
startenroll_year => 'text', |
enrollstart_minute => 'text', |
startenroll_minute => 'text', |
enrollstart_second => 'text', |
startenroll_second => 'text', |
enrollend_day => 'text', |
endenroll_day => 'text', |
enrollend_year => 'text', |
endenroll_year => 'text', |
enrollend_minute => 'text', |
endenroll_minute => 'text', |
enrollend_second => 'text', |
endenroll_second => 'text', |
|
crosslisttotal => 'hidden', |
|
addcrosslist => 'checkbox', |
addcrosslist => 'checkbox', |
autoadds => 'radio', |
autoadds => 'radio', |
autodrops => 'radio', |
autodrops => 'radio', |
); |
); |
if ($env{'form.sectotal'} > 0) { |
my ($instcode,$titlescount) = &get_instcode($dom); |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
if ($instcode) { |
$extras{'sec_'.$i} = 'checkbox', |
my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode); |
$extras{'secnum_'.$i} = 'text', |
if (@sections) { |
$extras{'loncapasec_'.$i} = 'checkbox', |
$extras{'sectotal'} = 'hidden'; |
|
if ($env{'form.sectotal'} > 0) { |
|
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
|
$extras{'sec_'.$i} = 'radio'; |
|
$extras{'secnum_'.$i} = 'text'; |
|
$extras{'loncapasec_'.$i} = 'text'; |
|
} |
|
} |
|
} else { |
|
$extras{'addsection'} = 'checkbox'; |
|
my $sectotal = $env{'form.sectotal'}; |
|
if ($env{'form.addsection'}) { |
|
$sectotal ++; |
|
} |
|
for (my $i=0; $i<$sectotal; $i++) { |
|
$extras{'sec_'.$i} = 'checkbox'; |
|
$extras{'secnum_'.$i} = 'text', |
|
$extras{'loncapasec_'.$i} = 'text', |
|
} |
|
} |
|
(my $outcome,my $desc,$instcredits) = |
|
&Apache::lonnet::auto_validate_instcode(undef,$dom,$instcode); |
|
if ($showcredits && $instcredits eq '') { |
|
$extras{'coursecredits'} = 'text'; |
|
} |
|
} elsif ($env{'form.crstype'} eq 'unofficial') { |
|
if ($showcredits) { |
|
$extras{'coursecredits'} = 'text'; |
} |
} |
} |
} |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
if (!defined($crosslisttotal)) { |
if ($env{'form.addcrosslist'}) { |
|
$crosslisttotal ++; |
|
} |
|
if (!$crosslisttotal) { |
$crosslisttotal = 1; |
$crosslisttotal = 1; |
} |
} |
if ($crosslisttotal > 0) { |
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'; |
} |
} |
if (@codetitles > 0) { |
if (@codetitles > 0) { |
foreach my $item (@codetitles) { |
foreach my $item (@codetitles) { |
$extras{'crosslist_'.$i.'_'.$item} = 'selectbox'; |
$extras{'crosslist_'.$i.'_'.$item} = 'selectbox'; |
|
} |
|
} |
} |
$extras{'crosslist_'.$i} = 'checkbox'; |
|
$extras{'crosslist_'.$i.'_instsec'} = 'text', |
|
$extras{'crosslist_'.$i.'_lcsec'} = 'text', |
|
} |
} |
|
$extras{'crosslist_'.$i} = 'checkbox'; |
|
$extras{'crosslist_'.$i.'_instsec'} = 'text', |
|
$extras{'crosslist_'.$i.'_lcsec'} = 'text', |
} |
} |
my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras); |
my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras); |
%{$elements{'new'}{'enrollment'}} = %mergedhash; |
%{$elements{'new'}{'enrollment'}} = %mergedhash; |
} |
} |
my %people; |
my %people; |
my $persontotal = $env{'form.persontotal'}; |
my $persontotal = $env{'form.persontotal'}; |
if (!defined($persontotal)) { |
if ($env{'form.addperson'}) { |
|
$persontotal ++; |
|
} |
|
if ((!defined($persontotal)) || (!$persontotal)) { |
$persontotal = 1; |
$persontotal = 1; |
} |
} |
for (my $i=0; $i<$persontotal; $i++) { |
for (my $i=0; $i<$persontotal; $i++) { |
$people{'person_'.$i.'_uname'} = 'text', |
$people{'person_'.$i.'_uname'} = 'text', |
$people{'person_'.$i.'_dom'} = 'selectbox', |
$people{'person_'.$i.'_dom'} = 'selectbox', |
$people{'person_'.$i.'_hidedom'} = 'hidden', |
$people{'person_'.$i.'_hidedom'} = 'hidden', |
$people{'person_'.$i.'_first'} = 'text', |
$people{'person_'.$i.'_firstname'} = 'text', |
$people{'person_'.$i.'_last'} = 'text', |
$people{'person_'.$i.'_lastname'} = 'text', |
$people{'person_'.$i.'_email'} = 'text', |
$people{'person_'.$i.'_emailaddr'} = 'text', |
$people{'person_'.$i.'_role'} = 'selectbox', |
$people{'person_'.$i.'_role'} = 'selectbox', |
$people{'person_'.$i.'_sec'} = 'selectbox', |
$people{'person_'.$i.'_sec'} = 'selectbox', |
$people{'person_'.$i.'_newsec'} = 'text', |
$people{'person_'.$i.'_newsec'} = 'text', |
$people{'person_'.$i.'_sections'} = 'hidden', |
|
} |
} |
my %personnelhash = (%{$elements{'new'}{'personnel'}},%people); |
my %personnelhash = (%{$elements{'new'}{'personnel'}},%people); |
%{$elements{'new'}{'personnel'}} = %personnelhash; |
%{$elements{'new'}{'personnel'}} = %personnelhash; |
return %elements; |
return (\%elements,$instcredits);; |
} |
} |
|
|
sub onload_action { |
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)'; |
return \%loaditems; |
} else { |
} |
$loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs);'; |
|
} |
sub check_can_request { |
if ($state eq 'courseinfo') { |
my ($dom,$can_request) = @_; |
$loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);'; |
my $canreq = 0; |
|
my ($types,$typename) = &course_types(); |
|
if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) { |
|
foreach my $type (@{$types}) { |
|
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
|
$env{'user.domain'}, |
|
$type,undef,'requestcourses')) { |
|
$canreq ++; |
|
if ($dom eq $env{'user.domain'}) { |
|
$can_request->{$type} = 1; |
|
} |
|
} |
|
if ($env{'environment.reqcrsotherdom.'.$type} ne '') { |
|
my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type}); |
|
if (@curr > 0) { |
|
$canreq ++; |
|
unless ($dom eq $env{'user.domain'}) { |
|
if (grep(/^\Q$dom\E$/,@curr)) { |
|
$can_request->{$type} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
} |
} |
return $canreq; |
return \%loaditems; |
} |
|
|
|
sub course_types { |
|
my @types = ('official','unofficial','community'); |
|
my %typename = ( |
|
official => 'Official course', |
|
unofficial => 'Unofficial course', |
|
community => 'Community', |
|
); |
|
return (\@types,\%typename); |
|
} |
} |
|
|
|
|
sub print_main_menu { |
sub print_main_menu { |
my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_; |
my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb,$request_domains) = @_; |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &Apache::loncommon::course_types(); |
my $onchange; |
my $onchange = 'this.form.submit()'; |
unless ($env{'form.interface'} eq 'textual') { |
|
$onchange = 1; |
|
} |
|
|
|
my $nextstate_setter = "\n"; |
my $nextstate_setter = "\n"; |
if (ref($states) eq 'HASH') { |
if (ref($states) eq 'HASH') { |
foreach my $key (keys(%{$states})) { |
foreach my $key (keys(%{$states})) { |
Line 410 sub print_main_menu {
|
Line 702 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 429 function check_can_request(crschoice,act
|
Line 723 function check_can_request(crschoice,act
|
var unofficial = ''; |
var unofficial = ''; |
var community = ''; |
var community = ''; |
END |
END |
|
if (ref($can_request) eq 'HASH') { |
foreach my $item (keys(%{$can_request})) { |
foreach my $item (keys(%{$can_request})) { |
$js .= " |
$js .= " |
$item = 1; |
$item = 1; |
"; |
"; |
|
} |
} |
} |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
official => 'You are not permitted to request creation of an official course in this domain.', |
official => 'You are not permitted to request creation of an official course in this domain.', |
unofficial => 'You are not permitted to request creation of an unofficial course in this domain.', |
unofficial => 'You are not permitted to request creation of an unofficial course in this domain.', |
community => 'You are not permitted to request creation of a community this domain.', |
community => 'You are not permitted to request creation of a community this domain.', |
all => 'You must choose a specific course type when making a new course request.\\nAll types is not allowed.', |
all => 'You must choose a specific course type when making a new course request.\\n\"All types\" is not allowed.', |
); |
); |
$js .= <<END; |
$js .= <<END; |
if (crschoice == 'official') { |
if (crschoice == 'official') { |
Line 469 END
|
Line 764 END
|
} |
} |
return true; |
return true; |
} |
} |
|
|
END |
END |
|
my ($pagetitle,$pageinfo,$domaintitle); |
$r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb. |
if (ref($can_request) eq 'HASH') { |
'<div>'. |
if (($can_request->{'official'}) || ($can_request->{'unofficial'})) { |
'<form name="domforcourse" method="post" action="/adm/requestcourse">'. |
if ($can_request->{'community'}) { |
|
$pagetitle = 'Course/Community Requests'; |
|
$pageinfo = &mt('Request creation of a new course or community, or review your pending requests.'); |
|
$domaintitle = &mt('Course/Community Domain'); |
|
} else { |
|
$pagetitle = 'Course Requests'; |
|
$pageinfo = &mt('Request creation of a new course, or review your pending course requests.'); |
|
$domaintitle = &mt('Course Domain'); |
|
} |
|
} elsif ($can_request->{'community'}) { |
|
$pagetitle = 'Community Requests'; |
|
$pageinfo = &mt('Request creation of a new course, or review your pending requests.'); |
|
$domaintitle = &mt('Community Domain'); |
|
} else { |
|
$pagetitle = 'Course/Community Requests'; |
|
$pageinfo = &mt('You do not have rights to request creation of courses in this domain; please choose a different domain.'); |
|
$domaintitle = &mt('Course/Community Domain'); |
|
} |
|
} |
|
my @incdoms; |
|
if (ref($request_domains) eq 'HASH') { |
|
foreach my $item (keys(%{$request_domains})) { |
|
if (ref($request_domains->{$item}) eq 'ARRAY') { |
|
foreach my $possdom (@{$request_domains->{$item}}) { |
|
unless(grep(/^\Q$possdom\E$/,@incdoms)) { |
|
push(@incdoms,$possdom); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
$r->print(&header($pagetitle,$js.$jscript,$loaditems).$crumb. |
|
'<p>'.$pageinfo.'</p>'. |
|
'<div>'. |
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title('Course Domain'). |
&Apache::lonhtmlcommon::row_title($domaintitle). |
&Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange)); |
'<form name="domforcourse" method="post" action="/adm/requestcourse">'. |
|
&Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange,\@incdoms)); |
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). |
unless ((ref($can_request) eq 'HASH') && (keys(%{$can_request}) > 0)) { |
&Apache::lonhtmlcommon::end_pick_box().'</form></div>'); |
$r->print(&Apache::lonhtmlcommon::row_closure(1)."\n". |
|
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n". |
|
&Apache::loncommon::end_page()); |
|
return; |
|
} |
|
$r->print('</form>'.&Apache::lonhtmlcommon::row_closure()); |
my $formname = 'requestcrs'; |
my $formname = 'requestcrs'; |
my $nexttext = &mt('Next'); |
my $nexttext = &mt('Next'); |
$r->print('<div><form name="'.$formname.'" method="post" action="/adm/requestcourse">'. |
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Action')).' |
&Apache::lonhtmlcommon::start_pick_box(). |
<form name="mainmenu_action" method="post" action=""> |
&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(). |
&Apache::lonhtmlcommon::row_title('Course Type').' |
&Apache::lonhtmlcommon::row_title(&mt('Type')).' |
<select size="1" name="crstype"> |
<form name="mainmenu_coursetype" method="post" action=""> |
<option value="any">'.&mt('All types').'</option>'); |
<select size="1" name="crstype">'); |
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) { |
if (ref($can_request) eq 'HASH') { |
foreach my $type (@{$types}) { |
if (keys(%{$can_request}) > 1) { |
my $selected = ''; |
$r->print(' <option value="any">'.&mt('All types').'</option>'); |
if ($type eq 'official') { |
} |
$selected = ' selected="selected"'; |
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) { |
} |
foreach my $type (@{$types}) { |
$r->print('<option value="'.$type.'"'.$selected.'>'.$typename->{$type}. |
next unless($can_request->{$type}); |
'</option>'."\n"); |
my $selected = ''; |
} |
if ($env{'form.crstype'} eq '') { |
} |
if ($type eq 'official') { |
$r->print('</select> |
$selected = ' selected="selected"'; |
<input type="hidden" name="state" value="crstype" />'. |
} |
&Apache::lonhtmlcommon::row_closure(1). |
} else { |
&Apache::lonhtmlcommon::end_pick_box().'<br /> |
if ($type eq $env{'form.crstype'}) { |
<input type="button" name="next" value="'.$nexttext.'" onclick="javascript:nextPage(document.'.$formname.')" /> |
$selected = ' selected="selected"'; |
</form></div>'); |
} |
|
} |
|
$r->print('<option value="'.$type.'"'.$selected.'>'.&mt($typename->{$type}). |
|
'</option>'."\n"); |
|
} |
|
} |
|
} |
|
$r->print('</select></form>'."\n". |
|
&Apache::lonhtmlcommon::row_closure(1)."\n". |
|
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n". |
|
'<div><form name="'.$formname.'" method="post" action="/adm/requestcourse">'."\n". |
|
'<input type="hidden" name="state" value="crstype" />'."\n". |
|
'<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) = @_; |
my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb, |
|
$newinstcode,$codechk,$checkedcode,$description,$showcredits, |
|
$instcredits,$invalidcrosslist,$uname,$udom) = @_; |
my $js; |
my $js; |
if (($action eq 'new') || ($action eq 'view')) { |
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) { |
$js = <<END; |
$js = <<END; |
|
|
function nextPage(formname,nextstate) { |
function nextPage(formname,nextstate) { |
formname.state.value= nextstate; |
formname.state.value= nextstate; |
formname.submit(); |
formname.submit(); |
} |
} |
|
|
|
END |
|
} |
|
if (($action eq 'new') || ($action eq 'view')) { |
|
$js .= <<END; |
|
|
function backPage(formname,prevstate) { |
function backPage(formname,prevstate) { |
formname.state.value = prevstate; |
formname.state.value = prevstate; |
formname.submit(); |
formname.submit(); |
Line 539 END
|
Line 894 END
|
} |
} |
if ($action eq 'new') { |
if ($action eq 'new') { |
my $jsextra; |
my $jsextra; |
unless (($state eq 'review') || ($state eq 'process')) { |
if (($state eq 'courseinfo') || ($state eq 'codepick')) { |
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); |
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); |
|
} elsif ($state eq 'enrollment') { |
|
if (($env{'form.crstype'} eq 'official') && |
|
(&Apache::lonnet::auto_run('',$dom))) { |
|
$js .= "\n".§ion_check_javascript()."\n".&enrollment_lcsec_js(); |
|
} |
|
} elsif ($state eq 'personnel') { |
|
$js .= "\n".§ion_check_javascript()."\n".&personnel_lcsec_js(); |
|
} |
|
my $title; |
|
if ($env{'form.crstype'} eq 'community') { |
|
$title = 'Request a community'; |
|
} else { |
|
$title = 'Request a course'; |
} |
} |
$r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb); |
$r->print(&header($title,$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,$description,$showcredits, |
|
$instcredits,$invalidcrosslist); |
} elsif ($action eq 'view') { |
} elsif ($action eq 'view') { |
$r->print(&header('Manage course requests',$js.$jscript,$loaditems).$crumb); |
my $jsextra; |
|
my $formname = 'requestcrs'; |
|
my $prev = $states->{$action}[$page-1]; |
|
my $next = $states->{$action}[$page+1]; |
if ($state eq 'pick_request') { |
if ($state eq 'pick_request') { |
$r->print(&print_request_status($dom)); |
$next = $states->{$action}[$page+1]; |
|
$jsextra = &viewrequest_javascript($formname,$next); |
|
} elsif ($state eq 'details') { |
|
$jsextra = &viewdetails_javascript($formname); |
|
|
|
} elsif ($state eq 'cancel') { |
|
$jsextra = &viewcancel_javascript($formname); |
|
} |
|
my $title; |
|
if ($env{'form.crstype'} eq 'community') { |
|
$title = 'Manage community requests'; |
|
} else { |
|
$title = 'Manage course requests'; |
} |
} |
} elsif ($action eq 'log') { |
$r->print(&header($title,$js.$jscript.$jsextra,$loaditems).$crumb); |
$r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb); |
my $form = '<form method="post" name="'.$formname.'" action="/adm/requestcourse" />'; |
|
if ($state eq 'pick_request') { |
|
my $title; |
|
if ($env{'form.crstype'} eq 'community') { |
|
$title = &mt('Pending community requests'); |
|
} elsif ($env{'form.crstype'} eq 'official') { |
|
$title = &mt('Pending requests for official courses'); |
|
} elsif ($env{'form.crstype'} eq 'unofficial') { |
|
$title = &mt('Pending requests for unofficial courses'); |
|
} else { |
|
$title = &mt('Pending course/community requests'); |
|
} |
|
$r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n". |
|
&print_request_status($dom,$action).'</form></div>'); |
|
} elsif ($state eq 'details') { |
|
my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk); |
|
my $origcnum = $env{'form.cnum'}; |
|
if ($origcnum eq '') { |
|
$origcnum = $env{'form.origcnum'}; |
|
} |
|
if ($env{'form.crstype'} eq 'official') { |
|
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
|
\%cat_order,\@code_order); |
|
} |
|
my $title; |
|
if ($env{'form.crstype'} eq 'community') { |
|
$title = &mt('Community Request Details'); |
|
} else { |
|
$title = &mt('Course Request Details'); |
|
} |
|
$r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n". |
|
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order, |
|
\@code_order,'','','','',$instcredits)."\n". |
|
'<input name="origcnum" value="'.$origcnum.'" type="hidden" />'."\n"); |
|
my @excluded = &get_excluded_elements($dom,$states,'new','review', |
|
$showcredits); |
|
push(@excluded,'origcnum'); |
|
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</div>'); |
|
my $other = 'modify'; |
|
my %navtxt = &Apache::lonlocal::texthash ( |
|
prev => 'Back', |
|
other => 'Modify Request', |
|
next => 'Cancel Request', |
|
); |
|
&display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, |
|
$navtxt{'next'},$state,$other,$navtxt{'other'}); |
|
$r->print('</form>'); |
|
} elsif ($state eq 'cancel') { |
|
my $title; |
|
if ($env{'form.crstype'} eq 'community') { |
|
$title = &mt('Cancel community request'); |
|
} else { |
|
$title = &mt('Cancel course request'); |
|
} |
|
my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'}); |
|
$r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n". |
|
$output); |
|
my @excluded = &get_excluded_elements($dom,$states,'view','cancel', |
|
$showcredits); |
|
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</div>'); |
|
my %navtxt = &Apache::lonlocal::texthash ( |
|
prev => 'Back', |
|
next => 'Confirm Cancellation', |
|
); |
|
if ($result eq 'ok') { |
|
&display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, |
|
$navtxt{'next'},$state); |
|
} else { |
|
&display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},undef, |
|
'',$state); |
|
} |
|
$r->print('</form>'); |
|
} elsif ($state eq 'removal') { |
|
my $cnum = $env{'form.origcnum'}; |
|
my $statuskey = 'status:'.$dom.':'.$cnum; |
|
my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey], |
|
$env{'user.domain'},$env{'user.name'}); |
|
my $currstatus = $userreqhash{$statuskey}; |
|
my ($result,$error); |
|
if (($currstatus eq 'approval') || ($currstatus eq 'pending')) { |
|
my %status = ( |
|
$statuskey => 'cancelled', |
|
); |
|
my $statusresult = &Apache::lonnet::put('courserequests',\%status); |
|
if ($statusresult eq 'ok') { |
|
my $delresult = |
|
&Apache::lonnet::del_dom('courserequestqueue', |
|
[$cnum.'_'.$currstatus],$dom); |
|
if ($delresult eq 'ok') { |
|
$result = 'ok'; |
|
} else { |
|
$error = &mt('An error occurred when updating the pending requests queue: [_1]',$delresult); |
|
} |
|
} else { |
|
$error = &mt("An error occurred when updating the status of this request in the requestor's records: [_1]",$statusresult); |
|
} |
|
} else { |
|
$error = &mt('The current status of this request could not be verified as pending approval/institutional action.'); |
|
} |
|
$r->print('<h3>'.&mt('Request Cancellation').'</h3><div>'."\n".$form."\n". |
|
'<input type="hidden" name="state" value="'.$state.'" />'."\n". |
|
'<input type="hidden" name="action" value="'.$action.'" />'."\n". |
|
'<input type="hidden" name="showdom" value="'.$dom.'" />'."\n". |
|
'<input type="hidden" name="orignum" value="'.$cnum.'" />'."\n"); |
|
if ($result eq 'ok') { |
|
if ($env{'form.crstype'} eq 'community') { |
|
$r->print(&mt('Your community request has been cancelled.')); |
|
} else { |
|
$r->print(&mt('Your course request has been cancelled.')); |
|
} |
|
} else { |
|
$r->print('<div class="LC_error">'. |
|
&mt('The request cancellation process was not complete.'). |
|
'<br />'.$error.'</div>'); |
|
} |
|
$r->print('</form>'); |
|
} |
|
} elsif ($action eq 'display') { |
|
my $formname = 'requestcrs'; |
|
my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk); |
|
if ($env{'form.crstype'} eq 'official') { |
|
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
|
\%cat_order,\@code_order); |
|
} |
|
my ($title,$header); |
|
if ($env{'form.crstype'} eq 'community') { |
|
$title = 'Community Request'; |
|
$header = &mt('Community Request'); |
|
} else { |
|
$title = 'Course Request'; |
|
$header = &mt('Course Request'); |
|
} |
|
$r->print(&header($title,'','','',{ 'only_body' => 1}). |
|
$crumb."\n".'<h3>'.$header.'</h3>'. |
|
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order, |
|
\@code_order,$uname,$udom,'','',$instcredits)."\n". |
|
'</div>'. |
|
&close_popup_form()); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
|
|
|
sub enrollment_lcsec_js { |
|
my %alerts = §ion_check_alerts(); |
|
my $secname = $alerts{'badsec'}; |
|
my $secnone = $alerts{'reserved'}; |
|
my $output = ' |
|
function validateEnrollSections(formname,nextstate) { |
|
var badsectotal = 0; |
|
var reservedtotal = 0; |
|
var secTest = ""; |
|
'; |
|
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
|
$output .= " |
|
var selSec = 0; |
|
for (var j=0; j<document.requestcrs.sec_".$i.".length; j++) { |
|
if (document.requestcrs.sec_".$i."[j].checked) { |
|
selSec = document.requestcrs.sec_".$i."[j].value; |
|
} |
|
if (selSec == 1) { |
|
secTest = validsection(document.requestcrs.loncapasec_".$i."); |
|
if (secTest == 'badsec') { |
|
badsectotal++; |
|
} |
|
if (secTest == 'reserved') { |
|
reservedtotal++; |
|
} |
|
} |
|
} |
|
"; |
|
} |
|
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) { |
|
$output .= " |
|
if (document.requestcrs.crosslist_".$i.".checked) { |
|
secTest = validsection(document.requestcrs.crosslist_".$i."_lcsec); |
|
if (secTest == 'badsec') { |
|
badsectotal++; |
|
} |
|
if (secTest == 'reserved') { |
|
reservedtotal++; |
|
} |
|
} |
|
"; |
|
} |
|
$output .= " |
|
if (badsectotal>0) { |
|
alert('$secname'); |
|
return false; |
|
} |
|
if (reservedtotal>0) { |
|
alert('$secnone'); |
|
return false; |
|
} |
|
formname.state.value= nextstate; |
|
formname.submit(); |
|
return; |
|
} |
|
"; |
|
return $output; |
|
} |
|
|
|
sub personnel_lcsec_js { |
|
my %alerts = §ion_check_alerts(); |
|
my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'}; |
|
my $secnone = $alerts{'reserved'}; |
|
my $output = ' |
|
function validatePersonnelSections(formname,nextstate) { |
|
var badsectotal = 0; |
|
var reservedtotal = 0; |
|
var secTest = ""; |
|
'; |
|
for (my $i=0; $i<$env{'form.persontotal'}; $i++) { |
|
$output .= " |
|
if (document.requestcrs.person_".$i."_uname.value != '') { |
|
secTest = validsection(document.requestcrs.person_".$i."_newsec,'1'); |
|
if (secTest == 'badsec') { |
|
badsectotal++; |
|
} |
|
if (secTest == 'reserved') { |
|
reservedtotal++; |
|
} |
|
} |
|
"; |
|
} |
|
$output .= " |
|
if (badsectotal > 0) { |
|
alert('$secname'); |
|
return false; |
|
} else { |
|
if (reservedtotal > 0) { |
|
alert('$secnone'); |
|
return false; |
|
} |
|
} |
|
formname.state.value = nextstate; |
|
formname.submit(); |
|
return; |
|
} |
|
"; |
|
return $output; |
|
} |
|
|
|
sub section_check_alerts { |
|
my %lt = |
|
&Apache::lonlocal::texthash( |
|
reserved => "You need to change one or more LON-CAPA section names - none is a reserved word in the system, and may not be used.", |
|
badsec => 'You need to change one or more LON-CAPA section names - names may only contain letters or numbers.', |
|
separate => 'Separate multiple sections with a comma.' |
|
); |
|
return %lt; |
|
} |
|
|
|
sub section_check_javascript { |
|
return <<"END"; |
|
function validsection(field,mult) { |
|
var str = field.value; |
|
var badsec=0; |
|
var reserved=0; |
|
if (window.RegExp) { |
|
var badsecnum=0; |
|
var reservednum=0; |
|
var pattern=/[^a-zA-Z0-9]/; |
|
str = str.replace(/(^\\s*)|(\\s*\$)/gi,""); |
|
str = str.replace(/[ ]{2,}/gi," "); |
|
if (mult == '1') { |
|
var sections = new Array(); |
|
sections = str.split(/\\s*[\\s,;:]\\s*/); |
|
var i; |
|
for (i=0; i<sections.length; i++) { |
|
if ((sections[i] != '') && (sections[i] != undefined) && (sections[i] != null)) { |
|
if (pattern.test(sections[i])) { |
|
badsecnum++; |
|
} else { |
|
if (sections[i] == 'none') { |
|
reservednum++; |
|
} |
|
} |
|
} |
|
} |
|
} else { |
|
if ((str != '') && (str != undefined) && (str != null)) { |
|
if (pattern.test(str)) { |
|
badsecnum++; |
|
} else { |
|
if (str == 'none') { |
|
reservednum++; |
|
} |
|
} |
|
} |
|
} |
|
if (badsecnum > 0) { |
|
return 'badsec'; |
|
} |
|
if (reservednum > 0) { |
|
return 'reserved'; |
|
} |
|
} |
|
return; |
|
} |
|
END |
|
} |
|
|
|
sub close_popup_form { |
|
my $close= &mt('Close Window'); |
|
return << "END"; |
|
<p><form name="displayreq" action="" method="post"> |
|
<input type="button" name="closeme" value="$close" onclick="javascript:self.close();" /> |
|
</form></p> |
|
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, |
|
$description,$showcredits,$instcredits,$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 567 sub print_request_form {
|
Line 1275 sub print_request_form {
|
next => 'Next', |
next => 'Next', |
); |
); |
$crstype = $env{'form.crstype'}; |
$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); |
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 'ok') { |
|
$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 'ok') { |
$message .= '<br />'.$codechk; |
|
} |
|
$message .= '</div>'; |
$prev = 'crstype'; |
$prev = 'crstype'; |
} |
} |
$r->print($message); |
$r->print($message); |
Line 620 sub print_request_form {
|
Line 1312 sub print_request_form {
|
$codepicker = &coursecode_form($dom,'instcode',\@codetitles, |
$codepicker = &coursecode_form($dom,'instcode',\@codetitles, |
\%cat_titles,\%cat_order); |
\%cat_titles,\%cat_order); |
if ($codepicker) { |
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>'); |
&Apache::lonhtmlcommon::end_pick_box().'</div>'); |
} else { |
} else { |
$r->print(&courseinfo_form($dom,$formname,$crstype)); |
$next = $states->{$action}[$page+2]; |
|
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
} |
} |
} else { |
} else { |
$r->print(&courseinfo_form($dom,$formname,$crstype)); |
if ($crstype eq 'official') { |
|
$next = $states->{$action}[$page+2]; |
|
} |
|
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
} |
} |
} elsif ($prev eq 'codepick') { |
} elsif ($prev eq 'codepick') { |
$r->print(&courseinfo_form($dom,$formname,$crstype)); |
if ($instcode eq '') { |
|
$prev = $states->{$action}[$page-2]; |
|
} |
|
$r->print(&courseinfo_form($dom,$formname,$crstype,$next,$description)); |
} elsif ($state eq 'enrollment') { |
} elsif ($state eq 'enrollment') { |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
&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(&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, |
|
$showcredits,$instcredits,$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 to be from the course domain','<tt>'.$personname.':'.$persondom.'</tt>'); |
|
next; |
|
} |
|
} |
|
my $usertype = &get_usertype($persondom,$personname,\%curr_rules,\%got_rules); |
|
if (&Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype)) { |
|
my ($allowed,$msg,$authtype,$authparam) = |
|
&check_newuser_rules($persondom,$personname, |
|
\%alerts,\%rulematch,\%inst_results, |
|
\%curr_rules,\%got_rules); |
|
if ($allowed) { |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($persondom); |
|
if ($usertype eq 'official') { |
|
if ($authtype eq '') { |
|
$authtype = $domdefaults{'auth_def'}; |
|
$authparam = $domdefaults{'auth_arg_def'}; |
|
} |
|
} elsif ($usertype eq 'unofficial') { |
|
if ($authtype eq '') { |
|
$authtype = 'internal'; |
|
$authparam = ''; |
|
} |
|
} else { |
|
$authtype = $domdefaults{'auth_def'}; |
|
$authparam = $domdefaults{'auth_arg_def'}; |
|
} |
|
if (($authtype eq '') || |
|
(($authtype =~/^krb/) && ($authparam eq ''))) { |
|
push(@disallowed,$i); |
|
$disallowmsg{$i} = &mt('[_1] was excluded because institutional information is incomplete for this new user.','<tt>'.$personname.':'.$persondom.'</tt>'); |
|
next; |
|
} |
|
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; |
|
if ($env{'form.origcnum'} =~ /^($match_courseid)$/) { |
|
$cnum = $env{'form.origcnum'}; |
|
} else { |
|
my $gentype = 'Course'; |
|
if ($crstype eq 'community') { |
|
$gentype = 'Community'; |
|
} |
|
$cnum = &Apache::lonnet::generate_coursenum($dom,$gentype); |
|
} |
&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(&print_review($formname,$dom,\@codetitles,\%cat_titles,\%cat_order, |
if ($crstype eq 'community') { |
\@code_order)); |
$r->print('<h3>'.&mt('Review community request details before submission').'</h3>'); |
$navtxt{'next'} = &mt('Submit course request'); |
} else { |
|
$r->print('<h3>'.&mt('Review course request details before submission').'</h3>'); |
|
} |
|
$r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg,$instcredits). |
|
'<input type="hidden" name="cnum" value="'.$cnum.'" />'); |
|
if ($crstype eq 'community') { |
|
$navtxt{'next'} = &mt('Submit community request'); |
|
} else { |
|
$navtxt{'next'} = &mt('Submit course request'); |
|
} |
} elsif ($state eq 'process') { |
} elsif ($state eq 'process') { |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
&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,$instcredits); |
|
$r->print($result); |
|
if (($storeresult eq 'ok') || ($storeresult eq 'created')) { |
|
if ($storeresult eq 'ok') { |
|
$r->print('<p><a href="/adm/requestcourse?action=view&state=details&showdom='.$dom.'&cnum='. $env{'form.cnum'}.'">'. |
|
&mt('Modify this request').'</a>'.(' 'x4). |
|
'<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>'); |
|
} |
|
if (&Apache::loncoursequeueadmin::author_prompt()) { |
|
$r->print('<h3>'.&mt('Access to authoring space').'</h3>'. |
|
'<p>'. |
|
&mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.'). |
|
'<br />'. |
|
&mt('By contrast, items created in authoring space, then imported into a course, can use all of the features of the assessment engine.').'</p>'. |
|
'<p>'.&mt('Request authoring space access now?'). |
|
'<span class="LC_nobreak"> '. |
|
'<label><input type="radio" name="requestauthor" value="1" />'.&mt('Yes').'</label>'. |
|
(' 'x2). |
|
'<label><input type="radio" name="requestauthor" value="0" checked="checked"/>'.&mt('No').'</label>'. |
|
'</span></p>'. |
|
'<input type="submit" name="newauthor" value="'.&mt('Submit authoring request').'" />'. |
|
'<input type="hidden" name="state" value="reqauthor" />'. |
|
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'. |
|
'<input type="hidden" name="cnum" value="'.$env{'form.cnum'}.'" />'. |
|
'<input type="hidden" name="showdom" value="'.$env{'form.showdom'}.'" />'. |
|
'<input type="hidden" name="crstype" value="'.$env{'form.crstype'}.'" />'. |
|
'<input type="hidden" name="disposition" value="'.$storeresult.'" />'. |
|
'<br />'); |
|
} elsif ($storeresult eq 'created') { |
|
$r->print('<p><a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>'); |
|
} |
|
} |
|
} elsif ($state eq 'reqauthor') { |
|
my ($result,@links); |
|
if ($env{'form.requestauthor'}) { |
|
$r->print(&Apache::loncoursequeueadmin::process_reqauthor(\$result)); |
|
if ($result eq 'created') { |
|
my $role = 'au'; |
|
my $spec = "$role./$env{'form.showdom'}/"; |
|
push(@links,&mt('Enter your authoring space with role: [_1]', |
|
'<a href="/adm/roles?selectrole=1&'.$spec.'=1">'. |
|
&Apache::lonnet::plaintext($role).'</a>')); |
|
} |
|
} |
|
if (($env{'form.disposition'} eq 'created') && |
|
($env{'form.cnum'} =~ /^$match_courseid$/) && |
|
($env{'form.showdom'} =~ /^$match_domain$/)) { |
|
my ($spec,$area,$role,$type); |
|
my $role = 'cc'; |
|
my $spec = "$role./$env{'form.showdom'}/$env{'form.cnum'}"; |
|
my $type = 'Course'; |
|
if ($env{'form.crstype'} eq 'community') { |
|
$type = 'Community'; |
|
} |
|
my $showrole = &Apache::lonnet::plaintext($role,$type); |
|
unshift(@links,&mt('Enter new course with role: [_1]', |
|
'<a href="/adm/roles?selectrole=1&'.$spec.'=1">'.$showrole.'</a>')); |
|
} |
|
if (@links > 1) { |
|
$r->print(&mt('New roles will be listed on your [_1]Roles[_2] page.', |
|
'<a href="/adm/roles">','</a>').' '.&mt('Choose a role:'). |
|
'<ul>'); |
|
foreach my $link (@links) { |
|
$r->print('<li>'.$link.'</li>'); |
|
} |
|
$r->print('</ul>'); |
|
} elsif (@links == 1) { |
|
$r->print('<p>'.$links[0].'</p>'); |
|
} |
|
} |
|
my @excluded = &get_excluded_elements($dom,$states,$action,$state,$showcredits); |
|
if ($state eq 'personnel') { |
|
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,('sectotal','crosslisttotal')); |
} |
} |
|
if (($state eq 'process') || ($state eq 'reqauthor')) { |
|
$r->print('</form>'); |
|
} else { |
|
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>'); |
|
&display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, |
|
$navtxt{'next'},$state); |
|
} |
|
return; |
|
} |
|
|
|
sub get_usertype { |
|
my ($persondom,$personname,$curr_rules,$got_rules) = @_; |
|
my ($rules,$ruleorder) = |
|
&Apache::lonnet::inst_userrules($persondom,'username'); |
|
my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname, |
|
$rules,$curr_rules,$got_rules); |
|
return $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,$authtype,$authparam); |
|
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; |
|
} |
|
} |
|
} |
|
if ($allowed) { |
|
if (ref($rulematch) eq 'HASH') { |
|
if (ref($rulematch->{$personname.':'.$persondom}) eq 'HASH') { |
|
my $matchedrule = $rulematch->{$personname.':'.$persondom}{'username'}; |
|
my ($rules,$ruleorder) = |
|
&Apache::lonnet::inst_userrules($persondom,'username'); |
|
if (ref($rules) eq 'HASH') { |
|
if (ref($rules->{$matchedrule}) eq 'HASH') { |
|
$authtype = $rules->{$matchedrule}{'authtype'}; |
|
$authparam = $rules->{$matchedrule}{'authparm'}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return ($allowed,$userchkmsg,$authtype,$authparam); |
|
} |
|
|
|
sub get_excluded_elements { |
|
my ($dom,$states,$action,$state,$showcredits) = @_; |
my @excluded = ('counter'); |
my @excluded = ('counter'); |
my %elements = &form_elements($dom); |
my ($elements,$instcredits) = &form_elements($dom,$showcredits); |
if (ref($states) eq 'HASH') { |
if (ref($states) eq 'HASH') { |
if (ref($states->{$action}) eq 'ARRAY') { |
if (ref($states->{$action}) eq 'ARRAY') { |
my @items = @{$states->{$action}}; |
my @items = @{$states->{$action}}; |
my $numitems = scalar(@items); |
my $numitems = scalar(@items); |
if ($numitems) { |
if ($numitems) { |
for (my $i=$numitems-1; $i>=0; $i--) { |
for (my $i=$numitems-1; $i>=0; $i--) { |
if (ref($elements{$action}) eq 'HASH') { |
if ((ref($elements) eq 'HASH') && |
if (ref($elements{$action}{$items[$i]}) eq 'HASH') { |
(ref($elements->{$action}) eq 'HASH')) { |
foreach my $key (keys(%{$elements{$action}{$items[$i]}})) { |
if (ref($elements->{$action}{$items[$i]}) eq 'HASH') { |
|
foreach my $key (keys(%{$elements->{$action}{$items[$i]}})) { |
push(@excluded,$key); |
push(@excluded,$key); |
} |
} |
} |
} |
Line 675 sub print_request_form {
|
Line 1659 sub print_request_form {
|
if (grep(/^instcode_/,@excluded)) { |
if (grep(/^instcode_/,@excluded)) { |
push(@excluded,'instcode'); |
push(@excluded,'instcode'); |
} |
} |
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>'); |
return @excluded; |
&display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'}); |
|
return; |
|
} |
} |
|
|
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); |
$showcredits,$instcredits,$invalidcrosslist) =@_; |
|
my ($sections,$autoenroll,$access_dates,$output,$hasauto,$hascredits, |
|
$creditsrow,$domdefcredits); |
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 |
|
|
my %accesstitles = ( |
my %accesstitles = ( |
'start' => 'Default start access', |
'start' => 'Default start access', |
'end' => 'Default end accss', |
'end' => 'Default end access', |
); |
); |
my %enrolltitles = ( |
my %enrolltitles = ( |
'start' => 'Start auto-enrollment', |
'start' => 'Start auto-enrollment', |
'end' => 'End auto-enrollment', |
'end' => 'End auto-enrollment', |
); |
); |
|
if ($showcredits) { |
|
unless ($env{'form.crstype'} eq 'community') { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($dom); |
|
$domdefcredits = $domdefs{$env{'form.crstype'}.'credits'}; |
|
} |
|
} |
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); |
$section_form = &inst_section_selector($dom,$instcode); |
my ($section_form,$crosslist_form); |
|
if ($instcode ne '') { |
|
$section_form = &inst_section_selector($dom,$instcode); |
|
if ($section_form eq '') { |
|
my $sectotal = $env{'form.sectotal'}; |
|
if (!$sectotal) { |
|
$sectotal = 1; |
|
} |
|
if ($env{'form.addsection'}) { |
|
$sectotal ++; |
|
} |
|
for (my $i=0; $i<$sectotal; $i++) { |
|
$section_form .= §ions_form($dom,$instcode,$i); |
|
} |
|
if ($section_form) { |
|
$section_form .= |
|
&Apache::lonhtmlcommon::row_title(&mt('Add another')). |
|
'<input name="sectotal" type="hidden" value="'.$sectotal.'" />'. |
|
'<input name="addsection" type="checkbox" value="'.$sectotal.'"'. |
|
' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}. |
|
"'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(); |
|
} |
|
} |
|
} |
|
if ($section_form) { |
|
$sections = &Apache::lonhtmlcommon::row_headline(). |
|
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Sections'). |
|
' '.&mt('Sections for auto-enrollment').'</h3>'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
$section_form; |
|
} |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
if (!defined($crosslisttotal)) { |
if (!$crosslisttotal) { |
$crosslisttotal = 1; |
$crosslisttotal = 1; |
} |
} |
if ($env{'form.addcrosslist'}) { |
if ($env{'form.addcrosslist'}) { |
Line 711 sub print_enrollment_menu {
|
Line 1731 sub print_enrollment_menu {
|
} |
} |
if ($crosslist_form) { |
if ($crosslist_form) { |
$crosslist_form .= |
$crosslist_form .= |
&Apache::lonhtmlcommon::row_title(&mt('Add another?')). |
&Apache::lonhtmlcommon::row_title(&mt('Add another')). |
'<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>'.&Apache::loncommon::help_open_topic('Course_Request_Crosslist').' '.&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"; |
} |
} |
$hasauto = 1; |
$autoenroll_form = |
$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>'. |
'<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(&Apache::loncommon::help_open_topic('Course_Request_Autodrop').' '.&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', |
if ($autoenroll_form) { |
$hasauto,undef,%enrolltitles); |
$autoenroll = '<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
if ($showcredits) { |
$autoenroll_form. |
if ($instcredits) { |
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n"; |
$creditsrow = &mt('[quant,_1,credit]',$instcredits); |
|
} else { |
|
$creditsrow = '<span class="LC_nobreak">'. |
|
'<input type="text" size="3" name="coursecredits"'. |
|
' value="'.$domdefcredits.'" />'; |
|
} |
|
$hascredits = 1; |
|
} |
|
} |
|
} elsif ($env{'form.crstype'} eq 'unofficial') { |
|
if ($showcredits) { |
|
$creditsrow = '<span class="LC_nobreak">'. |
|
'<input type="text" size="3" name="coursecredits"'. |
|
' value="'.$domdefcredits.'"/>'; |
|
$hascredits = 1; |
|
} |
|
} |
|
my $access_dates = |
|
&date_setting_table($starttime,$endtime,$formname,'access',$hasauto, |
|
$hascredits,%accesstitles); |
|
$output .= &Apache::lonhtmlcommon::start_pick_box(); |
|
if ($sections) { |
|
$output .= $sections; |
|
} |
|
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; |
|
} |
|
if ($creditsrow) { |
|
$output .= &Apache::lonhtmlcommon::row_headline('Credits'). |
|
'<h3>'.&mt('Credits earned by students').'</h3>'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
&Apache::lonhtmlcommon::row_title(&mt('Default credits')). |
|
$creditsrow. |
|
&Apache::lonhtmlcommon::row_closure(1); |
|
} |
|
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 />'; |
} |
} |
} |
} |
my $access_dates_form = |
return $output; |
&date_setting_table($starttime,$endtime,$formname,'access',%accesstitles); |
|
if ($access_dates_form) { |
|
$access_dates = '<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
|
$access_dates_form. |
|
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n"; |
|
} |
|
return $sections.$autoenroll.$access_dates; |
|
} |
} |
|
|
|
|
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" '. |
'value="'.$sectotal.'"</th>'. |
'value="'.$sectotal.'" /></th>'. |
'<th>'.&mt('Institutional Section').'</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(); |
&Apache::loncommon::end_data_table_row(); |
for (my $i=0; $i<@sections; $i++) { |
for (my $i=0; $i<@sections; $i++) { |
my $colflag = $i%2; |
my $colflag = $i%2; |
|
my $secon = ' checked="checked"'; |
|
my $secoff = ''; |
|
if ($env{'form.origcnum'}) { |
|
$secoff = $secon; |
|
$secon=''; |
|
} |
$output .= &Apache::loncommon::start_data_table_row(). |
$output .= &Apache::loncommon::start_data_table_row(). |
'<td><input type="checkbox" name="sec_'.$i. |
'<td><label><input type="radio" name="sec_'.$i. |
'" checked="checked" /></td>'. |
'"'.$secon.' value="1" />'.&mt('Yes').'</label>'. |
'<td>'.$sections[$i]. |
(' 'x2).'<label><input type="radio" name="sec_'.$i. |
|
'"'.$secoff.' value="0" />'.&mt('No').'</label></td>'. |
|
'<td align="center">'.$sections[$i]. |
'<input type="hidden" name="secnum_'.$i.'" value="'. |
'<input type="hidden" name="secnum_'.$i.'" value="'. |
$sections[$i].'" /></td>'. |
$sections[$i].'" /></td>'. |
'<td><input type="text" size="10" name="loncapasec_'.$i. |
'<td><input type="text" size="10" name="loncapasec_'.$i. |
Line 788 sub inst_section_selector {
|
Line 1872 sub inst_section_selector {
|
} |
} |
|
|
sub date_setting_table { |
sub date_setting_table { |
my ($starttime,$endtime,$formname,$suffix,%datetitles) = @_; |
my ($starttime,$endtime,$formname,$prefix,$hasauto,$hascredits,%datetitles)=@_; |
my ($perpetual,$table); |
my ($perpetual,$table); |
my $startform = &Apache::lonhtmlcommon::date_setter($formname,'start'.$suffix, |
my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start', |
$starttime,'','','',1,'','','',1); |
$starttime,'','','',1,'','','',1); |
my $endform = &Apache::lonhtmlcommon::date_setter($formname,'end'.$suffix, |
my $endform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'end', |
$endtime,'','','',1,'','','',1); |
$endtime,'','','',1,'','','',1); |
if ($suffix eq 'access') { |
my $closure = ''; |
|
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>'; |
|
unless ($hascredits) { |
|
$closure = '1'; |
|
} |
|
} |
|
|
|
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($datetitles{'start'}). |
|
$startform. |
$table = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'start'}). |
&Apache::lonhtmlcommon::row_closure(). |
' '.&mt($datetitles{'start'})).$startform. |
&Apache::lonhtmlcommon::row_title($datetitles{'end'}). |
&Apache::lonhtmlcommon::row_closure(1). |
$endform.$perpetual. |
&Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'end'}). |
&Apache::lonhtmlcommon::row_closure(1); |
' '.&mt($datetitles{'end'})).$endform.$perpetual. |
|
&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)) { |
if ((!defined($persontotal)) || (!$persontotal)) { |
$persontotal = 1; |
$persontotal = 1; |
} |
} |
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','last','first','email','hidedom'); |
|
|
|
my $roleoptions; |
|
my @roles = &Apache::lonuserutils::roles_by_context('course'); |
|
my $type = 'Course'; |
my $type = 'Course'; |
if ($crstype eq 'community') { |
if ($crstype eq 'community') { |
$type = 'Community'; |
$type = 'Community'; |
} |
} |
|
my $roleoptions; |
|
my @roles = &Apache::lonuserutils::roles_by_context('course','',$type); |
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 871 sub print_personnel_menu {
|
Line 1969 sub print_personnel_menu {
|
$newtitle = &mt('Other').': '; |
$newtitle = &mt('Other').': '; |
} |
} |
|
|
|
if ($persontotal) { |
|
my %lt = &Apache::lonlocal::texthash( |
|
community => 'Requestor is automatically assigned Coordinator role.', |
|
official => 'Requestor is automatically assigned Course Coordinator role.', |
|
); |
|
$lt{'unofficial'} = $lt{'official'}; |
|
$output .= &Apache::lonhtmlcommon::row_headline(). |
|
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&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 898 sub print_personnel_menu {
|
Line 2001 sub print_personnel_menu {
|
$existmult.'>'."\n".$existops.'</select>'.(' ' x3); |
$existmult.'>'."\n".$existops.'</select>'.(' ' x3); |
} |
} |
$sectionselector .= $newtitle. |
$sectionselector .= $newtitle. |
'<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'. |
'<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'."\n"; |
'<input type="hidden" name="person_'.$i.'_sections" 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>'. |
'<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'first'}.'</td>'."\n". |
'</tr>'."\n".'<tr>'. |
'<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'last'}.'</td>'."\n". |
'<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'firstname'}.'</td>'."\n". |
'<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{email}.'</td></tr>'."\n". |
'<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'lastname'}.'</td>'."\n". |
'<tr><td align="center" valign="top">'.&mt('Role').'<br />'.$roleselector.'</td>'."\n". |
'<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{'emailaddr'}.'</td></tr>'."\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(); |
'</tr></table>'.&Apache::lonhtmlcommon::row_closure(); |
} |
} |
$output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')). |
$output .= &Apache::lonhtmlcommon::row_title(&mt('Add another')). |
'<input name="persontotal" type="hidden" value="'.$persontotal.'" />'. |
'<input name="persontotal" type="hidden" value="'.$persontotal.'" />'. |
'<input name="addperson" type="checkbox" value="'.$persontotal.'"'. |
'<input name="addperson" type="checkbox" value="'.$persontotal.'"'. |
' 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(1). |
&Apache::lonhtmlcommon::end_pick_box().'</div>'; |
&Apache::lonhtmlcommon::end_pick_box().'</div>'; |
|
if ($crstype eq 'community') { |
|
$output .= '<p>'.&mt('You may also add users later, once the community has been created, by using the "Manage community users" link, accessible from the "Main Menu".').'</p>'; |
|
} else { |
|
$output .= '<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; |
return $output; |
} |
} |
|
|
sub print_request_status { |
sub current_lc_sections { |
my ($dom) = @_; |
my @currsecs; |
my %requests = &Apache::lonnet::dumpstore('courserequests',$env{'user.domain'}, |
if ($env{'form.sectotal'}) { |
$env{'user.name'}); |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
my ($output,$formname,%queue_by_date); |
if ($env{'form.sec_'.$i}) { |
foreach my $key (keys(%requests)) { |
if (defined($env{'form.loncapasec_'.$i})) { |
if (ref($requests{$key}) eq 'HASH') { |
my $lcsec = $env{'form.loncapasec_'.$i}; |
my ($cdom,$cnum) = split('_',$key); |
unless (grep(/^\Q$lcsec\E$/,@currsecs)) { |
next if ($cdom ne $dom); |
push(@currsecs,$lcsec); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return @currsecs; |
|
} |
|
|
|
sub sorted_request_history { |
|
my ($dom,$action,$curr_req) = @_; |
|
my ($after,$before,$statusfilter,$crstypefilter); |
|
if ($env{'form.status'} ne '') { |
|
$statusfilter = $env{'form.status'}; |
|
} |
|
if ($env{'form.crstype'} ne '') { |
|
$crstypefilter = $env{'form.crstype'}; |
|
} |
|
if (ref($curr_req) eq 'HASH') { |
|
$after = $curr_req->{'requested_after_date'}, |
|
$before = $curr_req->{'requested_before_date'}; |
|
$statusfilter = $curr_req->{'status'}; |
|
$crstypefilter = $curr_req->{'crstype'}; |
|
} |
|
my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'}, |
|
$env{'user.name'},'^status:'.$dom); |
|
my %queue_by_date; |
|
my ($types,$typenames) = &Apache::loncommon::course_types(); |
|
foreach my $key (keys(%statusinfo)) { |
|
if ($action eq 'view') { |
|
next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')); |
|
} else { |
|
next unless (($statusfilter eq 'any') || |
|
($statusfilter eq $statusinfo{$key})); |
|
} |
|
(undef,my($cdom,$cnum)) = split(':',$key); |
|
next if ($cdom ne $dom); |
|
my $requestkey = $cdom.'_'.$cnum; |
|
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
|
my %history = &Apache::lonnet::restore($requestkey,'courserequests', |
|
$env{'user.domain'},$env{'user.name'}); |
my $entry; |
my $entry; |
my $timestamp = $requests{$key}{'timestamp'}; |
my $reqtime = $history{'reqtime'}; |
my $crstype = $requests{$key}{'crstype'}; |
my $lastupdate = $history{'timestamp'}; |
my $status = $requests{$key}{'status'}; |
my $crstype = $history{'crstype'}; |
next unless (($env{'form.crstype'} eq 'all') || |
my $disposition = $history{'disposition'}; |
($env{'form.crstype'} eq $crstype)); |
my $status = $history{'status'}; |
next unless (($status eq 'approval') || ($status eq 'pending')); |
if ($action eq 'view') { |
if (ref($requests{$key}{'details'}) eq 'HASH') { |
next if ((exists($history{'status'})) && ($history{'status'} eq 'created')); |
$entry = $key.':'.$crstype.':'.$requests{$key}{'details'}{'cdesc'}; |
} else { |
|
next if (($reqtime < $after) || ($reqtime > $before)); |
|
} |
|
next unless (($crstypefilter eq 'any') || |
|
($crstypefilter eq $crstype)); |
|
if ($action eq 'view') { |
|
next unless (($disposition eq 'approval') || |
|
($disposition eq 'pending')); |
|
} |
|
if (ref($history{'details'}) eq 'HASH') { |
|
$entry = $requestkey.':'.$crstype.':'. |
|
&escape($history{'details'}{'cdescr'}); |
|
if ($action eq 'log') { |
|
$entry .= ':'.$lastupdate.':'; |
|
if ($statusinfo{$key} ne '') { |
|
$entry .= $statusinfo{$key}; |
|
} elsif ($status ne '') { |
|
$entry .= $status; |
|
} else { |
|
$entry .= $disposition; |
|
} |
|
} |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
$entry .= ':'.$requests{$key}{'details'}{'instcode'}; |
$entry .= ':'.&escape($history{'details'}{'instcode'}); |
} |
} |
} |
} |
if ($entry ne '') { |
if ($entry ne '') { |
if (exists($queue_by_date{$timestamp})) { |
if (exists($queue_by_date{$reqtime})) { |
if (ref($queue_by_date{$timestamp}) eq 'ARRAY') { |
if (ref($queue_by_date{$reqtime}) eq 'ARRAY') { |
push(@{$queue_by_date{$timestamp}},$entry); |
push(@{$queue_by_date{$reqtime}},$entry); |
} |
} |
} else { |
} else { |
@{$queue_by_date{$timestamp}} = ($entry); |
@{$queue_by_date{$reqtime}} = ($entry); |
} |
} |
} |
} |
} |
} |
} |
} |
$formname = 'requestcrs'; |
return %queue_by_date; |
|
} |
|
|
|
sub print_request_status { |
|
my ($dom,$action) = @_; |
|
my %queue_by_date = &sorted_request_history($dom,$action); |
my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date)); |
my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date)); |
$output = '<form method="post" name="'.$formname.'" action="/adm/requestcourse" />'."\n". |
my $formname = 'requestcrs'; |
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n". |
my ($types,$typenames) = &Apache::loncommon::course_types(); |
|
my $output = '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n". |
|
|
'<input type="hidden" name="state" value="'.$env{'form.state'}.'" />'."\n". |
'<input type="hidden" name="state" value="'.$env{'form.state'}.'" />'."\n". |
'<input type="hidden" name="crstype" value="'.$env{'form.crstype'}.'" />'."\n"; |
'<input type="hidden" name="crstype" value="'.$env{'form.crstype'}.'" />'."\n". |
|
'<input type="hidden" name="showdom" value="" />'."\n". |
|
'<input type="hidden" name="cnum" value="" />'."\n"; |
if (@sortedtimes > 0) { |
if (@sortedtimes > 0) { |
|
my $desctitle; |
|
if ($env{'form.crstype'} eq 'any') { |
|
$desctitle = &mt('Course/Community Description') |
|
} elsif ($env{'form.crstype'} eq 'community') { |
|
$desctitle = &mt('Community Description') |
|
} else { |
|
$desctitle = &mt('Course Description'); |
|
} |
$output .= &Apache::loncommon::start_data_table(). |
$output .= &Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th>'.&mt('Action').'</th>'. |
'<th>'.&mt('Action').'</th>'. |
'<th>'.&mt('Description').'</th>'; |
'<th>'.$desctitle.'</th>'. |
if ($env{'form.crstype'} eq 'all') { |
'<th>'.&mt('Domain').'</th>'; |
|
if ($env{'form.crstype'} eq 'any') { |
$output .= '<th>'.&mt('Type').'</th>'; |
$output .= '<th>'.&mt('Type').'</th>'; |
} |
} |
if (($env{'form.crstype'} eq 'all') || ($env{'form.crstype'} eq 'official')) { |
if (($env{'form.crstype'} eq 'any') || ($env{'form.crstype'} eq 'official')) { |
$output .= '<th>'.&mt('Institutional Code').'</th>'; |
$output .= '<th>'.&mt('Institutional Code').'</th>'; |
} |
} |
$output .= '<th>'.&mt('Date requested').'</th>'. |
$output .= '<th>'.&mt('Date requested').'</th>'. |
Line 983 sub print_request_status {
|
Line 2176 sub print_request_status {
|
my ($key,$type,$desc,$instcode) = split(':',$request); |
my ($key,$type,$desc,$instcode) = split(':',$request); |
my ($cdom,$cnum) = split('_',$key); |
my ($cdom,$cnum) = split('_',$key); |
$output .= &Apache::loncommon::start_data_table_row(). |
$output .= &Apache::loncommon::start_data_table_row(). |
'<td><input type="button" value="'.&mt('Select').'" onclick="javascript:viewrequest('."'$cdom','$cnum'".')" /></td>'. |
'<td><input type="button" value="'.&mt('Select').'" onclick="javascript:chooseRequest('."'$cdom','$cnum'".')" /></td>'. |
'<td>'.$desc.'</td>'; |
'<td>'.&unescape($desc).'</td>'. |
if ($env{'form.crstype'} eq 'all') { |
'<td>'.$cdom.'</td>'; |
$output .= '<td>'.&course_types($type).'</td>'; |
if ($env{'form.crstype'} eq 'any') { |
|
my $typename; |
|
if (ref($typenames) eq 'HASH') { |
|
$typename = &mt($typenames->{$type}); |
|
} |
|
if ($typename eq '') { |
|
$typename = &mt('Unknown type'); |
|
} |
|
$output .= '<td>'.$typename.'</td>'; |
} |
} |
if (($env{'form.crstype'} eq 'all') || |
if (($env{'form.crstype'} eq 'any') || |
($env{'form.crstype'} eq 'official')) { |
($env{'form.crstype'} eq 'official')) { |
$output .= '<td>'.$instcode.'</td>'; |
my $showinstcode; |
|
if ($type eq 'official') { |
|
$showinstcode = &unescape($instcode); |
|
} else { |
|
$showinstcode = &mt('Not applicable'); |
|
} |
|
$output .= '<td>'.$showinstcode.'</td>'; |
} |
} |
$output .= '<td>'.$showtime.'</td>'. |
$output .= '<td>'.$showtime.'</td>'. |
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
Line 999 sub print_request_status {
|
Line 2206 sub print_request_status {
|
} |
} |
$output .= &Apache::loncommon::end_data_table(); |
$output .= &Apache::loncommon::end_data_table(); |
} else { |
} else { |
$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>'; |
if ($env{'form.crstype'} eq 'any') { |
|
$output .= '<div>'.&mt('You have no matching course or community requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'</div>'; |
|
} elsif ($env{'form.crstype'} eq 'community') { |
|
$output .= '<div>'.&mt('You have no matching community requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'</div>'; |
|
} else { |
|
$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 .= ' |
<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>'; |
|
return $output; |
return $output; |
} |
} |
|
|
|
sub print_cancel_request { |
|
my ($dom,$cnum) = @_; |
|
my $requestkey = $dom.'_'.$cnum; |
|
my ($result,$output); |
|
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
|
my %history = &Apache::lonnet::restore($requestkey,'courserequests', |
|
$env{'user.domain'},$env{'user.name'}); |
|
my $timestamp = $history{'reqtime'}; |
|
my $crstype = $history{'crstype'}; |
|
my $status = $history{'status'}; |
|
if (($status eq 'cancelled') || ($status eq 'created')) { |
|
if ($status eq 'cancelled') { |
|
$output = &mt('This request has already been cancelled.'); |
|
} elsif ($status eq 'created') { |
|
$output = &mt('This request has already been processed, and a course created.'); |
|
} |
|
$output = &mt('No further action will be taken'); |
|
} elsif (ref($history{'details'}) eq 'HASH') { |
|
my ($types,$typename) = &Apache::loncommon::course_types(); |
|
my $showtype = $crstype; |
|
if (defined($typename->{$crstype})) { |
|
$showtype = $typename->{$crstype}; |
|
} |
|
$output = '<p>'.&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Description').'</th><th>'.&mt('Requested').'</th>'. |
|
'<th>'.&mt('Type').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row(). |
|
&Apache::loncommon::start_data_table_row(). |
|
'<td>'.$history{details}{'cdescr'}.'</td><td>'. |
|
&Apache::lonlocal::locallocaltime($timestamp).'</td>'. |
|
'<td>'.$showtype.'</td>'. |
|
&Apache::loncommon::end_data_table_row(). |
|
&Apache::loncommon::end_data_table(). |
|
'<br /><div class="LC_warning">'; |
|
if ($crstype eq 'community') { |
|
$output .= &mt('Cancelling the request will remove it from the queue of pending community requests').'</div>'; |
|
} else { |
|
$output .= &mt('Cancelling the request will remove it from the queue of pending course requests').'</div>'; |
|
} |
|
$result = 'ok'; |
|
} else { |
|
$output = '<div class="LC_error">'.&mt('No record exists for the course ID').'</div>'; |
|
} |
|
} else { |
|
$output = '<div class="LC_error">'.&mt('Invalid course ID').'</div>'; |
|
} |
|
return ($result,$output); |
|
} |
|
|
|
sub viewrequest_javascript { |
|
my ($formname,$next) = @_; |
|
return <<"ENDJS"; |
|
|
|
function chooseRequest(cdom,cnum) { |
|
document.$formname.showdom.value = cdom; |
|
document.$formname.cnum.value = cnum; |
|
nextPage(document.$formname,'$next'); |
|
} |
|
|
|
ENDJS |
|
} |
|
|
|
sub viewdetails_javascript { |
|
my ($formname) = @_; |
|
return << "ENDJS"; |
|
|
|
function nextPage(formname,nextstate) { |
|
if (nextstate == "modify") { |
|
formname.state.value = "personnel"; |
|
formname.action.value = "new"; |
|
} else { |
|
formname.state.value = nextstate; |
|
} |
|
formname.submit(); |
|
} |
|
|
|
function backPage(formname,prevstate) { |
|
formname.state.value = prevstate; |
|
formname.submit(); |
|
} |
|
|
|
ENDJS |
|
} |
|
|
|
sub viewcancel_javascript { |
|
my $alert = &mt('Are you sure you want to cancel this request?\\n'. |
|
'Your request will be removed.'); |
|
return << "ENDJS"; |
|
function nextPage(formname,nextstate) { |
|
if (confirm('$alert')) { |
|
formname.state.value = nextstate; |
|
formname.submit(); |
|
} |
|
return; |
|
} |
|
|
|
ENDJS |
|
} |
|
|
sub print_request_logs { |
sub print_request_logs { |
my ($jscript,$loaditems,$crumb) = @_; |
my ($r,$dom,$jscript,$loaditems,$crumb) = @_; |
|
my $title; |
|
if ($env{'form.crstype'} eq 'community') { |
|
$title = 'Community Request Logs'; |
|
} elsif ($env{'form.crstype'} eq 'any') { |
|
$title = 'Course/Community Request Logs'; |
|
} else { |
|
$title = 'Course Request Logs'; |
|
} |
|
$r->print(&header($title,$jscript,$loaditems).$crumb); |
|
my $formname = 'requestcrs'; |
|
$r->print('<form action="/adm/requestcourse" method="post" name="'.$formname.'" onsubmit="javascript:setPage(this);">'."\n". |
|
'<input type="hidden" name="action" value="log" />'."\n". |
|
'<input type="hidden" name="state" value="display" />'."\n"); |
|
# set defaults |
|
my $now = time(); |
|
my $defstart = $now - (7*24*3600); #7 days ago |
|
my %defaults = ( |
|
page => '1', |
|
show => '10', |
|
crstype => 'any', |
|
status => 'any', |
|
requested_before_date => $now, |
|
requested_after_date => $defstart, |
|
); |
|
my ($types,$typenames) = &Apache::loncommon::course_types(); |
|
my $more_records = 0; |
|
my %curr; |
|
foreach my $item ('show','page','crstype','status') { |
|
$curr{$item} = $env{'form.'.$item}; |
|
} |
|
$curr{'requested_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('requested_after_date'); |
|
$curr{'requested_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('requested_before_date'); |
|
foreach my $key (keys(%defaults)) { |
|
if ($curr{$key} eq '') { |
|
$curr{$key} = $defaults{$key}; |
|
} |
|
} |
|
my ($statuses,$statusnames) = &reqstatus_names($curr{'crstype'}); |
|
$r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'. |
|
&requestlog_display_filter($formname,\%curr)); |
|
my %queue_by_date = &sorted_request_history($dom,$env{'form.action'},\%curr); |
|
my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date)); |
|
my $showntablehdr = 0; |
|
my $tablehdr = &Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
'<th> </th><th>'.&mt('Request Date').'</th>'. |
|
'<th>'.&mt('Description').'</th>'; |
|
if ($curr{'crstype'} eq 'any') { |
|
$tablehdr .= '<th>'.&mt('Course Type').'</th>'; |
|
} |
|
if (($curr{'crstype'} eq 'official') || ($curr{'crstype'} eq 'any')) { |
|
$tablehdr .= '<th>'.&mt('Institutional Code').'</th>'; |
|
} |
|
if ($curr{'status'} eq 'any') { |
|
$tablehdr .= '<th>'.&mt('Status').'</th>'; |
|
} elsif ($curr{'status'} eq 'created') { |
|
$tablehdr .= '<th>'.&mt('Creation Date').'</th>'; |
|
} elsif ($curr{'status'} eq 'cancelled') { |
|
$tablehdr .= '<th>'.&mt('Cancellation Date').'</th>'; |
|
} elsif ($curr{'status'} eq 'rejected') { |
|
$tablehdr .= '<th>'.&mt('Rejection Date').'</th>'; |
|
} |
|
$tablehdr .= &Apache::loncommon::end_data_table_header_row(); |
|
my ($minshown,$maxshown); |
|
$minshown = 1; |
|
my $count = 0; |
|
if ($curr{'show'} ne &mt('all')) { |
|
$maxshown = $curr{'page'} * $curr{'show'}; |
|
if ($curr{'page'} > 1) { |
|
$minshown = 1 + ($curr{'page'} - 1) * $curr{'show'}; |
|
} |
|
} |
|
my $norecords; |
|
if (@sortedtimes > 0) { |
|
foreach my $item (@sortedtimes) { |
|
if ($curr{'show'} ne &mt('all')) { |
|
if ($count >= $curr{'page'} * $curr{'show'}) { |
|
$more_records = 1; |
|
last; |
|
} |
|
} |
|
$count ++; |
|
next if ($count < $minshown); |
|
if (!$showntablehdr) { |
|
$r->print($tablehdr); |
|
$showntablehdr = 1; |
|
} |
|
my $showtime = &Apache::lonlocal::locallocaltime($item); |
|
if (ref($queue_by_date{$item}) eq 'ARRAY') { |
|
foreach my $request (sort(@{$queue_by_date{$item}})) { |
|
my ($key,$crstype,$desc,$timestamp,$status,$instcode) = split(':',$request); |
|
my ($cdom,$cnum) = split('_',$key); |
|
my $output = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$count.'</td>'. |
|
'<td>'.$showtime.'</td>'. |
|
'<td>'.&unescape($desc).'</td>'; |
|
if ($curr{'crstype'} eq 'any') { |
|
my $typename; |
|
if (ref($typenames) eq 'HASH') { |
|
$typename = &mt($typenames->{$crstype}); |
|
} |
|
if ($typename eq '') { |
|
$typename = &mt('Unknown type'); |
|
} |
|
$output .= '<td>'.$typename.'</td>'; |
|
} |
|
if (($curr{'crstype'} eq 'any') || |
|
($curr{'crstype'} eq 'official')) { |
|
my $showinstcode; |
|
if ($crstype eq 'official') { |
|
$showinstcode = &unescape($instcode); |
|
} else { |
|
$showinstcode = &mt('Not applicable'); |
|
} |
|
$output .= '<td>'.$showinstcode.'</td>'; |
|
} |
|
if ($curr{'status'} eq 'any') { |
|
my $statusname = &mt('Unknown status'); |
|
if (ref($statusnames) eq 'HASH') { |
|
if ($statusnames->{$status} ne '') { |
|
$statusname = $statusnames->{$status}; |
|
} |
|
} |
|
if (($status eq 'created') || ($status eq 'cancelled') || |
|
($status eq 'rejected')) { |
|
$statusname .= ' '.&Apache::lonlocal::locallocaltime($timestamp); |
|
} |
|
$output .= '<td>'.$statusname.'</td>'; |
|
} elsif (($status eq 'created') || ($status eq 'cancelled') || |
|
($status eq 'rejected')) { |
|
$output .= '<td>'.&Apache::lonlocal::locallocaltime($timestamp).'</td>'; |
|
} |
|
$output .= &Apache::loncommon::end_data_table_row(); |
|
$r->print($output); |
|
} |
|
} |
|
} |
|
if ($showntablehdr) { |
|
$r->print(&Apache::loncommon::end_data_table()); |
|
if (($curr{'page'} > 1) || ($more_records)) { |
|
$r->print('<table><tr>'); |
|
if ($curr{'page'} > 1) { |
|
$r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>'); |
|
} |
|
if ($more_records) { |
|
$r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>'); |
|
} |
|
$r->print('</tr></table>'); |
|
$r->print(<<"ENDSCRIPT"); |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
function chgPage(caller) { |
|
if (caller == 'previous') { |
|
document.$formname.page.value --; |
|
} |
|
if (caller == 'next') { |
|
document.$formname.page.value ++; |
|
} |
|
document.$formname.submit(); |
return; |
return; |
} |
} |
|
// ]]> |
|
</script> |
|
ENDSCRIPT |
|
} |
|
} else { |
|
$norecords = 1; |
|
} |
|
} else { |
|
$norecords = 1; |
|
} |
|
if ($norecords) { |
|
$r->print('<p class="LC_info">'. |
|
&mt('There are no records to display'). |
|
'</p>'); |
|
} |
|
$r->print('</form>'. |
|
&Apache::loncommon::end_page()); |
|
return; |
|
} |
|
|
|
sub reqstatus_names { |
|
my ($crstype) = @_; |
|
my @statuses = qw(created approval pending rejected cancelled); |
|
my %statusnames = |
|
&Apache::lonlocal::texthash ( |
|
created => 'Created', |
|
approval => 'Queued pending approval', |
|
pending => 'Queued pending validation', |
|
rejected => 'Request rejected', |
|
cancelled => 'Request cancelled', |
|
); |
|
if (($crstype eq 'official') || ($crstype eq 'unofficial')) { |
|
$statusnames{'created'} = &mt('Course created'); |
|
} elsif ($crstype eq 'community') { |
|
$statusnames{'created'} = &mt('Community created'); |
|
} |
|
return (\@statuses,\%statusnames); |
|
} |
|
|
|
sub requestlog_display_filter { |
|
my ($formname,$curr) = @_; |
|
my $nolink = 1; |
|
my $output = '<table><tr><td valign="top">'. |
|
'<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'. |
|
&Apache::lonmeta::selectbox('show',$curr->{'show'},undef, |
|
(&mt('all'),5,10,20,50,100,1000,10000)). |
|
'</td><td> </td>'; |
|
my $startform = |
|
&Apache::lonhtmlcommon::date_setter($formname,'requested_after_date', |
|
$curr->{'requested_after_date'},undef, |
|
undef,undef,undef,undef,undef,undef,$nolink); |
|
my $endform = |
|
&Apache::lonhtmlcommon::date_setter($formname,'requested_before_date', |
|
$curr->{'requested_before_date'},undef, |
|
undef,undef,undef,undef,undef,undef,$nolink); |
|
$output .= '<td valign="top"><b>'.&mt('Window during which course/community was requested:').'</b><br />'. |
|
'<table><tr><td>'.&mt('After:'). |
|
'</td><td>'.$startform.'</td></tr>'. |
|
'<tr><td>'.&mt('Before:').'</td>'. |
|
'<td>'.$endform.'</td></tr></table>'. |
|
'</td>'. |
|
'<td> </td>'; |
|
my ($types,$typenames) = &Apache::loncommon::course_types(); |
|
if (ref($types) eq 'ARRAY') { |
|
if (@{$types} > 1) { |
|
$output .= '<td valign="top"><b>'. |
|
&mt('Course Type:').'</b><br /><select name="crstype">'; |
|
my $selstr = ''; |
|
if ($curr->{'crstype'} eq 'any') { |
|
$selstr = ' selected="selected"'; |
|
} |
|
$output .= '<option value="any"'.$selstr.'>'.&mt('All types').'</option>'."\n"; |
|
foreach my $crstype (@{$types}) { |
|
my $selstr = ''; |
|
if ($curr->{'crstype'} eq $crstype) { |
|
$selstr = ' selected="selected"'; |
|
} |
|
my $typename = $crstype; |
|
if (ref($typenames) eq 'HASH') { |
|
if ($typenames->{$crstype} ne '') { |
|
$typename = $typenames->{$crstype}; |
|
} |
|
} |
|
$output .= '<option value="'.$crstype.'"'.$selstr.'>'.$typename.'</option>'."\n"; |
|
} |
|
$output .= '</select></td>'; |
|
} |
|
} |
|
my ($statuses,$statusnames) = &reqstatus_names($curr->{'crstype'}); |
|
if (ref($statuses) eq 'ARRAY') { |
|
if (@{$statuses} > 1) { |
|
$output .= '<td valign="top"><b>'. |
|
&mt('Request Status:').'</b><br /><select name="status">'; |
|
my $selstr = ''; |
|
if ($curr->{'status'} eq 'any') { |
|
$selstr = ' selected="selected"'; |
|
} |
|
$output .= '<option value="any"'.$selstr.'>'.&mt('Any status').'</option>'."\n"; |
|
foreach my $status (@{$statuses}) { |
|
my $selstr = ''; |
|
if ($curr->{'status'} eq $status) { |
|
$selstr = ' selected="selected"'; |
|
} |
|
my $statusname = $status; |
|
if (ref($statusnames) eq 'HASH') { |
|
if ($statusnames->{$status} ne '') { |
|
$statusname = $statusnames->{$status}; |
|
} |
|
} |
|
$output .= '<option value="'.$status.'"'.$selstr.'>'.$statusname.'</option>'."\n"; |
|
} |
|
$output .= '</select></td>'; |
|
} |
|
} |
|
$output .= '</tr></table>'; |
|
|
|
# Update Display button |
|
$output .= '<p>'. |
|
'<input type="submit" value="'.&mt('Update Display').'" />'. |
|
'</p><hr />'; |
|
return $output; |
|
} |
|
|
sub print_review { |
sub print_review { |
my ($formname,$dom,$codetitles,$cat_titles,$cat_order,$code_order) = @_; |
my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom, |
my ($types,$typename) = &course_types(); |
$disallowed,$disallowmsg,$instcredits) = @_; |
|
my ($types,$typename) = &Apache::loncommon::course_types(); |
my ($owner,$ownername,$owneremail); |
my ($owner,$ownername,$owneremail); |
$owner = $env{'user.name'}.':'.$env{'user.domain'}; |
if ($uname eq '' || $udom eq '') { |
$ownername = &Apache::loncommon::plainname($env{'user.name'}, |
$uname = $env{'user.name'}; |
$env{'user.domain'},'first'); |
$udom = $env{'user.domain'}; |
my %emails = &Apache::loncommon::getemails(); |
} |
|
$owner = $uname.':'.$udom; |
|
$ownername = &Apache::loncommon::plainname($uname,$udom,'first'); |
|
my %emails = &Apache::loncommon::getemails($uname,$udom); |
foreach my $email ('permanentemail','critnotification','notification') { |
foreach my $email ('permanentemail','critnotification','notification') { |
$owneremail = $emails{$email}; |
$owneremail = $emails{$email}; |
last if ($owneremail ne ''); |
last if ($owneremail ne ''); |
Line 1030 sub print_review {
|
Line 2627 sub print_review {
|
$crstypename = $env{'form.crstype'}; |
$crstypename = $env{'form.crstype'}; |
if (ref($typename) eq 'HASH') { |
if (ref($typename) eq 'HASH') { |
unless ($typename->{$env{'form.crstype'}} eq '') { |
unless ($typename->{$env{'form.crstype'}} eq '') { |
$crstypename = $typename->{$env{'form.crstype'}}; |
$crstypename = &mt($typename->{$env{'form.crstype'}}); |
} |
} |
} |
} |
|
my $category = 'Course'; |
|
if ($env{'form.crstype'} eq 'community') { |
|
$category = 'Community'; |
|
} |
|
|
$inst_headers = '<th>'.&mt('Description').'</th><th>'.&mt('Type').'</th>'; |
$inst_headers = '<th>'.&mt('Description').'</th><th>'.&mt('Type').'</th>'; |
$inst_values = '<td>'.$env{'form.cdescr'}.'</td><td>'.$crstypename.'</td>'; |
$inst_values = '<td>'.$env{'form.cdescr'}.'</td><td>'.$crstypename.'</td>'; |
|
|
|
my $enrollrow_title = &mt('Default Access Dates').'<br />'. |
|
'('.&Apache::lonnet::plaintext('st',$category).')'; |
if ($env{'form.crstype'} eq 'official') { |
if ($env{'form.crstype'} eq 'official') { |
if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) { |
if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) { |
foreach my $title (@{$codetitles}) { |
foreach my $title (@{$codetitles}) { |
Line 1052 sub print_review {
|
Line 2655 sub print_review {
|
} |
} |
} |
} |
} |
} |
|
$inst_headers .= '<th>'.&mt('Credits').'</th>'; |
|
if ($instcredits) { |
|
$inst_values .= '<td>'.$instcredits.'</td>'; |
|
} else { |
|
$inst_values .= '<td>'.$env{'form.coursecredits'}.'</td>'; |
|
} |
if (&Apache::lonnet::auto_run('',$dom)) { |
if (&Apache::lonnet::auto_run('',$dom)) { |
|
$enrollrow_title = &mt('Enrollment'); |
$enroll_headers = '<th>'.&mt('Automatic Adds').'</th>'. |
$enroll_headers = '<th>'.&mt('Automatic Adds').'</th>'. |
'<th>'.&mt('Automatic Drops').'</th>'. |
'<th>'.&mt('Automatic Drops').'</th>'. |
'<th>'.&mt('Enrollment Starts').'</th>'. |
'<th>'.&mt('Enrollment Starts').'</th>'. |
Line 1060 sub print_review {
|
Line 2670 sub print_review {
|
$section_headers = '<th>'.&mt('Sections').'</th>'. |
$section_headers = '<th>'.&mt('Sections').'</th>'. |
'<th>'.&mt('Crosslistings').'</th>'; |
'<th>'.&mt('Crosslistings').'</th>'; |
|
|
my ($startenroll,$endenroll) = &dates_from_form('startenroll','endenroll'); |
my ($enrollstart,$enrollend) = &dates_from_form('enrollstart','enrollend'); |
my @autoroster = (&mt('No'),&mt('Yes')); |
my @autoroster = (&mt('No'),&mt('Yes')); |
$enroll_values = '<td>'.$autoroster[$env{'form.autoadds'}].'</td>'. |
$enroll_values = '<td>'.$autoroster[$env{'form.autoadds'}].'</td>'. |
'<td>'.$autoroster[$env{'form.autodrops'}].'</td>'. |
'<td>'.$autoroster[$env{'form.autodrops'}].'</td>'. |
'<td>'.&Apache::lonlocal::locallocaltime($startenroll).'</td>'. |
'<td>'.&Apache::lonlocal::locallocaltime($enrollstart).'</td>'. |
'<td>'.&Apache::lonlocal::locallocaltime($endenroll).'</td>'; |
'<td>'.&Apache::lonlocal::locallocaltime($enrollend).'</td>'; |
$section_values = '<td><table class="LC_innerpickbox"><tr><th>'. |
$section_values = '<td><table class="LC_innerpickbox"><tr><th>'. |
&mt('Institutional section').'</th>'. |
&mt('Institutional section').'</th>'. |
'<th>'.&mt('LON-CAPA section').'</th></tr>'; |
'<th>'.&mt('LON-CAPA section').'</th></tr>'; |
Line 1091 sub print_review {
|
Line 2701 sub print_review {
|
&mt('Institutional course/section').'</th>'. |
&mt('Institutional course/section').'</th>'. |
'<th>'.&mt('LON-CAPA section').'</th></tr>'; |
'<th>'.&mt('LON-CAPA section').'</th></tr>'; |
my $xlistinfo; |
my $xlistinfo; |
if ($env{'form.crosslisttotal'}) { |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) { |
if (!$crosslisttotal) { |
if ($env{'form.crosslist_'.$i}) { |
$crosslisttotal = 1; |
$xlistinfo .= '<tr><td>'; |
} |
if (ref($code_order) eq 'ARRAY') { |
for (my $i=0; $i<$crosslisttotal; $i++) { |
if (@{$code_order} > 0) { |
if ($env{'form.crosslist_'.$i}) { |
foreach my $item (@{$code_order}) { |
$xlistinfo .= '<tr><td>'; |
$xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item}; |
if (ref($code_order) eq 'ARRAY') { |
} |
if (@{$code_order} > 0) { |
|
foreach my $item (@{$code_order}) { |
|
$xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item}; |
} |
} |
} |
} |
$xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>'; |
|
if ($env{'form.crosslist_'.$i.'_lcsec'}) { |
|
$xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'}; |
|
} else { |
|
$xlistinfo .= &mt('None'); |
|
} |
|
$xlistinfo .= '</td></tr>'; |
|
} |
} |
|
$xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>'; |
|
if ($env{'form.crosslist_'.$i.'_lcsec'}) { |
|
$xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'}; |
|
} else { |
|
$xlistinfo .= &mt('None'); |
|
} |
|
$xlistinfo .= '</td></tr>'; |
} |
} |
} |
} |
if ($xlistinfo eq '') { |
if ($xlistinfo eq '') { |
$xlistinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>'; |
$xlistinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>'; |
} |
} |
$section_values .= $xlistinfo.'</table></td>'; |
$section_values .= $xlistinfo; |
} |
} |
|
$section_values .= '</table></td>'; |
|
} elsif ($env{'form.crstype'} eq 'unofficial') { |
|
$inst_headers .= '<th>'.&mt('Credits').'</th>'; |
|
$inst_values .= '<td>'.$env{'form.coursecredits'}.'</td>'; |
} |
} |
|
|
my %ctxt = &clone_text(); |
my %ctxt = &clone_text(); |
$inst_headers .= '<th>'.&mt('Clone From').'</th>'; |
$inst_headers .= '<th>'.&mt('Clone From').'</th>'; |
if (($env{'form.clonecourse'} =~ /^$match_name$/) && |
if (($env{'form.cloning'}) && |
($env{'form.clonedomain'} =~ /^$match_domain$/)) { |
($env{'form.clonecrs'} =~ /^$match_name$/) && |
my %coursehash = |
($env{'form.clonedom'} =~ /^$match_domain$/)) { |
&Apache::lonnet::courseiddump($env{'form.clonedomain'},'.',1,'.','.', |
my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname, |
$env{'form.clonecourse'},undef,undef,'.'); |
$udom,$env{'form.clonecrs'},$env{'form.clonedom'}, |
my $cloneid = $env{'form.clonedomain'}.'_'.$env{'form.clonecourse'}; |
$env{'form.crstype'}); |
if (ref($coursehash{$cloneid}) eq 'HASH') { |
if ($canclone) { |
$inst_headers .= '<th>'.$ctxt{'dsh'}.'</th>'; |
my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'}, |
my $clonedesc = $coursehash{$cloneid}{'description'}; |
$env{'form.clonecrs'},('description','internal.coursecode')); |
my $cloneinst = $coursehash{$cloneid}{'inst_code'}; |
if (keys(%courseenv) > 0) { |
|
$inst_headers .= '<th>'.$ctxt{'dsh'}.'</th>'; |
$inst_values .= '<td>'.$clonedesc.' '; |
$inst_values .= '<td>'.$courseenv{'description'}.' '; |
if ($cloneinst ne '') { |
my $cloneinst = $courseenv{'internal.coursecode'}; |
$inst_values .= &mt('([_1] in [_2])',$cloneinst,$env{'form.clonedomain'}); |
if ($cloneinst ne '') { |
} else { |
$inst_values .= $cloneinst.' '.&mt('in').' '.$env{'form.clonedom'}; |
$inst_values .= &mt('(from [_1])',$env{'form.clonedomain'}); |
} else { |
} |
$inst_values .= &mt('from').' '.$env{'form.clonedom'}; |
$inst_values .= '</td><td>'; |
} |
if ($env{'form.datemode'} eq 'preserve') { |
$inst_values .= '</td><td>'; |
$inst_values .= $ctxt{'pcd'}; |
if ($env{'form.datemode'} eq 'preserve') { |
} elsif ($env{'form.datemode'} eq 'shift') { |
$inst_values .= $ctxt{'prd'}; |
$inst_values .= &mt('Shift dates by [_1] days',$env{'form.dateshift'}); |
} elsif ($env{'form.datemode'} eq 'shift') { |
} else { |
$inst_values .= &mt('Shift dates by [_1] days',$env{'form.dateshift'}); |
$inst_values .= $ctxt{'ncd'}; |
} else { |
} |
$inst_values .= $ctxt{'ncd'}; |
$inst_values .= '</td>'; |
} |
} else { |
$inst_values .= '</td>'; |
$inst_values .= '<td>'.&mt('Unknown').'</td>'; |
} else { |
} |
$inst_values .= '<td>'.&mt('Unknown').'</td>'; |
|
} |
|
} else { |
|
$inst_values .= '<td>'.&mt('Not permitted'),'</td>'; |
|
} |
} else { |
} else { |
$inst_values .= '<td>'.&mt('None').'</td>'; |
$inst_values .= '<td>'.&mt('None').'</td>'; |
} |
} |
$enroll_headers .= '<th>'.&mt('Access Starts').'</th>'. |
$enroll_headers .= '<th>'.&mt('Access Starts').'</th>'. |
'<th>'.&mt('Access Ends').'</th>'; |
'<th>'.&mt('Access Ends').'</th>'; |
my ($startaccess,$endaccess) = &dates_from_form('startaccess','endaccess'); |
my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend'); |
$enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($startaccess).'</td>'; |
$enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessstart).'</td>'; |
if ($endaccess == 0) { |
if ($accessend == 0) { |
$enroll_values .= '<td>'.&mt('No end date').'</td>'; |
$enroll_values .= '<td>'.&mt('No end date').'</td>'; |
} else { |
} else { |
$enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($endaccess).'</td>'; |
$enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessend).'</td>'; |
} |
} |
|
|
my $container = 'Course'; |
my $container = 'Course'; |
|
my $ccrole = 'cc'; |
if ($env{'form.crstype'} eq 'community') { |
if ($env{'form.crstype'} eq 'community') { |
$container = 'Community'; |
$container = 'Community'; |
|
$ccrole = 'co'; |
} |
} |
|
|
$personnel_headers = '<th>'.&mt('Name').'</th><th>'.&mt('Username:Domain'). |
$personnel_headers = '<th>'.&mt('Name').'</th><th>'.&mt('Username:Domain'). |
'</th><th>'.&mt('Role').'</th><th>'.&mt('LON-CAPA Sections'). |
'</th><th>'.&mt('Role').'</th><th>'.&mt('LON-CAPA Sections'). |
'</th>'; |
'</th>'; |
|
|
$personnel_values .= '<tr><td>'.$ownername.'</td><td>'.$owner.'</td>'. |
$personnel_values .= '<tr><td>'.$ownername.'</td><td>'.$owner.'</td>'. |
'<td>'.&Apache::lonnet::plaintext('cc',$container).'</td>'. |
'<td>'.&Apache::lonnet::plaintext($ccrole,$container).'</td>'. |
'<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 @officialsecs = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec'); |
|
my @allsecs; |
|
foreach my $sec (@officialsecs) { |
|
next unless ($sec =~ /\w/); |
|
next if ($sec =~ /\W/); |
|
next if ($sec eq 'none'); |
|
push(@allsecs,$sec); |
|
} |
|
my $newsec = $env{'form.person_'.$i.'_newsec'}; |
|
$newsec =~ s/^\s+//; |
|
$newsec =~s/\s+$//; |
|
my @newsecs = split(/\s*[\s,;:]\s*/,$newsec); |
|
foreach my $sec (@newsecs) { |
|
next unless ($sec =~ /\w/); |
|
next if ($sec =~ /\W/); |
|
next if ($sec eq 'none'); |
|
if ($sec ne '') { |
|
unless (grep(/^\Q$sec\E$/,@allsecs)) { |
|
push(@allsecs,$sec); |
|
} |
|
} |
|
} |
|
my $showsec; |
|
if (@allsecs) { |
|
$showsec = join(', ',@allsecs); |
|
} |
|
if ($showsec eq '') { |
|
$showsec = &mt('None'); |
|
} |
|
if ($env{'form.person_'.$i.'_role'} eq $ccrole) { |
|
$showsec = &mt('None'); |
|
} |
|
my $role = $env{'form.person_'.$i.'_role'}; |
$personnel_values .= |
$personnel_values .= |
'<tr><td>'.$env{'form.person_'.$i.'_first'}.' '. |
'<tr><td>'.$env{'form.person_'.$i.'_firstname'}.' '. |
$env{'form.person_'.$i.'_last'}.'</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>'.$env{'form.person_'.$i.'_sections'}.'</td></tr>'; |
} |
|
} |
|
my $output; |
|
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>'; |
|
} |
} |
} |
} |
} |
my $output = '<p>'.&mt('Review the details of the course request before submission.').'</p>'. |
$output .= '<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
'<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 1202 sub print_review {
|
Line 2872 sub print_review {
|
'<table class="LC_innerpickbox"><tr>'.$inst_headers.'</tr>'."\n". |
'<table class="LC_innerpickbox"><tr>'.$inst_headers.'</tr>'."\n". |
'<tr>'.$inst_values.'</tr></table>'."\n". |
'<tr>'.$inst_values.'</tr></table>'."\n". |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_title(&mt('Enrollment')). |
&Apache::lonhtmlcommon::row_title($enrollrow_title). |
'<table class="LC_innerpickbox"><tr>'.$enroll_headers.'</tr>'."\n". |
'<table class="LC_innerpickbox"><tr>'.$enroll_headers.'</tr>'."\n". |
'<tr>'.$enroll_values.'</tr></table>'."\n". |
'<tr>'.$enroll_values.'</tr></table>'."\n". |
&Apache::lonhtmlcommon::row_closure(); |
&Apache::lonhtmlcommon::row_closure(); |
Line 1216 sub print_review {
|
Line 2886 sub print_review {
|
'<table class="LC_innerpickbox"><tr>'.$personnel_headers.'</tr>'."\n". |
'<table class="LC_innerpickbox"><tr>'.$personnel_headers.'</tr>'."\n". |
$personnel_values.'</table>'."\n". |
$personnel_values.'</table>'."\n". |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::end_pick_box(); |
&Apache::lonhtmlcommon::end_pick_box().'</div>'; |
my $cnum = &Apache::lonnet::generate_coursenum($dom); |
|
$output .= '<input type="hidden" name="cnum" value="'.$cnum.'" />'; |
|
return $output; |
return $output; |
} |
} |
|
|
Line 1226 sub dates_from_form {
|
Line 2894 sub dates_from_form {
|
my ($startname,$endname) = @_; |
my ($startname,$endname) = @_; |
my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname); |
my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname); |
my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname); |
my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname); |
if ($endname eq 'endaccess') { |
if ($endname eq 'accessend') { |
if (exists($env{'form.no_end_date'}) ) { |
if (exists($env{'form.no_end_date'}) ) { |
$enddate = 0; |
$enddate = 0; |
} |
} |
Line 1235 sub dates_from_form {
|
Line 2903 sub dates_from_form {
|
} |
} |
|
|
sub courseinfo_form { |
sub courseinfo_form { |
my ($dom,$formname,$crstype) = @_; |
my ($dom,$formname,$crstype,$next,$description) = @_; |
my $output = '<div>'.&Apache::lonhtmlcommon::start_pick_box(). |
my %lt = &Apache::lonlocal::texthash( |
&Apache::lonhtmlcommon::row_title('Course Description'). |
official => 'You must provide a (brief) course description.', |
'<input type="text" size="40" name="cdescr" />'. |
community => 'You must provide a (brief) community description.' |
&Apache::lonhtmlcommon::row_closure(1). |
); |
&Apache::lonhtmlcommon::end_pick_box().'</div>'. |
$lt{'unofficial'} = $lt{'official'}; |
'<div>'.&clone_form($dom,$formname,$crstype).'</div>'."\n"; |
my $js_validate = <<"ENDJS"; |
|
<script type="text/javascript"> |
|
// <![CDATA[' |
|
|
|
function validateForm() { |
|
if ((document.$formname.cdescr.value == "") || (document.$formname.cdescr.value == "undefined")) { |
|
alert('$lt{$crstype}'); |
|
return; |
|
} |
|
nextPage(document.$formname,'$next'); |
|
} |
|
|
|
function toggleCloning() { |
|
var willclone; |
|
if (document.$formname.cloning.length > 1) { |
|
for (var i=0; i<document.$formname.cloning.length; i++) { |
|
if (document.$formname.cloning[i].checked) { |
|
willclone = document.$formname.cloning[i].value; |
|
} |
|
} |
|
} |
|
if (willclone == 1) { |
|
document.getElementById('cloneoptions').style.display="block"; |
|
} else { |
|
document.getElementById('cloneoptions').style.display="none"; |
|
document.$formname.clonecrs.value = ''; |
|
} |
|
} |
|
|
|
// ]] |
|
</script> |
|
|
|
ENDJS |
|
my $title = &mt('Brief Course Description'); |
|
my $clonetitle = &mt('Clone content and settings from an existing course?'); |
|
if ($crstype eq 'community') { |
|
$title = &mt('Brief Community Description'); |
|
$clonetitle = &mt('Clone content and settings from an existing community?'); |
|
} |
|
my $output .= $js_validate."\n".&Apache::lonhtmlcommon::start_pick_box(). |
|
&Apache::lonhtmlcommon::row_headline(). |
|
'<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="60" name="cdescr" value="'.$description.'" />'; |
|
my ($home_server_pick,$numlib) = |
|
&Apache::loncommon::home_server_form_item($dom,'chome', |
|
'default','hide'); |
|
if ($numlib > 1) { |
|
$output .= &Apache::lonhtmlcommon::row_closure(). |
|
&Apache::lonhtmlcommon::row_title(&mt('Home Server for Course')); |
|
} |
|
$output .= $home_server_pick. |
|
&Apache::lonhtmlcommon::row_closure(). |
|
&Apache::lonhtmlcommon::row_headline(). |
|
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Clone').' '.$clonetitle. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
&Apache::lonhtmlcommon::row_title(&mt('Clone?')). |
|
'<label><input type="radio" name="cloning" value="1" '. |
|
'onclick="javascript:toggleCloning()" />'. |
|
&mt('Yes').(' 'x2).'</label><label>'. |
|
'<input type="radio" name="cloning" value="0" checked="checked" '. |
|
'onclick="javascript:toggleCloning()" />'.&mt('No').'</label>'. |
|
'</h3>'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
&Apache::lonhtmlcommon::row_headline(). |
|
'<div id="cloneoptions" style="display: none" >'. |
|
&Apache::lonhtmlcommon::start_pick_box(). |
|
&clone_form($dom,$formname,$crstype). |
|
&Apache::lonhtmlcommon::end_pick_box().'</div>'. |
|
&Apache::lonhtmlcommon::end_pick_box()."\n"; |
return $output; |
return $output; |
} |
} |
|
|
Line 1251 sub clone_form {
|
Line 2989 sub clone_form {
|
if ($crstype eq 'community') { |
if ($crstype eq 'community') { |
$type = 'Community'; |
$type = 'Community'; |
} |
} |
my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedomain'). |
|
&Apache::loncommon::selectcourse_link($formname,'clonecourse','clonedomain','','','',$type); |
|
my %lt = &clone_text(); |
my %lt = &clone_text(); |
my $output .= |
my $output .= |
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title($lt{'dmn'}).'<label>'. |
|
&Apache::loncommon::select_dom_form($dom,'clonedom').'</label>'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'. |
&Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'. |
'<input type="text" size="25" name="clonecourse" value="" onfocus="this.blur();'. |
'<input type="text" size="25" name="clonecrs" value="" onfocus="this.blur();opencrsbrowser('."'$formname','clonecrs','clonedom','','','','','$type'".')" />'. |
'opencrsbrowser('."'$formname','clonecourse','clonedomain','','','','$type'".');" />'. |
'</label> '. |
'</label>'.&Apache::lonhtmlcommon::row_closure(1).'<label>'. |
&Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type). |
&Apache::lonhtmlcommon::row_title($lt{'dmn'}).'</label>'. |
&Apache::lonhtmlcommon::row_closure(1). |
$cloneform.'</label>'.&Apache::lonhtmlcommon::row_closure(). |
|
&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 1270 sub clone_form {
|
Line 3007 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; |
} |
} |
|
|
sub clone_text { |
sub clone_text { |
return &Apache::lonlocal::texthash( |
return &Apache::lonlocal::texthash( |
'cid' => 'Course ID', |
'cid' => 'Course ID', |
'dmn' => 'Domain', |
'dmn' => 'Domain', |
Line 1289 sub clone_text {
|
Line 3025 sub clone_text {
|
sub coursecode_form { |
sub coursecode_form { |
my ($dom,$context,$codetitles,$cat_titles,$cat_order,$num) = @_; |
my ($dom,$context,$codetitles,$cat_titles,$cat_order,$num) = @_; |
my $output; |
my $output; |
my %rowtitle = ( |
my %rowtitle = &Apache::lonlocal::texthash ( |
instcode => 'Course Category', |
instcode => 'Course Category', |
crosslist => 'Cross Listed Course', |
crosslist => 'Cross Listed Course', |
); |
); |
|
my %helpitem = ( |
|
instcode => 'Course_Request_Category', |
|
); |
if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') && |
if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') && |
(ref($cat_order))) { |
(ref($cat_order))) { |
my ($sel,$instsec,$lcsec); |
my ($sel,$instsec,$lcsec); |
Line 1308 sub coursecode_form {
|
Line 3047 sub coursecode_form {
|
my $lastitem = pop(@{$codetitles}); |
my $lastitem = pop(@{$codetitles}); |
my $lastinput = '<input type="text" size="5" name="'.$sel.'_'. $lastitem.'" />'; |
my $lastinput = '<input type="text" size="5" name="'.$sel.'_'. $lastitem.'" />'; |
if (@{$codetitles} > 0) { |
if (@{$codetitles} > 0) { |
$output = &Apache::lonhtmlcommon::row_title($rowtitle{$context}). |
my $helplink; |
|
if (defined($helpitem{$context})) { |
|
$helplink = &Apache::loncommon::help_open_topic($helpitem{$context}).' '; |
|
} |
|
$output = &Apache::lonhtmlcommon::row_title($helplink.$rowtitle{$context}). |
'<table><tr>'; |
'<table><tr>'; |
if ($context eq 'crosslist') { |
if ($context eq 'crosslist') { |
$output .= '<td>'.&mt('Include?').'<br />'. |
$output .= '<td>'.&mt('Include?').'<br />'. |
Line 1373 sub coursecode_form {
|
Line 3116 sub coursecode_form {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub sections_form { |
|
my ($dom,$instcode,$num) = @_; |
|
my $rowtitle; |
|
if ($instcode eq '') { |
|
$rowtitle = &mt('Sections'); |
|
} else { |
|
$rowtitle = &mt('Sections of [_1]',$instcode); |
|
} |
|
return &Apache::lonhtmlcommon::row_title($rowtitle). |
|
'<table><tr><td align="center">'. |
|
'<span class="LC_nobreak">'.&mt('Include?'). |
|
'<input type="checkbox" name="sec_'.$num.'" value="1" /></span>'. |
|
'</td><td align="center">'.&mt('Institutional section').'<br />'. |
|
'<input type="text" size="10" name="secnum_'.$num.'" />'. |
|
'</td><td align="center">'.&mt('LON-CAPA section').'<br />'. |
|
'<input type="text" size="10" name="loncapasec_'.$num.'" />'. |
|
'</td></tr></table>'. |
|
&Apache::lonhtmlcommon::row_closure(1); |
|
} |
|
|
sub get_course_dom { |
sub get_course_dom { |
my $codedom = &Apache::lonnet::default_login_domain(); |
my $codedom = &Apache::lonnet::default_login_domain(); |
|
if ($env{'form.showdom'} ne '') { |
|
if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') { |
|
return $env{'form.showdom'}; |
|
} |
|
} |
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { |
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { |
|
my ($types,$typename) = &Apache::loncommon::course_types(); |
|
if (ref($types) eq 'ARRAY') { |
|
foreach my $type (@{$types}) { |
|
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
|
$env{'user.domain'},$type, |
|
undef,'requestcourses')) { |
|
return $env{'user.domain'}; |
|
} |
|
} |
|
my @possible_doms; |
|
foreach my $type (@{$types}) { |
|
my $dom_str = $env{'environment.reqcrsotherdom.'.$type}; |
|
if ($dom_str ne '') { |
|
my @domains = split(',',$dom_str); |
|
foreach my $entry (@domains) { |
|
my ($extdom,$extopt) = split(':',$entry); |
|
if ($extdom eq $env{'request.role.domain'}) { |
|
return $extdom; |
|
} |
|
unless(grep(/^\Q$extdom\E$/,@possible_doms)) { |
|
push(@possible_doms,$extdom); |
|
} |
|
} |
|
} |
|
} |
|
if (@possible_doms) { |
|
@possible_doms = sort(@possible_doms); |
|
return $possible_doms[0]; |
|
} |
|
} |
$codedom = $env{'user.domain'}; |
$codedom = $env{'user.domain'}; |
if ($env{'request.role.domain'} ne '') { |
if ($env{'request.role.domain'} ne '') { |
$codedom = $env{'request.role.domain'}; |
$codedom = $env{'request.role.domain'}; |
} |
} |
} |
} |
if ($env{'form.showdom'} ne '') { |
|
if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') { |
|
$codedom = $env{'form.showdom'}; |
|
} |
|
} |
|
return $codedom; |
return $codedom; |
} |
} |
|
|
sub display_navbuttons { |
sub display_navbuttons { |
my ($r,$formname,$prev,$prevtext,$next,$nexttext) = @_; |
my ($r,$dom,$formname,$prev,$prevtext,$next,$nexttext,$state,$other,$othertext) = @_; |
$r->print('<div class="LC_navbuttons">'); |
$r->print('<div class="LC_navbuttons">'); |
if ($prev) { |
if ($prev) { |
$r->print(' |
$r->print('<input type="button" name="previous" value = "'.$prevtext.'" '. |
<input type="button" name="previous" value = "'.$prevtext.'" |
'onclick="javascript:backPage('."document.$formname,'$prev'".')"/>'. |
onclick="javascript:backPage(document.'.$formname.','."'".$prev."'".')"/> |
(' 'x3)); |
'); |
|
} elsif ($prevtext) { |
} elsif ($prevtext) { |
$r->print(' |
$r->print('<input type="button" name="previous" value = "'.$prevtext.'" '. |
<input type="button" name="previous" value = "'.$prevtext.'" |
'onclick="javascript:history.back()"/>'.(' 'x3)); |
onclick="javascript:history.back()"/> |
} |
'); |
if ($state eq 'details') { |
} |
$r->print(' <input type="button" name="other" value="'.$othertext.'" '. |
if ($next) { |
'onclick="javascript:nextPage('."document.$formname,'$other'". |
$r->print(' |
')" />'); |
<input type="button" name="next" value="'.$nexttext.'" |
} |
onclick="javascript:nextPage(document.'.$formname.','."'".$next."'".')" />'); |
my $gotnext; |
|
if ($state eq 'courseinfo') { |
|
$r->print('<input type="button" name="next" value="'.$nexttext.'" '. |
|
'onclick="javascript:validateForm();" />'); |
|
$gotnext = 1; |
|
} elsif ($state eq 'enrollment') { |
|
if (($env{'form.crstype'} eq 'official') && |
|
(&Apache::lonnet::auto_run('',$dom))) { |
|
$r->print('<input type="button" name="next" value="'.$nexttext.'" '. |
|
'onclick="javascript:validateEnrollSections('."document.$formname,'$next'".');" />'); |
|
$gotnext = 1; |
|
} |
|
} elsif ($state eq 'personnel') { |
|
if ($env{'form.persontotal'} > 0) { |
|
$r->print('<input type="button" name="next" value="'.$nexttext.'" '. |
|
'onclick="javascript:validatePersonnelSections('."document.$formname,'$next'".');" />'); |
|
$gotnext = 1; |
|
} |
|
} |
|
unless ($gotnext) { |
|
if ($next) { |
|
$r->print(' |
|
<input type="button" name="next" value="'.$nexttext.'" '. |
|
'onclick="javascript:nextPage('."document.$formname,'$next'".')" />'); |
|
} |
} |
} |
$r->print('</div>'); |
$r->print('</div>'); |
} |
} |
|
|
sub print_request_outcome { |
sub print_request_outcome { |
my ($dom,$codetitles,$code_order) = @_; |
my ($dom,$codetitles,$code_order,$instcredits) = @_; |
my ($output,$cnum,$now,$req_notifylist,$crstype,$startenroll,$endenroll, |
my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend, |
%sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,); |
%sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig); |
|
my $sectotal = $env{'form.sectotal'}; |
|
my $crosslisttotal = 0; |
$cnum = $env{'form.cnum'}; |
$cnum = $env{'form.cnum'}; |
unless ($cnum =~ /^$match_courseid$/) { |
unless ($cnum =~ /^$match_courseid$/) { |
$output = &mt('Invalid LON-CAPA course number for the new course')."\n"; |
$output = &mt('Invalid LON-CAPA course number for the new course')."\n"; |
Line 1429 sub print_request_outcome {
|
Line 3247 sub print_request_outcome {
|
} |
} |
$now = time; |
$now = time; |
$crstype = $env{'form.crstype'}; |
$crstype = $env{'form.crstype'}; |
|
my $ccrole = 'cc'; |
|
if ($crstype eq 'community') { |
|
$ccrole = 'co'; |
|
} |
|
my @instsections; |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
if (&Apache::lonnet::auto_run('',$dom)) { |
if (&Apache::lonnet::auto_run('',$dom)) { |
($startenroll,$endenroll)=&dates_from_form('startenroll','endenroll'); |
($enrollstart,$enrollend)=&dates_from_form('enrollstart','enrollend'); |
} |
} |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
if ($env{'form.sec_'.$i}) { |
if ($env{'form.sec_'.$i}) { |
if ($env{'form.secnum_'.$i} ne '') { |
if ($env{'form.secnum_'.$i} ne '') { |
$sections{$env{'form.secnum_'.$i}} = $env{'form.loncapasec_'.$i}; |
my $sec = $env{'form.secnum_'.$i}; |
|
$sections{$i}{'inst'} = $sec; |
|
if (($sec ne '') && (!grep(/^\Q$sec\E$/,@instsections))) { |
|
push(@instsections,$sec); |
|
} |
|
$sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i}; |
|
$sections{$i}{'loncapa'} =~ s/\W//g; |
|
if ($sections{$i}{'loncapa'} eq 'none') { |
|
$sections{$i}{'loncapa'} = ''; |
|
} |
} |
} |
} |
} |
} |
} |
Line 1450 sub print_request_outcome {
|
Line 3282 sub print_request_outcome {
|
} |
} |
} |
} |
} |
} |
$xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}; |
$crosslistings{$i}{'instcode'} = $xlistinfo; |
$crosslistings{$xlistinfo} = $env{'form.crosslist_'.$i.'_lcsec'}; |
if ($xlistinfo ne '') { |
|
$crosslisttotal ++; |
|
} |
|
$crosslistings{$i}{'instsec'} = $env{'form.crosslist_'.$i.'_instsec'}; |
|
$crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'}; |
} |
} |
} |
} |
|
} else { |
|
$enrollstart = ''; |
|
$enrollend = ''; |
} |
} |
|
my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg,%skipped); |
for (my $i=0; $i<$env{'form.persontotal'}; $i++) { |
for (my $i=0; $i<$env{'form.persontotal'}; $i++) { |
my $uname = $env{'form.person_'.$i.'_uname'}; |
my $uname = $env{'form.person_'.$i.'_uname'}; |
my $udom = $env{'form.person_'.$i.'_uname'}; |
my $udom = $env{'form.person_'.$i.'_dom'}; |
if (($uname =~ /^$match_username$/) && ($udom =~ /^$match_domain$/)) { |
if (($uname =~ /^$match_username$/) && ($udom =~ /^$match_domain$/)) { |
if (&Apache::lonnet::domain($udom) ne '') { |
if (&Apache::lonnet::domain($udom) ne '') { |
$personnel{$uname.':'.$udom} = { |
unless (ref($personnel{$uname.':'.$udom}) eq 'HASH') { |
first => $env{'form.person_'.$i.'_first'}, |
$personnel{$uname.':'.$udom} = { |
last => $env{'form.person_'.$i.'_last'}, |
firstname => $env{'form.person_'.$i.'_firstname'}, |
email => $env{'form.person_'.$i.'_email'}, |
lastname => $env{'form.person_'.$i.'_lastname'}, |
role => $env{'form.person_'.$i.'_role'}, |
emailaddr => $env{'form.person_'.$i.'_emailaddr'}, |
sections => $env{'form.person_'.$i.'_sections'}, |
}; |
}; |
if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
my $usertype = &get_usertype($udom,$uname,\%curr_rules,\%got_rules); |
|
if (&Apache::lonuserutils::can_create_user($udom,'requestcrs',$usertype)) { |
|
my ($allowed,$msg,$authtype,$authparam) = |
|
&check_newuser_rules($udom,$uname,\%alerts,\%rulematch, |
|
\%inst_results,\%curr_rules,\%got_rules); |
|
if ($allowed) { |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($udom); |
|
if ($usertype eq 'official') { |
|
if ($authtype eq '') { |
|
$authtype = $domdefaults{'auth_def'}; |
|
$authparam = $domdefaults{'auth_arg_def'}; |
|
} else { |
|
if ($authtype eq 'loc') { |
|
$authtype = 'localauth'; |
|
} elsif ($authtype eq 'int') { |
|
$authtype = 'internal'; |
|
} |
|
if ($authtype !~ /^(krb4|krb5|internal|localauth)$/) { |
|
$authtype = $domdefaults{'auth_def'}; |
|
$authparam = $domdefaults{'auth_arg_def'}; |
|
} |
|
} |
|
} elsif ($usertype eq 'unofficial') { |
|
if ($authtype eq '') { |
|
$authtype = 'internal'; |
|
$authparam = ''; |
|
} |
|
} else { |
|
$authtype = $domdefaults{'auth_def'}; |
|
$authparam = $domdefaults{'auth_arg_def'}; |
|
} |
|
if (($authtype eq '') || |
|
(($authtype =~/^krb(4|5)$/) && ($authparam eq '')) || |
|
($authtype !~ /^(krb4|krb5|internal|localauth)$/)) { |
|
$skipped{$uname.':'.$udom} = 1; |
|
next; |
|
} else { |
|
$personnel{$uname.':'.$udom}{'authtype'} = $authtype; |
|
$personnel{$uname.':'.$udom}{'autharg'} = $authparam; |
|
} |
|
} else { |
|
$skipped{$uname.':'.$udom} = 1; |
|
next; |
|
} |
|
} else { |
|
$skipped{$uname.':'.$udom} = 1; |
|
next; |
|
} |
|
} |
|
} |
|
my $role = $env{'form.person_'.$i.'_role'}; |
|
unless ($role eq '') { |
|
if (ref($personnel{$uname.':'.$udom}{'roles'}) eq 'ARRAY') { |
|
my @curr_roles = @{$personnel{$uname.':'.$udom}{'roles'}}; |
|
unless (grep(/^\Q$role\E$/,@curr_roles)) { |
|
push(@{$personnel{$uname.':'.$udom}{'roles'}},$role); |
|
} |
|
} else { |
|
@{$personnel{$uname.':'.$udom}{'roles'}} = ($role); |
|
} |
|
if ($role eq $ccrole) { |
|
@{$personnel{$uname.':'.$udom}{$role}{'usec'}} = (); |
|
} else { |
|
my @currsec = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec'); |
|
my @allsecs; |
|
foreach my $sec (@currsec) { |
|
next unless ($sec =~ /\w/); |
|
next if ($sec =~ /\W/); |
|
next if ($sec eq 'none'); |
|
push(@allsecs,$sec); |
|
} |
|
my $newsec = $env{'form.person_'.$i.'_newsec'}; |
|
$newsec =~ s/^\s+//; |
|
$newsec =~s/\s+$//; |
|
my @newsecs = split(/[\s,;]+/,$newsec); |
|
foreach my $sec (@newsecs) { |
|
next if ($sec =~ /\W/); |
|
next if ($sec eq 'none'); |
|
if ($sec ne '') { |
|
unless (grep(/^\Q$sec\E$/,@allsecs)) { |
|
push(@allsecs,$sec); |
|
} |
|
} |
|
} |
|
@{$personnel{$uname.':'.$udom}{$role}{'usec'}} = @allsecs; |
|
} |
|
} |
} else { |
} else { |
push(@missingdom,$uname.':'.$udom); |
push(@missingdom,$uname.':'.$udom); |
} |
} |
Line 1475 sub print_request_outcome {
|
Line 3401 sub print_request_outcome {
|
push(@baduname,$uname.':'.$udom); |
push(@baduname,$uname.':'.$udom); |
} |
} |
} |
} |
|
if (keys(%skipped)) { |
my ($startaccess,$endaccess) = &dates_from_form('startaccess','endacess'); |
foreach my $key (keys(%skipped)) { |
|
delete($personnel{$key}); |
|
} |
|
} |
|
my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend'); |
|
my $autodrops = 0; |
|
if ($env{'form.autodrops'}) { |
|
$autodrops = $env{'form.autodrops'}; |
|
} |
|
my $autoadds = 0; |
|
if ($env{'form.autoadds'}) { |
|
$autoadds = $env{'form.autoadds'}; |
|
} |
|
my $instcode = ''; |
|
if (exists($env{'form.instcode'})) { |
|
$instcode = $env{'form.instcode'}; |
|
} |
|
my $credits; |
|
if ($instcredits) { |
|
$credits = $instcredits; |
|
} elsif (exists($env{'form.coursecredits'})) { |
|
$credits = $env{'form.coursecredits'}; |
|
} |
|
my $clonecrs = ''; |
|
my $clonedom = ''; |
|
if (($env{'form.cloning'}) && |
|
($env{'form.clonecrs'} =~ /^($match_courseid)$/) && |
|
($env{'form.clonedom'} =~ /^($match_domain)$/)) { |
|
my $clonehome = &Apache::lonnet::homeserver($env{'form.clonecrs'}, |
|
$env{'form.clonedom'}); |
|
if ($clonehome ne 'no_host') { |
|
my $canclone = |
|
&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
|
$env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'}, |
|
$crstype); |
|
if ($canclone) { |
|
$clonecrs = $env{'form.clonecrs'}; |
|
$clonedom = $env{'form.clonedom'}; |
|
} |
|
} |
|
} |
my $details = { |
my $details = { |
owner => $env{'user.name'}, |
owner => $env{'user.name'}, |
domain => $env{'user.domain'}, |
domain => $env{'user.domain'}, |
cdom => $dom, |
cdom => $dom, |
cnum => $cnum, |
cnum => $cnum, |
cdesc => $env{'form.cdesc'}, |
coursehome => $env{'form.chome'}, |
|
cdescr => $env{'form.cdescr'}, |
crstype => $env{'form.crstype'}, |
crstype => $env{'form.crstype'}, |
instcode => $env{'form.instcode'}, |
instcode => $instcode, |
clonedomain => $env{'form.clonedomain'}, |
defaultcredits => $credits, |
clonecourse => $env{'form.clonecourse'}, |
clonedom => $clonedom, |
|
clonecrs => $clonecrs, |
datemode => $env{'form.datemode'}, |
datemode => $env{'form.datemode'}, |
dateshift => $env{'form.datshift'}, |
dateshift => $env{'form.dateshift'}, |
sectotal => $env{'form.sectotal'}, |
sectotal => $sectotal, |
sections => \%sections, |
sections => \%sections, |
crosslisttotal => $env{'form.crosslisttotal'}, |
crosslisttotal => $crosslisttotal, |
crosslistings => \%crosslistings, |
crosslists => \%crosslistings, |
autoadds => $env{'form.autoadds'}, |
autoadds => $autoadds, |
autodrops => $env{'form.autodrops'}, |
autodrops => $autodrops, |
startenroll => $startenroll, |
enrollstart => $enrollstart, |
endenroll => $endenroll, |
enrollend => $enrollend, |
startaccess => $startaccess, |
accessstart => $accessstart, |
endaccess => $endaccess, |
accessend => $accessend, |
personnel => \%personnel, |
personnel => \%personnel, |
}; |
}; |
my @inststatuses; |
my (@inststatuses,$storeresult,$creationresult); |
my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig); |
my $val = |
|
&Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'}, |
|
$env{'user.domain'},$env{'user.adv'}, |
|
$dom,$crstype,\@inststatuses,\%domconfig); |
if ($val eq '') { |
if ($val eq '') { |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
$output = &mt('You are not permitted to request creation of official courses'); |
$output = &mt('You are not permitted to request creation of official courses.'); |
} elsif ($crstype eq 'unofficial') { |
} elsif ($crstype eq 'unofficial') { |
$output = &mt('You are not permitted to request creation of unofficial courses'); |
$output = &mt('You are not permitted to request creation of unofficial courses.'); |
} elsif ($crstype eq 'community') { |
} elsif ($crstype eq 'community') { |
$output = &mt('You are not permitted to request creation of communities'); |
$output = &mt('You are not permitted to request creation of communities'); |
} else { |
} else { |
$output = &mt('Unrecognized course type: [_1]',$crstype); |
$output = &mt('Unrecognized course type: [_1]',$crstype); |
} |
} |
|
$storeresult = 'notpermitted'; |
} else { |
} else { |
my ($disposition,$message); |
my ($disposition,$message,$reqstatus); |
my %reqhash = ( |
my %reqhash = ( |
timestamp => $now, |
reqtime => $now, |
crstype => $crstype, |
crstype => $crstype, |
details => $details, |
details => $details, |
); |
); |
my $requestkey = $dom.'_'.$cnum; |
my $requestkey = $dom.'_'.$cnum; |
|
my $validationerror; |
if ($val eq 'autolimit=') { |
if ($val eq 'autolimit=') { |
$disposition = 'process'; |
$disposition = 'process'; |
} elsif ($val =~ /^autolimit=(\d+)$/) { |
} elsif ($val =~ /^autolimit=(\d+)$/) { |
Line 1528 sub print_request_outcome {
|
Line 3501 sub print_request_outcome {
|
$disposition = &check_autolimit($env{'user.name'},$env{'user.domain'}, |
$disposition = &check_autolimit($env{'user.name'},$env{'user.domain'}, |
$dom,$crstype,$limit,\$message); |
$dom,$crstype,$limit,\$message); |
} elsif ($val eq 'validate') { |
} elsif ($val eq 'validate') { |
$disposition = |
my ($inststatuslist,$validationchk,$validation); |
&Apache::lonnet::auto_courserequest_validation($dom,$details, |
if (@inststatuses > 0) { |
\@inststatuses,\$message); |
$inststatuslist = join(',',@inststatuses); |
|
} |
|
my $instseclist; |
|
if (@instsections > 0) { |
|
$instseclist = join(',',@instsections); |
|
} |
|
$validationchk = |
|
&Apache::lonnet::auto_courserequest_validation($dom, |
|
$env{'user.name'}.':'.$env{'user.domain'},$crstype, |
|
$inststatuslist,$instcode,$instseclist); |
|
if ($validationchk =~ /:/) { |
|
($validation,$message) = split(':',$validationchk); |
|
} else { |
|
$validation = $validationchk; |
|
} |
|
if ($validation =~ /^error(.*)$/) { |
|
$disposition = 'approval'; |
|
$validationerror = $1; |
|
} else { |
|
$disposition = $validation; |
|
} |
} else { |
} else { |
$disposition = 'approval'; |
$disposition = 'approval'; |
} |
} |
$reqhash{'status'} = $disposition; |
$reqhash{'disposition'} = $disposition; |
|
$reqstatus = $disposition; |
|
my ($modified,$queued); |
if ($disposition eq 'rejected') { |
if ($disposition eq 'rejected') { |
$output = &mt('Your course request was rejected.'); |
if ($crstype eq 'community') { |
|
$output = &mt('Your community request was rejected.'); |
|
} else { |
|
$output = &mt('Your course request was rejected.'); |
|
} |
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 ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles); |
my $type = 'Course'; |
my $type = 'Course'; |
if ($crstype eq 'community') { |
if ($crstype eq 'community') { |
$type = 'Community'; |
$type = 'Community'; |
} |
} |
my ($logmsg,$newusermsg,$addresult,$enrollcount,$output,$keysmsg,%longroles); |
my @roles = &Apache::lonuserutils::roles_by_context('course','',$type); |
my @roles = &Apache::lonuserutils::roles_by_context('course'); |
|
foreach my $role (@roles) { |
foreach my $role (@roles) { |
$longroles{$role}=&Apache::lonnet::plaintext($role,$type); |
$longroles{$role}=&Apache::lonnet::plaintext($role,$type); |
} |
} |
my %reqdetails = &build_batchcreatehash($details); |
my $result = &Apache::loncoursequeueadmin::course_creation($dom,$cnum, |
my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'request',\%reqdetails,\%longroles,\$logmsg,\$newusermsg,\$addresult,\$enrollcount,\$output,\$keysmsg,$env{'user.domain'},$env{'user.name'},$cnum); |
'autocreate',$details,\$logmsg,\$newusermsg,\$addresult, |
$disposition = 'created'; |
\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles); |
if ($cid eq $cnum) { |
if ($result eq 'created') { |
$disposition = 'created'; |
$disposition = 'created'; |
$output = &mt('Your course request has been processed and the course has been created.').'<br />'.&mt('You will need to logout and log-in again to be able to select a role in the course.'); |
$reqstatus = 'created'; |
|
my $role_result = &update_requestors_roles($dom,$cnum,$crstype,$details, |
|
\%longroles); |
|
if ($crstype eq 'community') { |
|
$output = '<p>'.&mt('Your community request has been processed and the community has been created.'); |
|
} else { |
|
$output = '<p>'.&mt('Your course request has been processed and the course has been created.'); |
|
} |
|
$output .= '<br />'.$role_result.'</p>'; |
|
$creationresult = 'created'; |
} else { |
} else { |
$output = &mt('An error occurred when processing your course request.').'<br />'.&mt('You may want to review the request details and submit the request again.'); |
$output = '<span class="LC_error">'; |
|
if ($crstype eq 'community') { |
|
$output .= &mt('An error occurred when processing your community request.'); |
|
} else { |
|
$output .= &mt('An error occurred when processing your course request.'); |
|
} |
|
$output .= '<br />'. |
|
&mt('You may want to review the request details and submit the request again.'). |
|
'</span>'; |
|
$creationresult = 'error'; |
} |
} |
} else { |
} else { |
my $requestid = $cnum.'_'.$disposition; |
my $requestid = $cnum.'_'.$disposition; |
Line 1567 sub print_request_outcome {
|
Line 3586 sub print_request_outcome {
|
crstype => $crstype, |
crstype => $crstype, |
ownername => $env{'user.name'}, |
ownername => $env{'user.name'}, |
ownerdom => $env{'user.domain'}, |
ownerdom => $env{'user.domain'}, |
description => $env{'form.cdesc'}, |
description => $env{'form.cdescr'}, |
}, |
}, |
}; |
}; |
my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request, |
if ($crstype eq 'official') { |
$dom); |
$request->{$requestid}->{'instcode'} = $instcode; |
if ($putresult eq 'ok') { |
} |
my %emails = &Apache::loncommon::getemails(); |
my $statuskey = 'status:'.$dom.':'.$cnum; |
my $address; |
my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey], |
if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) { |
$env{'user.domain'},$env{'user.name'}); |
$address = $emails{'permanentemail'}; |
if ($userreqhash{$statuskey} ne '') { |
if ($address eq '') { |
$modified = 1; |
$address = $emails{'notification'}; |
my $uname = &Apache::lonnet::get_domainconfiguser($dom); |
} |
my %queuehash = &Apache::lonnet::get('courserequestqueue', |
} |
[$cnum.'_approval', |
$output = &mt('Your course request has been recorded.').'<br />'; |
$cnum.'_pending'],$dom,$uname); |
if ($disposition eq 'approval') { |
if (($queuehash{$cnum.'_approval'} ne '') || |
$output .= &mt('Your course request has been recorded.').'<br />'. |
($queuehash{$cnum.'_pending'} ne '')) { |
&mt('A message will be sent to your LON-CAPA account when a domain coordinator takes action on your request.').'<br />'. |
$queued = 1; |
&mt('To access your LON-CAPA message, go to the Main Menu and click on "Send and Receive Messages".').'<br />'; |
} |
if ($address ne '') { |
} |
$output.= &mt('An e-mail will also be sent to: [_1] when this occurs.',$address).'<br />'; |
unless ($queued) { |
} |
my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request, |
if ($req_notifylist) { |
$dom); |
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
if ($putresult eq 'ok') { |
$env{'user.domain'}); |
if ($crstype eq 'community') { |
&Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,$fullname,$now,$dom,$details); |
$output .= &mt('Your community request has been recorded.'); |
|
} else { |
|
$output .= &mt('Your course request has been recorded.') |
} |
} |
|
$output .= '<br />'. |
|
¬ification_information($disposition,$req_notifylist, |
|
$cnum,$now); |
} else { |
} else { |
$output .= '<div class="LC_info">'. |
$reqstatus = 'domainerror'; |
&mt('Your request has been placed in a queue pending administrative action.').'<br />'. |
$reqhash{'disposition'} = $disposition; |
&mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").'<br />'. |
my $warning = &mt('An error occurred saving your request in the pending requests queue.'); |
&mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.'). |
$output = '<span class"LC_warning">'.$warning.'</span><br />'; |
'</div>'; |
|
} |
} |
|
} |
|
} |
|
($storeresult,my $updateresult) = |
|
&Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom, |
|
$cnum,$reqstatus,'request',$env{'user.domain'},$env{'user.name'}); |
|
if ($modified && $queued && $storeresult eq 'ok') { |
|
if ($crstype eq 'community') { |
|
$output .= '<p>'.&mt('Your community request has been updated').'</p>'; |
} else { |
} else { |
$reqhash{'status'} = 'domainerror'; |
$output .= '<p>'.&mt('Your course request has been updated').'</p>'; |
$reqhash{'disposition'} = $disposition; |
|
my $warning = &mt('An error occurred saving your request in the pending requests queue.'); |
|
$output = '<span class"LC_warning">'.$warning.'</span><br />'; |
|
|
|
} |
} |
|
$output .= ¬ification_information($disposition,$req_notifylist,$cnum,$now); |
} |
} |
my $storeresult; |
if ($validationerror ne '') { |
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
$output .= '<p class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>'; |
$storeresult = &Apache::lonnet::store_userdata(\%reqhash,$requestkey, |
|
'courserequests'); |
|
} else { |
|
$storeresult = 'error: invalid requestkey format'; |
|
} |
} |
if ($storeresult ne 'ok') { |
if ($updateresult) { |
$output .= '<span class="LC_warning">'.&mt('An error occurred saving a record of the details of your request.').'</span><br />'; |
$output .= $updateresult; |
&logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult"); |
|
} |
} |
} |
} |
return $output; |
if ($creationresult ne '') { |
|
return ($creationresult,$output); |
|
} else { |
|
return ($storeresult,$output); |
|
} |
} |
} |
|
|
sub get_processtype { |
sub update_requestors_roles { |
my ($dom,$crstype,$inststatuses,$domconfig) = @_; |
my ($dom,$cnum,$crstype,$details,$longroles) = @_; |
return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH')); |
my $now = time; |
my (%userenv,%settings,$val); |
my ($active,$future,$numactive,$numfuture,$output); |
my @options = ('autolimit','validate','approve'); |
my $owner = $env{'user.name'}.':'.$env{'user.domain'}; |
if ($dom eq $env{'user.domain'}) { |
if (ref($details) eq 'HASH') { |
%userenv = |
if (ref($details->{'personnel'}) eq 'HASH') { |
&Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, |
my $ccrole = 'cc'; |
'requestcourses.'.$crstype,'inststatus'); |
if ($crstype eq 'community') { |
if ($userenv{'requestcourses.'.$crstype}) { |
$ccrole = 'co'; |
$val = $userenv{'requestcourses.'.$crstype}; |
} |
@{$inststatuses} = ('_custom_'); |
unless (ref($details->{'personnel'}{$owner}) eq 'HASH') { |
} else { |
$details->{'personnel'}{$owner} = { |
my ($task,%alltasks); |
'roles' => [$ccrole], |
if (ref($domconfig->{'requestcourses'}) eq 'HASH') { |
$ccrole => { 'usec' => [] }, |
%settings = %{$domconfig->{'requestcourses'}}; |
}; |
if (ref($settings{$crstype}) eq 'HASH') { |
} |
if (($env{'user.adv'}) && (exists($settings{$crstype}{'_LC_adv'}))) { |
my @roles; |
$val = $settings{$crstype}{'_LC_adv'}; |
if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') { |
@{$inststatuses} = ('_LC_adv_'); |
@roles = sort(@{$details->{'personnel'}{$owner}{'roles'}}); |
|
unless (grep(/^\Q$ccrole\E$/,@roles)) { |
|
push(@roles,$ccrole); |
|
} |
|
} else { |
|
@roles = ($ccrole); |
|
} |
|
foreach my $role (@roles) { |
|
my $refresh=$env{'user.refresh.time'}; |
|
if ($refresh eq '') { |
|
$refresh = $env{'user.login.time'}; |
|
} |
|
if ($refresh eq '') { |
|
$refresh = $now; |
|
} |
|
my $start = $refresh-1; |
|
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 $ccrole) { |
|
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 { |
} else { |
if ($userenv{'inststatus'} ne '') { |
&Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom, |
@{$inststatuses} = split(',',$userenv{'inststatus'}); |
$spec,$cnum,$area); |
} else { |
} |
@{$inststatuses} = ('other'); |
&Apache::lonnet::set_userprivs(\%userroles,\%newrole, |
} |
\%newgroups); |
foreach my $status (@{$inststatuses}) { |
$userroles{'user.role.'.$spec} = $start.'.'.$end; |
if (exists($settings{$crstype}{$status})) { |
&Apache::lonnet::appenv(\%userroles,[$role,'cm']); |
my $value = $settings{$crstype}{$status}; |
if (($end == 0) || ($end > $now)) { |
next unless ($value); |
my $showrole = $role; |
unless (exists($alltasks{$value})) { |
if ($role =~ /^cr\//) { |
if (ref($alltasks{$value}) eq 'ARRAY') { |
$showrole = &Apache::lonnet::plaintext($role,$crstype); |
unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) { |
} elsif (ref($longroles) eq 'HASH') { |
push(@{$alltasks{$value}},$status); |
if ($longroles->{$role} ne '') { |
} |
$showrole = $longroles->{$role}; |
} else { |
|
@{$alltasks{$value}} = ($status); |
|
} |
|
} |
|
} |
} |
} |
} |
my $maxlimit = 0; |
if ($start <= $now) { |
foreach my $key (sort(keys(%alltasks))) { |
$active .= '<li><a href="/adm/roles?selectrole=1&'. |
if ($key =~ /^autolimit=(\d*)$/) { |
$spec.'=1">'.$showrole; |
if ($1 eq '') { |
if ($usec ne '') { |
$val ='autolimit='; |
$active .= ' - '.&mt('section:').' '.$usec; |
last; |
|
} elsif ($1 > $maxlimit) { |
|
$maxlimit = $1; |
|
} |
|
} |
} |
} |
$active .= '</a></li>'; |
if ($maxlimit) { |
$numactive ++; |
$val = 'autolimit='.$maxlimit; |
} else { |
} else { |
$future .= '<li>'.$showrole; |
foreach my $option (@options) { |
if ($usec ne '') { |
if ($alltasks{$option}) { |
$future .= ' - '.&mt('section:').' '.$usec; |
$val = $option; |
|
last; |
|
} |
|
} |
} |
|
$future .= '</li>'; |
|
$numfuture ++; |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} else { |
} |
%userenv = &Apache::lonnet::userenvironment($env{'user.domain'}, |
if ($active) { |
$env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'}); |
if ($numactive == 1) { |
if ($userenv{'reqcrsotherdom'}) { |
if ($crstype eq 'Community') { |
my @doms = split(',',$userenv{'reqcrsotherdom'}); |
$output = &mt('Use the following link to enter the community:'); |
my $optregex = join('|',@options); |
} else { |
if (grep(/^\Q$dom\E:($optregex=?\d*)/,@doms)) { |
$output = &mt('Use the following link to enter the course:'); |
$val = $1; |
} |
|
} else { |
|
if ($crstype eq 'Community') { |
|
$output = &mt('Use the following links to your new roles to enter the community:'); |
|
} else { |
|
$output = &mt('Use the following links to your new roles to enter the course:'); |
} |
} |
@{$inststatuses} = ('_external_'); |
|
} |
} |
|
$output .= ' <ul>'.$active.'</ul><br />'; |
|
} |
|
if ($future) { |
|
if ($crstype eq 'Community') { |
|
$output .= &mt('The following community [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'})) |
|
} else { |
|
$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'})); |
|
} |
|
$output .= ' <ul>'.$future.'</ul>'; |
|
} |
|
return $output; |
|
} |
|
|
|
sub notification_information { |
|
my ($disposition,$req_notifylist,$cnum,$now) = @_; |
|
my %emails = &Apache::loncommon::getemails(); |
|
my $address; |
|
if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) { |
|
$address = $emails{'permanentemail'}; |
|
if ($address eq '') { |
|
$address = $emails{'notification'}; |
|
} |
|
} |
|
my $output; |
|
if ($disposition eq 'approval') { |
|
$output .= &mt('A message will be sent to your LON-CAPA account when a domain coordinator takes action on your request.').'<br />'. |
|
&mt('To access your LON-CAPA message, go to the Main Menu and click on "Send and Receive Messages".').'<br />'; |
|
if ($address ne '') { |
|
$output.= &mt('An e-mail will also be sent to: [_1] when this occurs.',$address).'<br />'; |
|
} |
|
if ($req_notifylist) { |
|
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}); |
|
my $sender = $env{'user.name'}.':'.$env{'user.domain'}; |
|
&Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender); |
|
} |
|
} elsif ($disposition eq 'pending') { |
|
$output .= '<div class="LC_info">'. |
|
&mt('Your request has been placed in a queue pending administrative action.').'<br />'. |
|
&mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").'<br />'. |
|
&mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.'). |
|
'</div>'; |
|
} else { |
|
$output .= '<div class="LC_warning">'. |
|
&mt('Your request status is: [_1].',$disposition). |
|
'</div>'; |
} |
} |
return $val; |
return $output; |
} |
} |
|
|
sub check_autolimit { |
sub check_autolimit { |
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_; |
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_; |
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'}, |
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'}, |
'userroles',['active','future'],['cc'],[$dom]); |
'userroles',['active','future'],['cc','co'],[$dom]); |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &Apache::loncommon::course_types(); |
my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname); |
my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname); |
my %count; |
my $count = 0; |
if (ref($types) eq 'ARRAY') { |
|
foreach my $type (@{$types}) { |
|
$count{$type} = 0; |
|
} |
|
} |
|
foreach my $key (keys(%requests)) { |
foreach my $key (keys(%requests)) { |
my ($cdom,$cnum) = split('_',$key); |
my ($cdom,$cnum) = split('_',$key); |
if (exists($crsroles{$cnum.':'.$cdom.':cc'})) { |
if (ref($requests{$key}) eq 'HASH') { |
if (ref($requests{$key}) eq 'HASH') { |
next if ($requests{$key}{'crstype'} ne $crstype); |
my $type = $requests{$key}{'crstype'}; |
if (($crstype eq 'community') && |
if ($type =~ /^official|unofficial|community$/) { |
(exists($crsroles{$cnum.':'.$cdom.':co'}))) { |
$count{$type} ++; |
$count ++; |
} |
} elsif ((($crstype eq 'official') || ($crstype eq 'unofficial')) && |
|
(exists($crsroles{$cnum.':'.$cdom.':cc'}))) { |
|
$count ++; |
} |
} |
} |
} |
} |
} |
if ($count{$crstype} < $limit) { |
if ($count < $limit) { |
return 'process'; |
return 'process'; |
} else { |
} else { |
if (ref($typename) eq 'HASH') { |
if (ref($typename) eq 'HASH') { |
$$message = &mt('Your request has not been processed because you have reached the limit for the number of courses of this type.').'<br />'.&mt("Your $typename->{$crstype} limit is [_1].",$limit); |
if ($crstype eq 'community') { |
|
$$message = &mt('Your request has not been processed because you have reached the limit for the number of communities.'). |
|
'<br />'.&mt("Your limit is [_1].",$limit); |
|
} else { |
|
$$message = &mt('Your request has not been processed because you have reached the limit for the number of courses of this type.'). |
|
'<br />'.&mt("Your $typename->{$crstype} limit is [_1].",$limit); |
|
} |
} |
} |
return 'rejected'; |
return 'rejected'; |
} |
} |
return; |
return; |
} |
} |
|
|
sub build_batchcreatehash { |
sub retrieve_settings { |
my ($details) = @_; |
my ($dom,$cnum,$udom,$uname) = @_; |
my %batchhash; |
if ($udom eq '' || $uname eq '') { |
if (ref($details) eq 'HASH') { |
$udom = $env{'user.domain'}; |
|
$uname = $env{'user.name'}; |
|
} |
|
my ($result,%reqinfo) = &get_request_settings($dom,$cnum,$udom,$uname); |
|
if ($result eq 'ok') { |
|
if (($udom eq $reqinfo{'domain'}) && ($uname eq $reqinfo{'owner'})) { |
|
$env{'form.chome'} = $reqinfo{'coursehome'}; |
|
$env{'form.cdescr'} = $reqinfo{'cdescr'}; |
|
$env{'form.crstype'} = $reqinfo{'crstype'}; |
|
&generate_date_items($reqinfo{'accessstart'},'accessstart'); |
|
&generate_date_items($reqinfo{'accessend'},'accessend'); |
|
if ($reqinfo{'accessend'} == 0) { |
|
$env{'form.no_end_date'} = 1; |
|
} |
|
if (($reqinfo{'crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) { |
|
&generate_date_items($reqinfo{'enrollstart'},'enrollstart'); |
|
&generate_date_items($reqinfo{'enrollend'},'enrollend'); |
|
} |
|
$env{'form.clonecrs'} = $reqinfo{'clonecrs'}; |
|
$env{'form.clonedom'} = $reqinfo{'clonedom'}; |
|
if (($reqinfo{'clonecrs'} ne '') && ($reqinfo{'clonedom'} ne '')) { |
|
$env{'form.cloning'} = 1; |
|
} |
|
$env{'form.datemode'} = $reqinfo{'datemode'}; |
|
$env{'form.dateshift'} = $reqinfo{'dateshift'}; |
|
if ($reqinfo{'crstype'} eq 'official') { |
|
$env{'form.autoadds'} = $reqinfo{'autoadds'}; |
|
$env{'form.autodrops'} = $reqinfo{'autodrops'}; |
|
if ($reqinfo{'instcode'} ne '') { |
|
$env{'form.sectotal'} = $reqinfo{'sectotal'}; |
|
$env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'}; |
|
$env{'form.instcode'} = $reqinfo{'instcode'}; |
|
my $crscode = { |
|
$cnum => $reqinfo{'instcode'}, |
|
}; |
|
&extract_instcode($dom,'instcode',$crscode,$cnum); |
|
(undef,undef,my $instcredits) = |
|
&Apache::lonnet::auto_validate_instcode(undef,$dom, |
|
$reqinfo{'instcode'}); |
|
if ($instcredits ne $reqinfo{'defaultcredits'}) { |
|
$env{'form.coursecredits'} = $reqinfo{'defaultcredits'}; |
|
} |
|
} |
|
} elsif ($reqinfo{'crstype'} eq 'unofficial') { |
|
$env{'form.coursecredits'} = $reqinfo{'defaultcredits'}; |
|
} |
|
my @currsec; |
|
if (ref($reqinfo{'sections'}) eq 'HASH') { |
|
foreach my $i (sort(keys(%{$reqinfo{'sections'}}))) { |
|
if (ref($reqinfo{'sections'}{$i}) eq 'HASH') { |
|
my $sec = $reqinfo{'sections'}{$i}{'inst'}; |
|
$env{'form.secnum_'.$i} = $sec; |
|
$env{'form.sec_'.$i} = '1'; |
|
if (!grep(/^\Q$sec\E$/,@currsec)) { |
|
push(@currsec,$sec); |
|
} |
|
$env{'form.loncapasec_'.$i} = $reqinfo{'sections'}{$i}{'loncapa'}; |
|
} |
|
} |
|
} |
|
if (ref($reqinfo{'crosslists'}) eq 'HASH') { |
|
foreach my $i (sort(keys(%{$reqinfo{'crosslists'}}))) { |
|
if (ref($reqinfo{'crosslists'}{$i}) eq 'HASH') { |
|
$env{'form.crosslist_'.$i} = '1'; |
|
$env{'form.crosslist_'.$i.'_instsec'} = $reqinfo{'crosslists'}{$i}{'instsec'}; |
|
$env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslists'}{$i}{'loncapa'}; |
|
if ($reqinfo{'crosslists'}{$i}{'instcode'} ne '') { |
|
my $key = $cnum.$i; |
|
my $crscode = { |
|
$key => $reqinfo{'crosslists'}{$i}{'instcode'}, |
|
}; |
|
&extract_instcode($dom,'crosslist',$crscode,$key,$i); |
|
} |
|
} |
|
} |
|
} |
|
if (ref($reqinfo{'personnel'}) eq 'HASH') { |
|
my $i = 0; |
|
foreach my $user (sort(keys(%{$reqinfo{'personnel'}}))) { |
|
my ($uname,$udom) = split(':',$user); |
|
if (ref($reqinfo{'personnel'}{$user}) eq 'HASH') { |
|
if (ref($reqinfo{'personnel'}{$user}{'roles'}) eq 'ARRAY') { |
|
foreach my $role (sort(@{$reqinfo{'personnel'}{$user}{'roles'}})) { |
|
$env{'form.person_'.$i.'_role'} = $role; |
|
$env{'form.person_'.$i.'_firstname'} = $reqinfo{'personnel'}{$user}{'firstname'}; |
|
$env{'form.person_'.$i.'_lastname'} = $reqinfo{'personnel'}{$user}{'lastname'}; ; |
|
$env{'form.person_'.$i.'_emailaddr'} = $reqinfo{'personnel'}{$user}{'emailaddr'}; |
|
$env{'form.person_'.$i.'_uname'} = $uname; |
|
$env{'form.person_'.$i.'_dom'} = $udom; |
|
if (ref($reqinfo{'personnel'}{$user}{$role}) eq 'HASH') { |
|
if (ref($reqinfo{'personnel'}{$user}{$role}{'usec'}) eq 'ARRAY') { |
|
my @usecs = @{$reqinfo{'personnel'}{$user}{$role}{'usec'}}; |
|
my @newsecs; |
|
if (@usecs > 0) { |
|
foreach my $sec (@usecs) { |
|
if (grep(/^\Q$sec\E/,@currsec)) { |
|
$env{'form.person_'.$i.'_sec'} = $sec; |
|
} else { |
|
push(@newsecs,$sec); |
|
} |
|
} |
|
} |
|
if (@newsecs > 0) { |
|
$env{'form.person_'.$i.'_newsec'} = join(',',@newsecs); |
|
} |
|
} |
|
} |
|
$i ++; |
|
} |
|
} |
|
} |
|
} |
|
$env{'form.persontotal'} = $i; |
|
} |
|
} |
} |
} |
return %batchhash; |
return $result; |
} |
} |
|
|
sub retrieve_settings { |
sub get_request_settings { |
my ($dom,$request_id) = @_; |
my ($dom,$cnum,$udom,$uname) = @_; |
my %reqinfo = &get_request_settings($request_id,$dom); |
my $requestkey = $dom.'_'.$cnum; |
my %stored; |
my ($result,%reqinfo); |
$stored{'cdescr'} = &unescape($reqinfo{'description'}); |
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) { |
$stored{'startaccess'} = $reqinfo{'startaccess'}; |
my %history = &Apache::lonnet::restore($requestkey,'courserequests',$udom,$uname); |
$stored{'endaccess'} = $reqinfo{'endaccess'}; |
my $disposition = $history{'disposition'}; |
if ($stored{'endaccess'} == 0) { |
if (($disposition eq 'approval') || ($disposition eq 'pending')) { |
$stored{'no_end_date'} = 1; |
if (ref($history{'details'}) eq 'HASH') { |
} |
%reqinfo = %{$history{'details'}}; |
$stored{'startenroll'} = $reqinfo{'startenroll'}; |
$result = 'ok'; |
$stored{'endenroll'} = $reqinfo{'endenroll'}; |
} else { |
$stored{'crosslist'} = $reqinfo{'crosslist'}; |
$result = 'nothash'; |
$stored{'clonecourse'} = $reqinfo{'clonecourse'}; |
} |
$stored{'clonedomain'} = $reqinfo{'clonedomain'}; |
} else { |
$stored{'sections'} = $reqinfo{'sections'}; |
$result = 'notqueued'; |
$stored{'personnel'} = $reqinfo{'personnel'}; |
} |
|
} else { |
|
$result = 'invalid'; |
|
} |
|
return ($result,%reqinfo); |
|
} |
|
|
return %stored; |
sub extract_instcode { |
|
my ($cdom,$element,$crscode,$crskey,$counter) = @_; |
|
my (%codes,@codetitles,%cat_titles,%cat_order); |
|
if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscode,\%codes, |
|
\@codetitles,\%cat_titles, |
|
\%cat_order) eq 'ok') { |
|
if (ref($codes{$crskey}) eq 'HASH') { |
|
if (@codetitles > 0) { |
|
my $sel = $element; |
|
if ($element eq 'crosslist') { |
|
$sel .= '_'.$counter; |
|
} |
|
foreach my $title (@codetitles) { |
|
$env{'form.'.$sel.'_'.$title} = $codes{$crskey}{$title}; |
|
} |
|
} |
|
} |
|
} |
|
return; |
} |
} |
|
|
sub get_request_settings { |
sub generate_date_items { |
my ($request_id,$dom); |
my ($currentval,$item) = @_; |
|
if ($currentval =~ /\d+/) { |
|
my ($tzname,$sec,$min,$hour,$mday,$month,$year) = |
|
&Apache::lonhtmlcommon::get_timedates($currentval); |
|
$env{'form.'.$item.'_day'} = $mday; |
|
$env{'form.'.$item.'_month'} = $month+1; |
|
$env{'form.'.$item.'_year'} = $year; |
|
} |
|
return; |
} |
} |
|
|
1; |
1; |