version 1.84, 2014/05/19 15:59:55
|
version 1.95.2.7, 2021/12/14 02:54:52
|
Line 119 use Apache::loncoursequeueadmin;
|
Line 119 use Apache::loncoursequeueadmin;
|
use Apache::lonuserutils; |
use Apache::lonuserutils; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
|
my $registered_flush; |
|
my $registered_instcats; |
|
my $modified_dom; |
|
|
sub handler { |
sub handler { |
my ($r) = @_; |
my ($r) = @_; |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
Line 127 sub handler {
|
Line 131 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
|
$registered_flush = 0; |
|
$registered_instcats = 0; |
|
$modified_dom = ''; |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['action','showdom','cnum','state','crstype','queue','tabs']); |
['action','showdom','cnum','state','crstype','queue','tabs']); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
Line 172 sub handler {
|
Line 180 sub handler {
|
if ($can_request{'textbook'}) { |
if ($can_request{'textbook'}) { |
&process_textbook_request($r,$dom,$action,\%domdefs,\%domconfig,\%can_request); |
&process_textbook_request($r,$dom,$action,\%domdefs,\%domconfig,\%can_request); |
} else { |
} else { |
&textbook_request_disabled($r,$dom,\%can_request); |
&textbook_request_disabled($r,$dom,$action,\%can_request); |
} |
} |
} elsif ($action eq 'display') { |
} elsif ($action eq 'display') { |
my ($uname,$udom,$result,$warning) = &domcoord_display($dom); |
my ($uname,$udom,$result,$warning) = &domcoord_display($dom); |
Line 194 sub handler {
|
Line 202 sub handler {
|
if ($can_request{'textbook'}) { |
if ($can_request{'textbook'}) { |
&print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},\%can_request); |
&print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},\%can_request); |
} else { |
} else { |
&textbook_request_disabled($r,$dom,\%can_request); |
&textbook_request_disabled($r,$dom,$action,\%can_request); |
} |
} |
} |
} |
return OK; |
return OK; |
Line 476 sub get_breadcrumbs {
|
Line 484 sub get_breadcrumbs {
|
} |
} |
} |
} |
} |
} |
for (my $i=0; $i<@{$states->{$action}}; $i++) { |
if (ref($states->{$action}) eq 'ARRAY') { |
if ($$state eq $states->{$action}[$i]) { |
for (my $i=0; $i<@{$states->{$action}}; $i++) { |
&Apache::lonhtmlcommon::add_breadcrumb( |
if ($$state eq $states->{$action}[$i]) { |
{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( |
&Apache::lonhtmlcommon::add_breadcrumb( |
{ href => '/adm/requestcourse', |
{text=>"$trail->{$$state}"}); |
text => "$trail->{$states->{$action}[$i]}", |
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests'); |
} |
last; |
); |
|
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb( |
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]')", |
{ href => "javascript:backPage(document.requestcrs,'$states->{$action}[$i]')", |
text => "$trail->{$states->{$action}[$i]}", } |
text => "$trail->{$states->{$action}[$i]}", } |
); |
); |
} |
} |
} |
} |
} |
} |
|
} |
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb( |
&Apache::lonhtmlcommon::add_breadcrumb( |
{text=>'Pick Action'}); |
{text=>'Pick Action'}); |
Line 766 END
|
Line 776 END
|
"; |
"; |
} |
} |
} |
} |
my %lt = &Apache::lonlocal::texthash( |
my %js_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 in this domain.', |
community => 'You are not permitted to request creation of a community in this domain.', |
Line 774 END
|
Line 784 END
|
all => 'You must choose a specific course type when making a new course request.', |
all => 'You must choose a specific course type when making a new course request.', |
allt => '"All types" is not allowed.', |
allt => '"All types" is not allowed.', |
); |
); |
|
&js_escape(\%js_lt); |
$js .= <<END; |
$js .= <<END; |
if (crschoice == 'official') { |
if (crschoice == 'official') { |
if (official != 1) { |
if (official != 1) { |
alert("$lt{'official'}"); |
alert("$js_lt{'official'}"); |
return false; |
return false; |
} |
} |
} else { |
} else { |
if (crschoice == 'unofficial') { |
if (crschoice == 'unofficial') { |
if (unofficial != 1) { |
if (unofficial != 1) { |
alert("$lt{'unofficial'}"); |
alert("$js_lt{'unofficial'}"); |
return false; |
return false; |
} |
} |
} else { |
} else { |
if (crschoice == 'community') { |
if (crschoice == 'community') { |
if (community != 1) { |
if (community != 1) { |
alert("$lt{'community'}"); |
alert("$js_lt{'community'}"); |
return false; |
return false; |
} |
} |
} else { |
} else { |
if (crschoice == 'textbook') { |
if (crschoice == 'textbook') { |
if (textbook != 1) { |
if (textbook != 1) { |
alert("$lt{'community'}"); |
alert("$js_lt{'textbook'}"); |
return false; |
return false; |
} |
} |
} else { |
} else { |
if (actionchoice == 'new') { |
if (actionchoice == 'new') { |
alert('$lt{'all'}'+'\\n'+'$lt{'allt'}'); |
alert('$js_lt{'all'}'+'\\n'+'$js_lt{'allt'}'); |
return false; |
return false; |
} |
} |
} |
} |
Line 937 END
|
Line 948 END
|
if ($action eq 'new') { |
if ($action eq 'new') { |
my $jsextra; |
my $jsextra; |
if (($state eq 'courseinfo') || ($state eq 'codepick')) { |
if (($state eq 'courseinfo') || ($state eq 'codepick')) { |
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); |
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom,'','','','','', |
|
$newinstcode); |
} elsif ($state eq 'enrollment') { |
} elsif ($state eq 'enrollment') { |
if (($env{'form.crstype'} eq 'official') && |
if (($env{'form.crstype'} eq 'official') && |
(&Apache::lonnet::auto_run('',$dom))) { |
(&Apache::lonnet::auto_run('',$dom))) { |
Line 1172 sub enrollment_lcsec_js {
|
Line 1184 sub enrollment_lcsec_js {
|
my %alerts = §ion_check_alerts(); |
my %alerts = §ion_check_alerts(); |
my $secname = $alerts{'badsec'}; |
my $secname = $alerts{'badsec'}; |
my $secnone = $alerts{'reserved'}; |
my $secnone = $alerts{'reserved'}; |
|
&js_escape(\$secname); |
|
&js_escape(\$secnone); |
my $output = ' |
my $output = ' |
function validateEnrollSections(formname,nextstate) { |
function validateEnrollSections(formname,nextstate) { |
var badsectotal = 0; |
var badsectotal = 0; |
Line 1229 function validateEnrollSections(formname
|
Line 1243 function validateEnrollSections(formname
|
|
|
sub personnel_lcsec_js { |
sub personnel_lcsec_js { |
my %alerts = §ion_check_alerts(); |
my %alerts = §ion_check_alerts(); |
my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'}; |
my $secname = $alerts{'badsec'}."\n".$alerts{'separate'}; |
my $secnone = $alerts{'reserved'}; |
my $secnone = $alerts{'reserved'}; |
|
&js_escape(\$secname); |
|
&js_escape(\$secnone); |
my $output = ' |
my $output = ' |
function validatePersonnelSections(formname,nextstate) { |
function validatePersonnelSections(formname,nextstate) { |
var badsectotal = 0; |
var badsectotal = 0; |
Line 1566 sub print_request_form {
|
Line 1582 sub print_request_form {
|
\%cat_order,\@code_order); |
\%cat_order,\@code_order); |
} |
} |
my $lonhost = $r->dir_config('lonHostID'); |
my $lonhost = $r->dir_config('lonHostID'); |
my ($storeresult,$result) = &print_request_outcome($r,$lonhost,$dom,\@codetitles, |
my ($storeresult,$result,$customized) = &print_request_outcome($r,$lonhost,$dom,\@codetitles, |
\@code_order,$instcredits); |
\@code_order,$instcredits); |
$r->print($result); |
$r->print($result); |
if (($storeresult eq 'ok') || ($storeresult eq 'created')) { |
if (($storeresult eq 'ok') || ($storeresult eq 'created')) { |
if ($storeresult eq 'ok') { |
if ($storeresult eq 'ok') { |
Line 1576 sub print_request_form {
|
Line 1592 sub print_request_form {
|
'<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>'); |
'<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>'); |
} |
} |
if (&Apache::loncoursequeueadmin::author_prompt()) { |
if (&Apache::loncoursequeueadmin::author_prompt()) { |
&print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'}, |
unless ($customized) { |
$env{'form.crstype'},$storeresult); |
&print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'}, |
|
$env{'form.crstype'},$storeresult); |
|
} |
} elsif ($storeresult eq 'created') { |
} elsif ($storeresult eq 'created') { |
$r->print('<p><a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>'); |
unless ($customized) { |
|
$r->print('<p><a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>'); |
|
} |
} |
} |
} |
} |
} elsif ($state eq 'reqauthor') { |
} elsif ($state eq 'reqauthor') { |
Line 2085 sub print_personnel_menu {
|
Line 2105 sub print_personnel_menu {
|
$output .= &Apache::lonhtmlcommon::row_headline(). |
$output .= &Apache::lonhtmlcommon::row_headline(). |
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>'; |
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>'; |
} |
} |
|
my $cansearch = 1; |
|
my @alldoms = &Apache::lonnet::all_domains(); |
|
if (@alldoms == 1) { |
|
my %domsrch = &Apache::lonnet::get_dom('configuration', |
|
['directorysrch'],$alldoms[0]); |
|
if (ref($domsrch{'directorysrch'}) eq 'HASH') { |
|
if ((!$domsrch{'directorysrch'}{'available'}) && |
|
($domsrch{'directorysrch'}{'lcavailable'} eq '0')) { |
|
$cansearch = 0; |
|
} |
|
} |
|
} |
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); |
Line 2109 sub print_personnel_menu {
|
Line 2141 sub print_personnel_menu {
|
} |
} |
$sectionselector .= $newtitle. |
$sectionselector .= $newtitle. |
'<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'."\n"; |
'<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'."\n"; |
my $usersrchlinktxt = &mt('Search for user'); |
my $usersrchlink; |
my $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, |
if ($cansearch) { |
$usersrchlinktxt); |
my $usersrchlinktxt = &mt('Search for user'); |
|
$usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, |
|
$usersrchlinktxt); |
|
} else { |
|
$usersrchlink = ' '; |
|
} |
my $userchklinktxt = &mt('Check username'); |
my $userchklinktxt = &mt('Check username'); |
my $userchklink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, |
my $userchklink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, |
$userchklinktxt,'checkusername'); |
$userchklinktxt,'checkusername'); |
Line 2358 sub print_cancel_request {
|
Line 2395 sub print_cancel_request {
|
&Apache::loncommon::start_data_table_row(). |
&Apache::loncommon::start_data_table_row(). |
'<td>'.$history{details}{'cdescr'}.'</td><td>'. |
'<td>'.$history{details}{'cdescr'}.'</td><td>'. |
&Apache::lonlocal::locallocaltime($timestamp).'</td>'. |
&Apache::lonlocal::locallocaltime($timestamp).'</td>'. |
'<td>'.$showtype.'</td>'. |
'<td>'.&mt($showtype).'</td>'. |
&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::end_data_table(). |
&Apache::loncommon::end_data_table(). |
'<br /><div class="LC_warning">'; |
'<br /><div class="LC_warning">'; |
Line 2413 ENDJS
|
Line 2450 ENDJS
|
} |
} |
|
|
sub viewcancel_javascript { |
sub viewcancel_javascript { |
my $alert = &mt('Are you sure you want to cancel this request?').'\\n'. |
my $alert = &mt('Are you sure you want to cancel this request?')."\n". |
&mt('Your request will be removed.'); |
&mt('Your request will be removed.'); |
|
&js_escape(\$alert); |
return << "ENDJS"; |
return << "ENDJS"; |
function nextPage(formname,nextstate) { |
function nextPage(formname,nextstate) { |
if (confirm('$alert')) { |
if (confirm('$alert')) { |
Line 2711 sub requestlog_display_filter {
|
Line 2749 sub requestlog_display_filter {
|
$typename = $typenames->{$crstype}; |
$typename = $typenames->{$crstype}; |
} |
} |
} |
} |
$output .= '<option value="'.$crstype.'"'.$selstr.'>'.$typename.'</option>'."\n"; |
$output .= '<option value="'.$crstype.'"'.$selstr.'>'.&mt($typename).'</option>'."\n"; |
} |
} |
$output .= '</select></td>'; |
$output .= '</select></td>'; |
} |
} |
Line 2786 sub print_review {
|
Line 2824 sub print_review {
|
|
|
my $enrollrow_title = &mt('Default Access Dates').'<br />'. |
my $enrollrow_title = &mt('Default Access Dates').'<br />'. |
'('.&Apache::lonnet::plaintext('st',$category).')'; |
'('.&Apache::lonnet::plaintext('st',$category).')'; |
|
my $instcode; |
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 2801 sub print_review {
|
Line 2840 sub print_review {
|
} |
} |
} |
} |
} |
} |
|
if (ref($code_order) eq 'ARRAY') { |
|
foreach my $item (@{$code_order}) { |
|
$instcode .= $env{'form.instcode_'.$item}; |
|
} |
|
} |
$inst_headers .= '<th>'.&mt('Credits').'</th>'; |
$inst_headers .= '<th>'.&mt('Credits').'</th>'; |
if ($instcredits) { |
if ($instcredits) { |
$inst_values .= '<td>'.$instcredits.'</td>'; |
$inst_values .= '<td>'.$instcredits.'</td>'; |
Line 2888 sub print_review {
|
Line 2932 sub print_review {
|
($env{'form.clonedom'} =~ /^$match_domain$/)) { |
($env{'form.clonedom'} =~ /^$match_domain$/)) { |
my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname, |
my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname, |
$udom,$env{'form.clonecrs'},$env{'form.clonedom'}, |
$udom,$env{'form.clonecrs'},$env{'form.clonedom'}, |
$env{'form.crstype'}); |
$env{'form.crstype'},$dom,$instcode); |
if ($canclone) { |
if ($canclone) { |
my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'}, |
my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'}, |
$env{'form.clonecrs'},('description','internal.coursecode')); |
$env{'form.clonecrs'},('description','internal.coursecode')); |
Line 3050 sub dates_from_form {
|
Line 3094 sub dates_from_form {
|
|
|
sub courseinfo_form { |
sub courseinfo_form { |
my ($dom,$formname,$crstype,$next,$description) = @_; |
my ($dom,$formname,$crstype,$next,$description) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %js_lt = &Apache::lonlocal::texthash( |
official => 'You must provide a (brief) course description.', |
official => 'You must provide a (brief) course description.', |
community => 'You must provide a (brief) community description.' |
community => 'You must provide a (brief) community description.' |
); |
); |
$lt{'unofficial'} = $lt{'official'}; |
&js_escape(\%js_lt); |
$lt{'textbook'} = $lt{'official'}; |
$js_lt{'unofficial'} = $js_lt{'official'}; |
|
$js_lt{'textbook'} = $js_lt{'official'}; |
my $js_validate = <<"ENDJS"; |
my $js_validate = <<"ENDJS"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[' |
// <![CDATA[' |
|
|
function validateForm() { |
function validateForm() { |
if ((document.$formname.cdescr.value == "") || (document.$formname.cdescr.value == "undefined")) { |
if ((document.$formname.cdescr.value == "") || (document.$formname.cdescr.value == "undefined")) { |
alert('$lt{$crstype}'); |
alert('$js_lt{$crstype}'); |
return; |
return; |
} |
} |
nextPage(document.$formname,'$next'); |
nextPage(document.$formname,'$next'); |
Line 3142 sub clone_form {
|
Line 3187 sub clone_form {
|
&Apache::loncommon::select_dom_form($dom,'clonedom').'</label>'. |
&Apache::loncommon::select_dom_form($dom,'clonedom').'</label>'. |
&Apache::lonhtmlcommon::row_closure(1). |
&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="clonecrs" value="" onfocus="this.blur();opencrsbrowser('."'$formname','clonecrs','clonedom','','','','','$type'".')" />'. |
'<input type="text" size="25" name="clonecrs" value="" onfocus="this.blur();opencrsbrowser('."'$formname','clonecrs','clonedom','','','','$type'".')" />'. |
'</label> '. |
'</label> '. |
&Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type). |
&Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
Line 3153 sub clone_form {
|
Line 3198 sub clone_form {
|
'</label><br /><label>'. |
'</label><br /><label>'. |
'<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="364" />'. |
&Apache::lonhtmlcommon::row_closure(1); |
&Apache::lonhtmlcommon::row_closure(1); |
return $output; |
return $output; |
} |
} |
Line 3192 sub coursecode_form {
|
Line 3237 sub coursecode_form {
|
} |
} |
if (@{$codetitles} > 0) { |
if (@{$codetitles} > 0) { |
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) { |
my $helplink; |
my $helplink; |
if (defined($helpitem{$context})) { |
if (defined($helpitem{$context})) { |
Line 3586 sub print_request_outcome {
|
Line 3631 sub print_request_outcome {
|
my $canclone = |
my $canclone = |
&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
$env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'}, |
$env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'}, |
$crstype); |
$crstype,$dom,$instcode); |
if ($canclone) { |
if ($canclone) { |
$clonecrs = $env{'form.clonecrs'}; |
$clonecrs = $env{'form.clonecrs'}; |
$clonedom = $env{'form.clonedom'}; |
$clonedom = $env{'form.clonedom'}; |
Line 3620 sub print_request_outcome {
|
Line 3665 sub print_request_outcome {
|
accessend => $accessend, |
accessend => $accessend, |
personnel => \%personnel, |
personnel => \%personnel, |
}; |
}; |
my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode, |
my ($result,$output,$customized) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details, |
$req_notifylist,\@instsections,\%domconfig); |
$instcode,$req_notifylist,\@instsections,\%domconfig); |
return ($result,$output); |
return ($result,$output,$customized); |
} |
} |
|
|
sub process_request { |
sub process_request { |
my ($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections, |
my ($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections, |
$domconfig) = @_; |
$domconfig) = @_; |
my (@inststatuses,$storeresult,$creationresult,$output); |
my (@inststatuses,$storeresult,$creationresult,$output,$customized); |
my $val = |
my $val = |
&Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'}, |
&Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'}, |
$env{'user.domain'},$env{'user.adv'}, |
$env{'user.domain'},$env{'user.adv'}, |
Line 3647 sub process_request {
|
Line 3692 sub process_request {
|
} |
} |
$storeresult = 'notpermitted'; |
$storeresult = 'notpermitted'; |
} else { |
} else { |
my ($disposition,$message,$reqstatus,$coursedesc); |
my ($disposition,$message,$reqstatus,$coursedesc,$accessstart,$accessend,%customvalidation); |
my %reqhash = ( |
my %reqhash = ( |
reqtime => $now, |
reqtime => $now, |
crstype => $crstype, |
crstype => $crstype, |
Line 3659 sub process_request {
|
Line 3704 sub process_request {
|
$env{'user.domain'}); |
$env{'user.domain'}); |
if (ref($details) eq 'HASH') { |
if (ref($details) eq 'HASH') { |
$coursedesc = $details->{'cdescr'}; |
$coursedesc = $details->{'cdescr'}; |
|
$accessstart = $details->{'accessstart'}; |
|
$accessend = $details->{'accessend'}; |
} |
} |
if ($val eq 'autolimit=') { |
if ($val eq 'autolimit=') { |
$disposition = 'process'; |
$disposition = 'process'; |
Line 3667 sub process_request {
|
Line 3714 sub process_request {
|
$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') { |
my ($inststatuslist,$validationchk,$validation,%custominfo); |
my ($inststatuslist,$validationchk,$validation); |
|
if (ref($details) eq 'HASH') { |
|
if ($details->{'clonecrs'}) { |
|
$customvalidation{'_LC_clonefrom'} = $details->{'clonedom'}.'_'.$details->{'clonecrs'}; |
|
} |
|
} |
if (@inststatuses > 0) { |
if (@inststatuses > 0) { |
$inststatuslist = join(',',@inststatuses); |
$inststatuslist = join(',',@inststatuses); |
} |
} |
Line 3677 sub process_request {
|
Line 3729 sub process_request {
|
$instseclist = join(',',@{$instsections}); |
$instseclist = join(',',@{$instsections}); |
} |
} |
} |
} |
|
# |
|
# Retrieve any custom form information used for validation |
|
# |
my $preprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'prevalidate',$env{'user.name'}, |
my $preprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'prevalidate',$env{'user.name'}, |
$env{'user.domain'},$fullname,$coursedesc); |
$env{'user.domain'},$fullname,$coursedesc); |
if (ref($preprocess) eq 'HASH') { |
if (ref($preprocess) eq 'HASH') { |
if (ref($preprocess->{'formitems'}) eq 'HASH') { |
&custom_formitems($preprocess,\%customvalidation); |
foreach my $key (keys(%{$preprocess->{'formitems'}})) { |
|
if ($preprocess->{'formitems'}->{$key} eq 'multiple') { |
|
if (exists($env{'form.'.$key})) { |
|
@{$custominfo{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key}); |
|
} |
|
} else { |
|
if (exists($env{'form.'.$key})) { |
|
$custominfo{$key} = $env{'form.'.$key}; |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
$validationchk = |
$validationchk = |
&Apache::lonnet::auto_courserequest_validation($dom, |
&Apache::lonnet::auto_courserequest_validation($dom, |
$env{'user.name'}.':'.$env{'user.domain'},$crstype, |
$env{'user.name'}.':'.$env{'user.domain'},$crstype, |
$inststatuslist,$instcode,$instseclist,\%custominfo); |
$inststatuslist,$instcode,$instseclist,\%customvalidation); |
if ($validationchk =~ /:/) { |
if ($validationchk =~ /:/) { |
($validation,$message) = split(':',$validationchk); |
($validation,$message) = split(':',$validationchk); |
} else { |
} else { |
Line 3714 sub process_request {
|
Line 3757 sub process_request {
|
} |
} |
$reqhash{'disposition'} = $disposition; |
$reqhash{'disposition'} = $disposition; |
$reqstatus = $disposition; |
$reqstatus = $disposition; |
my ($modified,$queued,$coursedesc,$token,%customitems); |
my ($modified,$queued,$token,%customitems); |
unless ($disposition eq 'rejected') { |
unless ($disposition eq 'rejected') { |
my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$env{'user.name'}, |
my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$env{'user.name'}, |
$env{'user.domain'},$fullname,$coursedesc); |
$env{'user.domain'},$fullname,$coursedesc,undef, |
|
undef,undef,\%customvalidation); |
|
# |
|
# Retrieve any custom form information submitted with review page and include in request details. |
|
# |
if (ref($inprocess) eq 'HASH') { |
if (ref($inprocess) eq 'HASH') { |
if (ref($inprocess->{'formitems'}) eq 'HASH') { |
&custom_formitems($inprocess,\%customitems); |
foreach my $key (keys(%{$inprocess->{'formitems'}})) { |
foreach my $key (keys(%customitems)) { |
if ($inprocess->{'formitems'}->{$key} eq 'multiple') { |
$reqhash{'custom'}{$key} = $customitems{$key}; |
if (exists($env{'form.'.$key})) { |
|
@{$customitems{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key}); |
|
} |
|
} else { |
|
if (exists($env{'form.'.$key})) { |
|
$customitems{$key} = $env{'form.'.$key}; |
|
$reqhash{'custom'}{$key} = $customitems{$key}; |
|
} |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
Line 3760 sub process_request {
|
Line 3797 sub process_request {
|
&mt('Your request is being processed; this page will update when processing is complete.'). |
&mt('Your request is being processed; this page will update when processing is complete.'). |
'</div>'); |
'</div>'); |
$r->rflush(); |
$r->rflush(); |
|
if (ref($details) eq 'HASH') { |
|
if ($details->{'clonecrs'}) { |
|
$customitems{'_LC_clonefrom'} = $details->{'clonedom'}.'_'.$details->{'clonecrs'}; |
|
} |
|
} |
|
$customitems{'_LC_ownerfullname'} = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'},'first'); |
|
my $owneremail; |
|
my %emails = &Apache::loncommon::getemails(); |
|
foreach my $email ('permanentemail','critnotification','notification') { |
|
$owneremail = $emails{$email}; |
|
last if ($owneremail ne ''); |
|
} |
|
if ($owneremail ne '') { |
|
$customitems{'_LC_owneremail'} = $owneremail; |
|
} |
|
$customitems{'_LC_coursedomainname'} = &Apache::lonnet::domain($dom,'description'); |
|
$customitems{'_LC_coursedescription'} = $coursedesc; |
|
$customitems{'_LC_coursestartdate'} = $accessstart; |
|
$customitems{'_LC_courseenddate'} = $accessend; |
my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum, |
my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum, |
'autocreate',$details,\$logmsg,\$newusermsg,\$addresult, |
'autocreate',$details,\$logmsg,\$newusermsg,\$addresult, |
\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles, |
\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles, |
\$code,\%customitems); |
\$code,\%customitems); |
|
if (ref($postprocess) eq 'HASH') { |
|
$customized = $postprocess->{'createdcustomized'}; |
|
} |
if ($result eq 'created') { |
if ($result eq 'created') { |
$disposition = 'created'; |
$disposition = 'created'; |
$reqstatus = 'created'; |
$reqstatus = 'created'; |
Line 3790 sub process_request {
|
Line 3849 sub process_request {
|
} |
} |
} |
} |
} |
} |
$output .= '<br />'.$role_result.'</p>'; |
unless ($customized) { |
|
$output .= '<br />'.$role_result; |
|
} |
|
$output .= '</p>'; |
$creationresult = 'created'; |
$creationresult = 'created'; |
|
# Flush the course logs so reverse user roles immediately updated |
|
unless ($registered_flush) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\&Apache::lonnet::flushcourselogs,@{$handlers}]); |
|
$registered_flush=1; |
|
} |
|
if ($instcode ne '') { |
|
&Apache::lonnet::devalidate_cache_new('instcats',$dom); |
|
# Update cache of self-cataloging courses on institution's server(s). |
|
if (&Apache::lonnet::shared_institution($dom)) { |
|
unless ($registered_instcats) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]); |
|
$registered_instcats=1; |
|
$modified_dom = $dom; |
|
} |
|
} |
|
} |
} else { |
} else { |
$output = '<span class="LC_error">'; |
$output = '<span class="LC_error">'; |
if ($crstype eq 'community') { |
if ($crstype eq 'community') { |
Line 3895 sub process_request {
|
Line 3975 sub process_request {
|
if ((ref($postprocess) eq 'HASH') && |
if ((ref($postprocess) eq 'HASH') && |
((ref($postprocess->{'queuedmsg'}) eq 'HASH') || ($postprocess->{'queuedweb'}))) { |
((ref($postprocess->{'queuedmsg'}) eq 'HASH') || ($postprocess->{'queuedweb'}))) { |
¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess); |
¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess); |
|
$customized = $postprocess->{'createdcustomized'}; |
} |
} |
} elsif ($disposition eq 'pending') { |
} elsif ($disposition eq 'pending') { |
my $pendingform; |
my $pendingform; |
if ($crstype ne 'official') { |
if ($crstype ne 'official') { |
$pendingform = &pending_validation_form($dom,$cnum,$crstype,$now,$token, |
$pendingform = &pending_validation_form($r,$dom,$cnum,$crstype,$now,$token, |
$lonhost,$env{'form.cdescr'}); |
$lonhost,$env{'form.cdescr'}); |
} |
} |
if ($pendingform) { |
if ($pendingform) { |
Line 3907 sub process_request {
|
Line 3988 sub process_request {
|
} else { |
} else { |
$output .= ¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess); |
$output .= ¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess); |
} |
} |
|
if (ref($postprocess) eq 'HASH') { |
|
$customized = $postprocess->{'createdcustomized'}; |
|
} |
} |
} |
} |
} |
if ($validationerror ne '') { |
if ($validationerror ne '') { |
Line 3917 sub process_request {
|
Line 4001 sub process_request {
|
} |
} |
} |
} |
if ($creationresult ne '') { |
if ($creationresult ne '') { |
return ($creationresult,$output); |
return ($creationresult,$output,$customized); |
} else { |
} else { |
return ($storeresult,$output); |
return ($storeresult,$output,$customized); |
|
} |
|
} |
|
|
|
sub devalidate_remote_instcats { |
|
if ($modified_dom ne '') { |
|
my %servers = &Apache::lonnet::internet_dom_servers($modified_dom); |
|
my %thismachine; |
|
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); |
|
if (keys(%servers)) { |
|
foreach my $server (keys(%servers)) { |
|
next if ($thismachine{$server}); |
|
&Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]); |
|
} |
|
} |
|
$modified_dom = ''; |
|
} |
|
return; |
|
} |
|
|
|
sub custom_formitems { |
|
my ($preprocess,$customhash) = @_; |
|
return unless ((ref($preprocess) eq 'HASH') && (ref($customhash) eq 'HASH')); |
|
if (ref($preprocess->{'formitems'}) eq 'HASH') { |
|
foreach my $key (keys(%{$preprocess->{'formitems'}})) { |
|
if ($preprocess->{'formitems'}->{$key} eq 'multiple') { |
|
if (exists($env{'form.'.$key})) { |
|
my @items = &Apache::loncommon::get_env_multiple($env{'form.'.$key}); |
|
foreach my $item (@items) { |
|
$item =~ s/(`)/'/g; |
|
$item =~ s/\$/\(\$\)/g; |
|
push(@{$customhash->{$key}},$item); |
|
} |
|
} |
|
} else { |
|
if (exists($env{'form.'.$key})) { |
|
$customhash->{$key} = $env{'form.'.$key}; |
|
$customhash->{$key} =~ s/(`)/'/g; |
|
$customhash->{$key} =~ s/\$/\(\$\)/g; |
|
} |
|
} |
|
} |
} |
} |
} |
} |
|
|
Line 4173 sub notification_information {
|
Line 4298 sub notification_information {
|
} |
} |
|
|
sub pending_validation_form { |
sub pending_validation_form { |
my ($cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_; |
my ($r,$cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_; |
my $output; |
my $output; |
my %postvalues = ( |
my %postvalues = ( |
'owner' => $env{'user.name'}.':'.$env{'user.domain'}, |
'owner' => $env{'user.name'}.':'.$env{'user.domain'}, |
Line 4206 sub pending_validation_form {
|
Line 4331 sub pending_validation_form {
|
$buttontext = &mt('Create course'); |
$buttontext = &mt('Create course'); |
} |
} |
} |
} |
|
my $hostname = &Apache::lonnet::hostname($lonhost); |
my $protocol = $Apache::lonnet::protocol{$lonhost}; |
my $protocol = $Apache::lonnet::protocol{$lonhost}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
my $crscreator = $protocol.'://'.&Apache::lonnet::hostname($lonhost).'/cgi-bin/createpending.pl'; |
my $alias = &Apache::lonnet::use_proxy_alias($r,$lonhost); |
|
$hostname = $alias if ($alias ne ''); |
|
my $crscreator = $protocol.'://'.$hostname.'/cgi-bin/createpending.pl'; |
$output .= '<input type="hidden" name="crscreator" value="'.$crscreator.'" />'."\n". |
$output .= '<input type="hidden" name="crscreator" value="'.$crscreator.'" />'."\n". |
'<input type="hidden" name="token" value="'.$token.'" />'."\n". |
'<input type="hidden" name="token" value="'.$token.'" />'."\n". |
'<input type="submit" name="validate" value="'.$buttontext.'" />'."\n". |
'<input type="submit" name="validate" value="'.$buttontext.'" />'."\n". |
Line 4450 sub print_textbook_form {
|
Line 4578 sub print_textbook_form {
|
my ($clonedom,$clonecrs) = split(/_/,$item); |
my ($clonedom,$clonecrs) = split(/_/,$item); |
if (ref($prefab{$type}{$item}) eq 'HASH') { |
if (ref($prefab{$type}{$item}) eq 'HASH') { |
if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
$env{'user.domain'},$clonecrs,$clonedom,$crstype)) { |
$env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom)) { |
|
|
my $num = $prefab{$type}{$item}{'order'}; |
my $num = $prefab{$type}{$item}{'order'}; |
$ordered{$type}{$num} = $item; |
$ordered{$type}{$num} = $item; |
Line 4473 sub print_textbook_form {
|
Line 4601 sub print_textbook_form {
|
} |
} |
|
|
# |
# |
# Retrieve information about courses owned by user, or in which user has an active or future |
# Retrieve information about courses owned by user, or in which user has an active |
# Course Coordinator role |
# Course Coordinator role |
# |
# |
my $numcurrent; |
my $numcurrent; |
my %cloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.',$env{'user.name'}.':'.$env{'user.domain'}, |
my %cloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.',$env{'user.name'}.':'.$env{'user.domain'}, |
undef,undef,undef,'Course'); |
'.',undef,undef,'Course'); |
my %ccroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
my %ccroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
['active','future'],['cc']); |
['active'],['cc']); |
|
|
|
my $cc_clone = ''; |
foreach my $role (keys(%ccroles)) { |
foreach my $role (keys(%ccroles)) { |
my ($cnum,$cdom,$rest) = split(/:/,$role,3); |
my ($cnum,$cdom,$rest) = split(/:/,$role,3); |
|
$cc_clone .= $cdom.':'.$cnum.'&'; |
unless (exists($cloneable{$cdom.'_'.$cnum})) { |
unless (exists($cloneable{$cdom.'_'.$cnum})) { |
my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{'one_time' => 1}); |
my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{'one_time' => 1}); |
$cloneable{$cdom.'_'.$cnum} = \%courseinfo; |
$cloneable{$cdom.'_'.$cnum} = { |
|
context => $courseinfo{'internal.creationcontext'}, |
|
created => $courseinfo{'internal.created'}, |
|
creator => $courseinfo{'internal.creator'}, |
|
description => $courseinfo{'description'}, |
|
inst_code => $courseinfo{'coursecode'}, |
|
owner => $courseinfo{'internal.courseowner'}, |
|
releaserequired => $courseinfo{'internal.releaserequired'}, |
|
type => $courseinfo{'type'}, |
|
}; |
} |
} |
} |
} |
|
|
my $numcurrent = scalar(keys(%cloneable)); |
my $numcurrent = scalar(keys(%cloneable)); |
|
|
my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent); |
# |
|
# Retrieve information about courses from user's domain which user can clone, but which not owned |
|
# or cloneable based on Course Coordinator role. |
|
# |
|
my ($numdomcourses,%domcloneable); |
|
my %allcloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',undef,undef,'Course', |
|
undef,undef,undef,undef,undef, |
|
$env{'user.name'}.':'.$env{'user.domain'}, |
|
$cc_clone,1); |
|
foreach my $cid (keys(%allcloneable)) { |
|
unless (exists($cloneable{$cid})) { |
|
$domcloneable{$cid} = $allcloneable{$cid}; |
|
} |
|
} |
|
$numdomcourses = scalar(keys(%domcloneable)); |
|
|
|
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}); |
|
|
|
# |
|
# Retrieve any custom form information prior to rendering page |
|
# |
|
|
|
my $initprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'initializereview',$env{'user.name'}, |
|
$env{'user.domain'},$fullname); |
|
my %custominit; |
|
if (ref($initprocess) eq 'HASH') { |
|
&custom_formitems($initprocess,\%custominit); |
|
} |
|
|
|
# |
|
# Retrieve any custom onload actions or javascript used for page before rendering |
|
# |
|
|
|
my ($customonload,$customjs,$customvalidationjs); |
|
my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'prereview',$env{'user.name'}, |
|
$env{'user.domain'},$fullname,undef,undef, |
|
undef,undef,\%custominit); |
|
if (ref($inprocess) eq 'HASH') { |
|
$customonload = $inprocess->{'onload'}; |
|
$customjs = $inprocess->{'javascript'}; |
|
$customvalidationjs = $inprocess->{'validationjs'}; |
|
} |
|
|
|
my $postprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'review', |
|
$env{'user.name'}, |
|
$env{'user.domain'},$fullname,undef,undef, |
|
undef,undef,\%custominit); |
|
|
|
my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent,$numdomcourses,$customvalidationjs); |
|
$jscript .= $customjs; |
my %loaditems; |
my %loaditems; |
$loaditems{'onload'} = 'javascript:uncheckAllRadio();'; |
$loaditems{'onload'} = 'javascript:uncheckAllRadio();'.$customonload; |
$r->print(&header('Course Request',$jscript,\%loaditems)); |
$r->print(&header('Course Request',$jscript,\%loaditems)); |
|
|
if (ref($can_request) eq 'HASH') { |
if (ref($can_request) eq 'HASH') { |
Line 4538 sub print_textbook_form {
|
Line 4728 sub print_textbook_form {
|
# |
# |
# Content source selection, if more than one available |
# Content source selection, if more than one available |
# |
# |
if (keys(%cloneable) || keys(%ordered)) { |
if (keys(%cloneable) || keys(%ordered) || keys(%domcloneable)) { |
$r->print('<div>'. |
$r->print('<div>'. |
'<fieldset><legend>'.&mt('Course Content').'</legend>'); |
'<fieldset><legend>'.&mt('Course Content').'</legend>'); |
if (keys(%ordered)) { |
if (keys(%ordered)) { |
Line 4558 sub print_textbook_form {
|
Line 4748 sub print_textbook_form {
|
'<input type="radio" name="cloning" value="existing" onclick="javascript:cloneChoice();" />'. |
'<input type="radio" name="cloning" value="existing" onclick="javascript:cloneChoice();" />'. |
&mt('Copy one of your courses').'</label></span>'.(' 'x2).' '); |
&mt('Copy one of your courses').'</label></span>'.(' 'x2).' '); |
} |
} |
|
if (keys(%domcloneable)) { |
|
$r->print('<span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="cloning" value="colleague" onclick="javascript:cloneChoice();" />'. |
|
&mt("Copy a colleague's course").'</label></span>'.(' 'x2).' '); |
|
} |
$r->print('<span class="LC_nobreak"><label>'. |
$r->print('<span class="LC_nobreak"><label>'. |
'<input type="radio" name="cloning" value="none" checked="checked" onclick="javascript:cloneChoice();" />'. |
'<input type="radio" name="cloning" value="none" checked="checked" onclick="javascript:cloneChoice();" />'. |
&mt('Empty course shell').'</label></span>'); |
&mt('Empty course shell').'</label></span>'); |
Line 4619 sub print_textbook_form {
|
Line 4814 sub print_textbook_form {
|
# |
# |
# Table of user's current courses (owner and/or course coordinator) |
# Table of user's current courses (owner and/or course coordinator) |
# |
# |
|
my %lt = &clone_text(); |
if (keys(%cloneable)) { |
if (keys(%cloneable)) { |
my %lt = &clone_text(); |
|
$r->print('<div id="showexisting" style="display:none">'. |
$r->print('<div id="showexisting" style="display:none">'. |
&Apache::loncommon::start_data_table(). |
&clone_selection_table($dom,'owned',\%cloneable). |
&Apache::loncommon::start_data_table_header_row(). |
'<p><input type="radio" name="owndatemode" value="delete" /> '.$lt{'ncd'}. |
'<th>'.&mt('Title').'</th>'. |
'</label><br /><label>'. |
'<th>'.&mt('Owner/co-owner(s)').'</th>'. |
'<input type="radio" name="owndatemode" value="preserve" /> '.$lt{'prd'}. |
&Apache::loncommon::end_data_table_header_row()); |
'</label><br /><label>'. |
my %allownernames; |
'<input type="radio" name="owndatemode" value="shift" checked="checked" /> '. |
my %sortbytitle; |
$lt{'shd'}.'</label>'. |
foreach my $cid (sort(keys(%cloneable))) { |
'<input type="text" size="5" name="owndateshift" value="364" />'. |
if (ref($cloneable{$cid}) eq 'HASH') { |
'</div>'); |
my $cdesc = $cloneable{$cid}{'description'}; |
|
$cdesc =~ s/`/'/g; |
|
if ($cdesc ne '') { |
|
push(@{$sortbytitle{$cdesc}},$cid); |
|
} |
|
} |
|
} |
|
foreach my $title (sort(keys(%sortbytitle))) { |
|
if (ref($sortbytitle{$title}) eq 'ARRAY') { |
|
foreach my $cid (sort(@{$sortbytitle{$title}})) { |
|
my $cleantitle=&HTML::Entities::encode($title,'<>&"'); |
|
$cleantitle=~s/'/\\'/g; |
|
$cleantitle =~ s/^\s+//; |
|
my ($namestr,@owners,%ownernames); |
|
my $singleowner = $cloneable{$cid}{'internal.courseowner'}; |
|
push(@owners,$singleowner); |
|
if ($cloneable{$cid}{'co-owners'} ne '') { |
|
foreach my $item (split(/,/,$cloneable{$cid}{'internal.co-owners'})) { |
|
push(@owners,$item); |
|
} |
|
} |
|
foreach my $owner (@owners) { |
|
my ($ownername,$ownerdom); |
|
if ($owner =~ /:/) { |
|
($ownername,$ownerdom) = split(/:/,$owner); |
|
} else { |
|
$ownername = $owner; |
|
if ($owner ne '') { |
|
$ownerdom = $dom; |
|
} |
|
} |
|
if ($ownername ne '' && $ownerdom ne '') { |
|
if (exists($allownernames{$ownername.':'.$ownerdom})) { |
|
$ownernames{$ownername.':'.$ownerdom} = $allownernames{$ownername.':'.$ownerdom}; |
|
} else { |
|
my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom); |
|
$ownernames{$ownername.':'.$ownerdom} = \%namehash; |
|
$allownernames{$ownername.':'.$ownerdom} = $ownernames{$ownername.':'.$ownerdom}; |
|
} |
|
} |
|
} |
|
my @lastnames; |
|
foreach my $owner (keys(%ownernames)) { |
|
if (ref($ownernames{$owner}) eq 'HASH') { |
|
push(@lastnames,$ownernames{$owner}{'lastname'}); |
|
} |
|
} |
|
if (@lastnames) { |
|
$namestr = join(', ',sort(@lastnames)); |
|
} |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<td><label><input type="radio" name="owned" value="'.$cid.'" />'. |
|
' '.$cleantitle.'</label></td>'. |
|
'<td>'.$namestr.'</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_data_table(). |
|
'<p><input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}. |
|
'</label><br /><label>'. |
|
'<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}. |
|
'</label><br /><label>'. |
|
'<input type="radio" name="datemode" value="shift" checked="checked" /> '. |
|
$lt{'shd'}.'</label>'. |
|
'<input type="text" size="5" name="dateshift" value="365" />'. |
|
'</div>'); |
|
} |
} |
# |
# |
|
# Table of other cloneable courses from user's domain (exclude own courses) |
|
# |
|
if (keys(%domcloneable)) { |
|
$r->print('<div id="showcolleague" style="display:none">'. |
|
&clone_selection_table($dom,'colleague',\%domcloneable). |
|
'<p><input type="radio" name="colldatemode" value="delete" /> '.$lt{'ncd'}. |
|
'</label><br /><label>'. |
|
'<input type="radio" name="colldatemode" value="preserve" /> '.$lt{'prd'}. |
|
'</label><br /><label>'. |
|
'<input type="radio" name="colldatemode" value="shift" checked="checked" /> '. |
|
$lt{'shd'}.'</label>'. |
|
'<input type="text" size="5" name="colldateshift" value="364" />'. |
|
'</div>'); |
|
} |
|
|
|
# |
# End of content selector |
# End of content selector |
# |
# |
if (keys(%cloneable) || keys(%ordered)) { |
if (keys(%cloneable) || keys(%domcloneable) || keys(%ordered)) { |
$r->print('</fieldset></div>'); |
$r->print('</fieldset></div>'); |
} |
} |
|
|
Line 4733 sub print_textbook_form {
|
Line 4877 sub print_textbook_form {
|
# |
# |
# Display any custom fields for this course type |
# Display any custom fields for this course type |
# |
# |
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}); |
|
my $postprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'review', |
|
$env{'user.name'}, |
|
$env{'user.domain'},$fullname); |
|
if (ref($postprocess) eq 'HASH') { |
if (ref($postprocess) eq 'HASH') { |
if ($postprocess->{'reviewweb'}) { |
if ($postprocess->{'reviewweb'}) { |
$r->print($postprocess->{'reviewweb'}); |
$r->print($postprocess->{'reviewweb'}); |
Line 4760 sub print_textbook_form {
|
Line 4899 sub print_textbook_form {
|
return; |
return; |
} |
} |
|
|
|
sub clone_selection_table { |
|
my ($dom,$name,$cloneableref) = @_; |
|
return unless ((ref($cloneableref) eq 'HASH') && (($name eq 'owned') || ($name eq 'colleague'))); |
|
my %allownernames; |
|
my %sortbytitle; |
|
my $output; |
|
foreach my $cid (sort(keys(%{$cloneableref}))) { |
|
if (ref($cloneableref->{$cid}) eq 'HASH') { |
|
my $cdesc = $cloneableref->{$cid}{'description'}; |
|
$cdesc =~ s/`/'/g; |
|
if ($cdesc ne '') { |
|
push(@{$sortbytitle{$cdesc}},$cid); |
|
} |
|
} |
|
} |
|
foreach my $title (sort(keys(%sortbytitle))) { |
|
if (ref($sortbytitle{$title}) eq 'ARRAY') { |
|
foreach my $cid (sort(@{$sortbytitle{$title}})) { |
|
my $cleantitle=&HTML::Entities::encode($title,'<>&"'); |
|
$cleantitle=~s/'/\\'/g; |
|
$cleantitle =~ s/^\s+//; |
|
my ($namestr,@owners,%ownernames); |
|
if ($cloneableref->{$cid}{'owner'} ne '') { |
|
push(@owners,$cloneableref->{$cid}{'owner'}); |
|
} |
|
if ($cloneableref->{$cid}{'co-owners'} ne '') { |
|
foreach my $item (split(/,/,$cloneableref->{$cid}{'co-owners'})) { |
|
if (($item ne '') && (!grep(/^\Q$item\E$/,@owners))) { |
|
push(@owners,$item); |
|
} |
|
} |
|
} |
|
foreach my $owner (@owners) { |
|
my ($ownername,$ownerdom); |
|
if ($owner =~ /:/) { |
|
($ownername,$ownerdom) = split(/:/,$owner); |
|
} else { |
|
$ownername = $owner; |
|
if ($owner ne '') { |
|
$ownerdom = $dom; |
|
} |
|
} |
|
if ($ownername ne '' && $ownerdom ne '') { |
|
if (exists($allownernames{$ownername.':'.$ownerdom})) { |
|
$ownernames{$ownername.':'.$ownerdom} = $allownernames{$ownername.':'.$ownerdom}; |
|
} else { |
|
my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom); |
|
$ownernames{$ownername.':'.$ownerdom} = \%namehash; |
|
$allownernames{$ownername.':'.$ownerdom} = $ownernames{$ownername.':'.$ownerdom}; |
|
} |
|
} |
|
} |
|
my @lastnames; |
|
foreach my $owner (keys(%ownernames)) { |
|
if (ref($ownernames{$owner}) eq 'HASH') { |
|
push(@lastnames,$ownernames{$owner}{'lastname'}); |
|
} |
|
} |
|
if (@lastnames) { |
|
$namestr = join(', ',sort(@lastnames)); |
|
} |
|
$output .= &Apache::loncommon::start_data_table_row(). |
|
'<td><label><input type="radio" name="'.$name.'" value="'.$cid.'" />'. |
|
' '.$cleantitle.'</label></td>'. |
|
'<td>'.$namestr.'</td>'. |
|
&Apache::loncommon::end_data_table_row(); |
|
} |
|
} |
|
} |
|
if ($output) { |
|
return &Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Title').'</th>'. |
|
'<th>'.&mt('Owner/co-owner(s)').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row(). |
|
$output. |
|
&Apache::loncommon::end_data_table(); |
|
} |
|
return; |
|
} |
|
|
sub process_textbook_request { |
sub process_textbook_request { |
my ($r,$dom,$action,$domdefs,$domconfig,$can_request) = @_; |
my ($r,$dom,$action,$domdefs,$domconfig,$can_request) = @_; |
my ($uniquecode,$req_notifylist); |
my ($uniquecode,$req_notifylist); |
Line 4785 sub process_textbook_request {
|
Line 5005 sub process_textbook_request {
|
$clonefrom = $env{'form.template'}; |
$clonefrom = $env{'form.template'}; |
} elsif ($reqtype eq 'existing') { |
} elsif ($reqtype eq 'existing') { |
$clonefrom = $env{'form.owned'}; |
$clonefrom = $env{'form.owned'}; |
|
} elsif ($reqtype eq 'colleague') { |
|
$clonefrom = $env{'form.colleague'}; |
} |
} |
my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend'); |
my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend'); |
if ($clonefrom) { |
if ($clonefrom) { |
Line 4792 sub process_textbook_request {
|
Line 5014 sub process_textbook_request {
|
if (&Apache::lonnet::homeserver($clonecrs,$clonedom) ne 'no_host') { |
if (&Apache::lonnet::homeserver($clonecrs,$clonedom) ne 'no_host') { |
my $canclone = |
my $canclone = |
&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
$env{'user.domain'},$clonecrs,$clonedom,$crstype); |
$env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom); |
unless ($canclone) { |
unless ($canclone) { |
undef($clonecrs); |
undef($clonecrs); |
undef($clonedom); |
undef($clonedom); |
Line 4840 sub process_textbook_request {
|
Line 5062 sub process_textbook_request {
|
accessend => $accessend, |
accessend => $accessend, |
personnel => {}, |
personnel => {}, |
}; |
}; |
if ($reqtype eq 'existing') { |
if (($clonecrs ne '') && ($clonedom ne '')) { |
$details->{datemode} = $env{'form.datemode'}; |
if ($reqtype eq 'existing') { |
$details->{dateshift} = $env{'form.dateshift'}; |
$details->{datemode} = $env{'form.owndatemode'}; |
|
if ($details->{datemode} eq 'shift') { |
|
$details->{dateshift} = $env{'form.owndateshift'}; |
|
} else { |
|
$details->{dateshift} = ''; |
|
} |
|
} elsif ($reqtype eq 'colleague') { |
|
$details->{datemode} = $env{'form.colldatemode'}; |
|
if ($details->{datemode} eq 'shift') { |
|
$details->{dateshift} = $env{'form.colldateshift'}; |
|
} else { |
|
$details->{dateshift} = ''; |
|
} |
|
} elsif (($reqtype eq 'textbook') || ($reqtype eq 'template')) { |
|
$details->{datemode} = 'delete'; |
|
$details->{dateshift} = ''; |
|
} |
|
if ($details->{dateshift} ne '') { |
|
$details->{dateshift} =~ s/[^\d\.]+//g; |
|
} |
|
} else { |
|
$details->{datemode} = ''; |
|
$details->{dateshift} = ''; |
} |
} |
my $lonhost = $r->dir_config('lonHostID'); |
my $lonhost = $r->dir_config('lonHostID'); |
$r->rflush(); |
$r->rflush(); |
my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,'', |
my ($result,$output,$customized) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details, |
$req_notifylist,[],$domconfig); |
'',$req_notifylist,[],$domconfig); |
$r->print($output); |
$r->print($output); |
if (&Apache::loncoursequeueadmin::author_prompt()) { |
if (&Apache::loncoursequeueadmin::author_prompt()) { |
&print_author_prompt($r,$action,$cnum,$dom,$crstype,$result); |
unless ($customized) { |
|
&print_author_prompt($r,$action,$cnum,$dom,$crstype,$result); |
|
} |
} elsif ($result eq 'created') { |
} elsif ($result eq 'created') { |
$r->print('<p><a href="/adm/requestcourse">'.&mt('Create another course').'</a></p>'); |
unless ($customized) { |
|
$r->print('<p><a href="/adm/requestcourse">'.&mt('Create another course').'</a></p>'); |
|
} |
} |
} |
&endContentScreen($r); |
&endContentScreen($r); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|
sub textbook_request_javascript { |
sub textbook_request_javascript { |
my ($numprefab,$numcurrent) = @_; |
my ($numprefab,$numcurrent,$numcolleague,$customvalidationjs) = @_; |
return unless (ref($numprefab) eq 'HASH'); |
return unless (ref($numprefab) eq 'HASH'); |
return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent); |
return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent && !$numcolleague); |
my %lt = &Apache::lonlocal::texthash( |
my %js_lt = &Apache::lonlocal::texthash( |
choose => 'Please select a content option.', |
choose => 'Please select a content option.', |
textbook => 'Please select a textbook, or choose a different option.', |
textbook => 'Please select a textbook, or choose a different option.', |
template => 'Please select a template, or choose a different option.', |
template => 'Please select a template, or choose a different option.', |
existing => 'Please select one of your existing courses to copy, or choose a different option.', |
existing => 'Please select one of your existing courses to copy, or choose a different option.', |
title => 'Please enter a course title.', |
colleague => "Please select a colleague's course to copy, or choose a different option.", |
|
title => 'Please enter a course title.', |
); |
); |
|
&js_escape(\%js_lt); |
return <<"ENDSCRIPT"; |
return <<"ENDSCRIPT"; |
function cloneChoice() { |
function cloneChoice() { |
if (document.requestcourse.cloning) { |
if (document.requestcourse.cloning) { |
var radioLength = document.requestcourse.cloning.length; |
var radioLength = document.requestcourse.cloning.length; |
if (radioLength == undefined) { |
if (radioLength == undefined) { |
var val = document.requestcourse.cloning.value; |
var val = document.requestcourse.cloning.value; |
if ((val == 'textbook') || (val == 'template') || (val == 'existing')) { |
if ((val == 'textbook') || (val == 'template') || (val == 'existing') || (val == 'colleague')) { |
var elem = document.getElementById('show'+val); |
var elem = document.getElementById('show'+val); |
if (document.requestcourse.cloning.checked) { |
if (document.requestcourse.cloning.checked) { |
elem.style.display = 'block'; |
elem.style.display = 'block'; |
Line 4887 function cloneChoice() {
|
Line 5137 function cloneChoice() {
|
} else { |
} else { |
for (var i=0; i<radioLength; i++) { |
for (var i=0; i<radioLength; i++) { |
var val = document.requestcourse.cloning[i].value; |
var val = document.requestcourse.cloning[i].value; |
if ((val == 'textbook') || (val == 'template') || (val == 'existing')) { |
if ((val == 'textbook') || (val == 'template') || (val == 'existing') || (val == 'colleague')) { |
var elem = document.getElementById('show'+val); |
var elem = document.getElementById('show'+val); |
if (document.requestcourse.cloning[i].checked) { |
if (document.requestcourse.cloning[i].checked) { |
elem.style.display = 'block'; |
elem.style.display = 'block'; |
Line 4901 function cloneChoice() {
|
Line 5151 function cloneChoice() {
|
if (val == 'existing') { |
if (val == 'existing') { |
uncheckRadio('owned'); |
uncheckRadio('owned'); |
} |
} |
|
if (val == 'colleague') { |
|
uncheckRadio('colleague'); |
|
} |
elem.style.display = 'none'; |
elem.style.display = 'none'; |
} |
} |
} |
} |
Line 4928 function uncheckAllRadio() {
|
Line 5181 function uncheckAllRadio() {
|
var numbook = $numprefab->{'textbooks'}; |
var numbook = $numprefab->{'textbooks'}; |
var numtemplate = $numprefab->{'templates'}; |
var numtemplate = $numprefab->{'templates'}; |
var numcurrent = $numcurrent; |
var numcurrent = $numcurrent; |
|
var numcolleague = $numcolleague; |
if (numbook > 0) { |
if (numbook > 0) { |
uncheckRadio('textbook'); |
uncheckRadio('textbook'); |
} |
} |
if (nutemplate > 0) { |
if (numtemplate > 0) { |
uncheckRadio('template'); |
uncheckRadio('template'); |
}m |
} |
if (numcurrent > 0) { |
if (numcurrent > 0) { |
uncheckRadio('existing'); |
uncheckRadio('existing'); |
} |
} |
|
if (numcolleague > 0) { |
|
uncheckRadio('colleague'); |
|
} |
return; |
return; |
} |
} |
|
|
Line 4946 function validTextbookReq() {
|
Line 5203 function validTextbookReq() {
|
var radioLength = document.requestcourse.cloning.length; |
var radioLength = document.requestcourse.cloning.length; |
if (radioLength == undefined) { |
if (radioLength == undefined) { |
if (document.requestcourse.cloning.checked == false) { |
if (document.requestcourse.cloning.checked == false) { |
alert("$lt{'choose'}"); |
alert("$js_lt{'choose'}"); |
return false; |
return false; |
} else { |
} else { |
cloneChoice = document.requestcourse.cloning.value; |
cloneChoice = document.requestcourse.cloning.value; |
Line 4959 function validTextbookReq() {
|
Line 5216 function validTextbookReq() {
|
} |
} |
} |
} |
if (cloneChoice == 0) { |
if (cloneChoice == 0) { |
alert("$lt{'choose'}"); |
alert("$js_lt{'choose'}"); |
return false; |
return false; |
} |
} |
} |
} |
var group; |
var group; |
if ((cloneChoice == 'textbook') || (cloneChoice == 'template') || (cloneChoice == 'existing')) { |
if ((cloneChoice == 'textbook') || (cloneChoice == 'template') || (cloneChoice == 'existing') || (cloneChoice == 'colleague')) { |
var group; |
var group; |
if (cloneChoice == 'textbook') { |
if (cloneChoice == 'textbook') { |
group = document.getElementsByName('book'); |
group = document.getElementsByName('book'); |
Line 4972 function validTextbookReq() {
|
Line 5229 function validTextbookReq() {
|
if (cloneChoice == 'template') { |
if (cloneChoice == 'template') { |
group = document.getElementsByName('template'); |
group = document.getElementsByName('template'); |
} else { |
} else { |
group = document.getElementsByName('owned'); |
if (cloneChoice == 'existing') { |
|
group = document.getElementsByName('owned'); |
|
} else { |
|
group = document.getElementsByName('colleague'); |
|
} |
} |
} |
} |
} |
var groupLength = group.length; |
var groupLength = group.length; |
Line 4991 function validTextbookReq() {
|
Line 5252 function validTextbookReq() {
|
} |
} |
if (chosen == 0) { |
if (chosen == 0) { |
if (cloneChoice == 'textbook') { |
if (cloneChoice == 'textbook') { |
alert("$lt{'textbook'}"); |
alert("$js_lt{'textbook'}"); |
} else { |
} else { |
if (cloneChoice == 'template') { |
if (cloneChoice == 'template') { |
alert("$lt{'template'}"); |
alert("$js_lt{'template'}"); |
} else { |
} else { |
alert("$lt{'existing'}"); |
if (cloneChoice == 'existing') { |
|
alert("$js_lt{'existing'}"); |
|
} else { |
|
alert("$js_lt{'colleague'}"); |
|
} |
} |
} |
} |
} |
return false; |
return false; |
Line 5004 function validTextbookReq() {
|
Line 5269 function validTextbookReq() {
|
} |
} |
} |
} |
if (document.requestcourse.cdescr.value == '') { |
if (document.requestcourse.cdescr.value == '') { |
alert("$lt{'title'}"); |
alert("$js_lt{'title'}"); |
return false; |
return false; |
} |
} |
|
$customvalidationjs |
return true; |
return true; |
} |
} |
|
|
Line 5014 ENDSCRIPT
|
Line 5280 ENDSCRIPT
|
|
|
} |
} |
|
|
|
sub textbook_request_disabled { |
|
my ($r,$dom,$action,$can_request) = @_; |
|
if (ref($can_request) eq 'HASH') { |
|
if ($action eq 'process') { |
|
unless ((scalar(keys(%{$can_request})) == 1)) { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
|
{ href => '/adm/requestcourse', |
|
text => 'Pick action', |
|
}); |
|
} |
|
} |
|
} |
|
$r->print(&header('Course Request')); |
|
&Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'). |
|
'<div>'. |
|
'<p class="LC_info">'.&mt('You do not have privileges to request creation of textbook courses.').'</p>'); |
|
if (ref($can_request) eq 'HASH') { |
|
if (scalar(keys(%{$can_request})) > 1) { |
|
$r->print('<a href="/adm/requestcourse">'.&mt('Go back').'</a>'); |
|
} |
|
} |
|
$r->print('</div>'. |
|
&Apache::loncommon::end_page()); |
|
return; |
|
} |
|
|
sub startContentScreen { |
sub startContentScreen { |
my ($r,$mode)=@_; |
my ($r,$mode)=@_; |
$r->print("\n".'<ul class="LC_TabContentBigger" id="textbookreq">'."\n"); |
$r->print("\n".'<ul class="LC_TabContentBigger" id="textbookreq">'."\n"); |