version 1.78, 2014/04/16 14:40:17
|
version 1.83, 2014/05/14 18:20:09
|
Line 174 sub handler {
|
Line 174 sub handler {
|
} else { |
} else { |
&textbook_request_disabled($r,$dom,\%can_request); |
&textbook_request_disabled($r,$dom,\%can_request); |
} |
} |
|
} elsif ($action eq 'display') { |
|
my ($uname,$udom,$result,$warning) = &domcoord_display($dom); |
|
if ($warning ne '') { |
|
my $args = { only_body => 1 }; |
|
$r->print(&header('Course/Community Requests','','' ,'',$args). |
|
'<h3>'.&mt('Course/Community Request Details').'</h3>'. |
|
'<div class="LC_warning">'.$warning.'</div>'. |
|
&close_popup_form()); |
|
} else { |
|
$states{'display'} = ['details']; |
|
my $loaditems = &onload_action($action,$state); |
|
my $page = 0; |
|
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
|
$loaditems,'','','','','',$showcredits,'','', |
|
$uname,$udom); |
|
} |
} else { |
} else { |
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); |
Line 232 sub handler {
|
Line 248 sub handler {
|
my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) = |
my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) = |
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail); |
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail); |
if ($action eq 'display') { |
if ($action eq 'display') { |
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { |
($uname,$udom,$result,$warning) = &domcoord_display($dom); |
if ($env{'form.cnum'} ne '') { |
|
my $cnum = $env{'form.cnum'}; |
|
my $queue = $env{'form.queue'}; |
|
my $reqkey = $cnum.'_'.$queue; |
|
my $namespace = 'courserequestqueue'; |
|
my $domconfig = &Apache::lonnet::get_domainconfiguser($dom); |
|
my %queued = |
|
&Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig); |
|
if (ref($queued{$reqkey}) eq 'HASH') { |
|
$uname = $queued{$reqkey}{'ownername'}; |
|
$udom = $queued{$reqkey}{'ownerdom'}; |
|
if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) { |
|
$result = &retrieve_settings($dom,$cnum,$udom,$uname); |
|
} else { |
|
if ($env{'form.crstype'} eq 'community') { |
|
$warning = &mt('Invalid username or domain for community requestor'); |
|
} else { |
|
$warning = &mt('Invalid username or domain for course requestor'); |
|
} |
|
} |
|
} else { |
|
if ($env{'form.crstype'} eq 'community') { |
|
$warning = &mt('No information was found for this community request.'); |
|
} 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))) { |
} elsif ((defined($state)) && (defined($action))) { |
if (($action eq 'view') && ($state eq 'details')) { |
if (($action eq 'view') && ($state eq 'details')) { |
if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) { |
if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) { |
Line 1129 END
|
Line 1106 END
|
return; |
return; |
} |
} |
|
|
|
sub domcoord_display { |
|
my ($dom) = @_; |
|
my ($uname,$udom,$result,$warning); |
|
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { |
|
if ($env{'form.cnum'} ne '') { |
|
my $cnum = $env{'form.cnum'}; |
|
my $queue = $env{'form.queue'}; |
|
my $reqkey = $cnum.'_'.$queue; |
|
my $namespace = 'courserequestqueue'; |
|
my $domconfig = &Apache::lonnet::get_domainconfiguser($dom); |
|
my %queued = |
|
&Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig); |
|
if (ref($queued{$reqkey}) eq 'HASH') { |
|
$uname = $queued{$reqkey}{'ownername'}; |
|
$udom = $queued{$reqkey}{'ownerdom'}; |
|
if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) { |
|
$result = &retrieve_settings($dom,$cnum,$udom,$uname); |
|
} else { |
|
if ($env{'form.crstype'} eq 'community') { |
|
$warning = &mt('Invalid username or domain for community requestor'); |
|
} else { |
|
$warning = &mt('Invalid username or domain for course requestor'); |
|
} |
|
} |
|
} else { |
|
if ($env{'form.crstype'} eq 'community') { |
|
$warning = &mt('No information was found for this community request.'); |
|
} 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.'); |
|
} |
|
} |
|
return ($uname,$udom,$result,$warning); |
|
} |
|
|
sub enrollment_lcsec_js { |
sub enrollment_lcsec_js { |
my %alerts = §ion_check_alerts(); |
my %alerts = §ion_check_alerts(); |
my $secname = $alerts{'badsec'}; |
my $secname = $alerts{'badsec'}; |
Line 3739 sub process_request {
|
Line 3762 sub process_request {
|
if ($code) { |
if ($code) { |
$reqhash{'code'} = $code; |
$reqhash{'code'} = $code; |
} |
} |
|
if (ref($postprocess) eq 'HASH') { |
|
if (ref($postprocess->{'createdactions'}) eq 'HASH') { |
|
if (ref($postprocess->{'createdactions'}{'environment'}) eq 'HASH') { |
|
&Apache::loncoursequeueadmin::postprocess_crsenv($dom,$cnum, |
|
$postprocess->{'createdactions'}{'environment'}); |
|
} |
|
} |
|
} |
$output .= '<br />'.$role_result.'</p>'; |
$output .= '<br />'.$role_result.'</p>'; |
$creationresult = 'created'; |
$creationresult = 'created'; |
} else { |
} else { |
Line 4385 sub generate_date_items {
|
Line 4416 sub generate_date_items {
|
|
|
sub print_textbook_form { |
sub print_textbook_form { |
my ($r,$dom,$incdoms,$domdefs,$settings,$can_request) = @_; |
my ($r,$dom,$incdoms,$domdefs,$settings,$can_request) = @_; |
my ($bookshash,%ordered); |
my (%prefab,%ordered,%numprefab); |
my $crstype = 'textbook'; |
my $crstype = 'textbook'; |
# |
# |
# Retrieve list of textbook courses cloneable by user |
# Retrieve list of prefabricated courses (textbook courses and templates) cloneable by user |
# |
# |
my $numbook; |
foreach my $type ('textbooks','templates') { |
if (ref($settings) eq 'HASH') { |
$numprefab{$type} = 0; |
$bookshash = $settings->{'textbooks'}; |
if (ref($settings) eq 'HASH') { |
if (ref($bookshash) eq 'HASH') { |
$prefab{$type} = $settings->{$type}; |
foreach my $item (keys(%{$bookshash})) { |
if (ref($prefab{$type}) eq 'HASH') { |
my ($clonedom,$clonecrs) = split(/_/,$item); |
foreach my $item (keys(%{$prefab{$type}})) { |
if (ref($bookshash->{$item}) eq 'HASH') { |
|
my ($clonedom,$clonecrs) = split(/_/,$item); |
my ($clonedom,$clonecrs) = split(/_/,$item); |
if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
if (ref($prefab{$type}{$item}) eq 'HASH') { |
$env{'user.domain'},$clonecrs,$clonedom,$crstype)) { |
if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, |
|
$env{'user.domain'},$clonecrs,$clonedom,$crstype)) { |
my $num = $bookshash->{$item}{'order'}; |
|
$ordered{$num} = $item; |
my $num = $prefab{$type}{$item}{'order'}; |
$numbook ++; |
$ordered{$type}{$num} = $item; |
|
$numprefab{$type} ++; |
|
} |
} |
} |
} |
} |
} |
} |
Line 4439 sub print_textbook_form {
|
Line 4471 sub print_textbook_form {
|
|
|
my $numcurrent = scalar(keys(%cloneable)); |
my $numcurrent = scalar(keys(%cloneable)); |
|
|
my $jscript = &textbook_request_javascript($numbook,$numcurrent); |
my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent); |
my %loaditems; |
my %loaditems; |
$loaditems{'onload'} = 'javascript:uncheckAllRadio();'; |
$loaditems{'onload'} = 'javascript:uncheckAllRadio();'; |
$r->print(&header('Course Request',$jscript,\%loaditems)); |
$r->print(&header('Course Request',$jscript,\%loaditems)); |
Line 4490 sub print_textbook_form {
|
Line 4522 sub print_textbook_form {
|
$r->print('<div>'. |
$r->print('<div>'. |
'<fieldset><legend>'.&mt('Course Content').'</legend>'); |
'<fieldset><legend>'.&mt('Course Content').'</legend>'); |
if (keys(%ordered)) { |
if (keys(%ordered)) { |
$r->print('<span class="LC_nobreak"><label>'. |
if (ref($ordered{'textbooks'}) eq 'HASH') { |
'<input type="radio" name="cloning" value="textbook" onclick="javascript:cloneChoice();" />'. |
$r->print('<span class="LC_nobreak"><label>'. |
&mt('Load textbook content').'</span>'.(' 'x2).' '); |
'<input type="radio" name="cloning" value="textbook" onclick="javascript:cloneChoice();" />'. |
|
&mt('Load textbook content').'</span>'.(' 'x2).' '); |
|
} |
|
if (ref($ordered{'templates'}) eq 'HASH') { |
|
$r->print('<span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="cloning" value="template" onclick="javascript:cloneChoice();" />'. |
|
&mt('Load pre-existing template').'</span>'.(' 'x2).' '); |
|
} |
} |
} |
if (keys(%cloneable)) { |
if (keys(%cloneable)) { |
$r->print('<span class="LC_nobreak"><label>'. |
$r->print('<span class="LC_nobreak"><label>'. |
Line 4510 sub print_textbook_form {
|
Line 4549 sub print_textbook_form {
|
# Table of cloneable textbook courses |
# Table of cloneable textbook courses |
# |
# |
if (keys(%ordered)) { |
if (keys(%ordered)) { |
$r->print('<div id="showtextbook" style="display:none">'. |
foreach my $type ('textbooks','templates') { |
&Apache::loncommon::start_data_table(). |
my $divid = 'showtextbook'; |
&Apache::loncommon::start_data_table_header_row(). |
my $radioid = 'book'; |
'<th>'.&mt('Title').'</th>'. |
if ($type eq 'templates') { |
'<th>'.&mt('Author(s)').'</th>'. |
$divid = 'showtemplate'; |
'<th>'.&mt('Subject').'</th>'. |
$radioid = 'template'; |
'<th>'.&mt('Book').'</th>'. |
} |
&Apache::loncommon::end_data_table_header_row()); |
if (ref($ordered{$type}) eq 'HASH') { |
my @items = sort { $a <=> $b } keys(%ordered); |
$r->print('<div id="'.$divid.'" style="display:none">'. |
foreach my $num (@items) { |
&Apache::loncommon::start_data_table(). |
my $item = $ordered{$num}; |
&Apache::loncommon::start_data_table_header_row(). |
my $cleantitle=&HTML::Entities::encode($bookshash->{$item}->{'title'},'<>&"'); |
'<th>'.&mt('Title').'</th>'); |
$cleantitle=~s/'/\\'/g; |
if ($type eq 'textbooks') { |
$cleantitle =~ s/^\s+//; |
$r->print('<th>'.&mt('Author(s)').'</th>'); |
$r->print(&Apache::loncommon::start_data_table_row(). |
} |
'<td><label><input type="radio" name="book" value="'.$item.'" />'. |
$r->print('<th>'.&mt('Subject').'</th>'); |
$cleantitle.'</label></td>'. |
if ($type eq 'textbooks') { |
'<td>'.$bookshash->{$item}->{'author'}.'</td>'. |
$r->print('<th>'.&mt('Publisher').'</th>'. |
'<td>'.$bookshash->{$item}->{'subject'}.'</td>'. |
'<th>'.&mt('Book').'</th>'); |
'<td><img border="0" src="'.$bookshash->{$item}->{'image'}. |
} |
'" alt="'.$cleantitle.'" /></td>'. |
$r->print(&Apache::loncommon::end_data_table_header_row()); |
&Apache::loncommon::end_data_table_row()); |
my @items = sort { $a <=> $b } keys(%{$ordered{$type}}); |
|
foreach my $num (@items) { |
|
my $item = $ordered{$type}{$num}; |
|
my $cleantitle=&HTML::Entities::encode($prefab{$type}{$item}{'title'},'<>&"'); |
|
$cleantitle=~s/'/\\'/g; |
|
$cleantitle =~ s/^\s+//; |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<td><label><input type="radio" name="'.$radioid.'" value="'.$item.'" />'. |
|
$cleantitle.'</label></td>'); |
|
if ($type eq 'textbooks') { |
|
$r->print('<td>'.$prefab{$type}{$item}{'author'}.'</td>'); |
|
} |
|
$r->print('<td>'.$prefab{$type}{$item}{'subject'}.'</td>'); |
|
if ($type eq 'textbooks') { |
|
$r->print('<td>'.$prefab{$type}{$item}{'publisher'}.'</td>'. |
|
'<td><img border="0" src="'.$prefab{$type}{$item}{'image'}. |
|
'" alt="'.$cleantitle.'" /></td>'); |
|
} |
|
$r->print(&Apache::loncommon::end_data_table_row()); |
|
} |
|
$r->print(&Apache::loncommon::end_data_table(). |
|
'</div>'); |
|
} |
} |
} |
$r->print(&Apache::loncommon::end_data_table(). |
|
'</div>'); |
|
} |
} |
|
|
# |
# |
Line 4702 sub process_textbook_request {
|
Line 4761 sub process_textbook_request {
|
my ($clonefrom,$clonedom,$clonecrs); |
my ($clonefrom,$clonedom,$clonecrs); |
if ($reqtype eq 'textbook') { |
if ($reqtype eq 'textbook') { |
$clonefrom = $env{'form.book'}; |
$clonefrom = $env{'form.book'}; |
|
} elsif ($reqtype eq 'template') { |
|
$clonefrom = $env{'form.template'}; |
} elsif ($reqtype eq 'existing') { |
} elsif ($reqtype eq 'existing') { |
$clonefrom = $env{'form.owned'}; |
$clonefrom = $env{'form.owned'}; |
} |
} |
Line 4773 sub process_textbook_request {
|
Line 4834 sub process_textbook_request {
|
} |
} |
|
|
sub textbook_request_javascript { |
sub textbook_request_javascript { |
my ($numbook,$numcurrent) = @_; |
my ($numprefab,$numcurrent) = @_; |
|
return unless (ref($numprefab) eq 'HASH'); |
|
return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent); |
my %lt = &Apache::lonlocal::texthash( |
my %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.', |
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.', |
title => 'Please enter a course title.', |
); |
); |
return if (!$numbook && !$numcurrent); |
|
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 == 'existing')) { |
if ((val == 'textbook') || (val == 'template') || (val == 'existing')) { |
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 4799 function cloneChoice() {
|
Line 4862 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 == 'existing')) { |
if ((val == 'textbook') || (val == 'template') || (val == 'existing')) { |
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 4807 function cloneChoice() {
|
Line 4870 function cloneChoice() {
|
if (val == 'textbook') { |
if (val == 'textbook') { |
uncheckRadio('book'); |
uncheckRadio('book'); |
} |
} |
|
if (val == 'template') { |
|
uncheckRadio('template'); |
|
} |
if (val == 'existing') { |
if (val == 'existing') { |
uncheckRadio('owned'); |
uncheckRadio('owned'); |
} |
} |
Line 4834 function uncheckRadio(radioGroupName) {
|
Line 4900 function uncheckRadio(radioGroupName) {
|
|
|
function uncheckAllRadio() { |
function uncheckAllRadio() { |
uncheckRadio('cloning'); |
uncheckRadio('cloning'); |
var numbook = $numbook; |
var numbook = $numprefab->{'textbooks'}; |
|
var numtemplate = $numprefab->{'templates'}; |
var numcurrent = $numcurrent; |
var numcurrent = $numcurrent; |
if (numbook > 0) { |
if (numbook > 0) { |
uncheckRadio('textbook'); |
uncheckRadio('textbook'); |
} |
} |
|
if (nutemplate > 0) { |
|
uncheckRadio('template'); |
|
}m |
if (numcurrent > 0) { |
if (numcurrent > 0) { |
uncheckRadio('existing'); |
uncheckRadio('existing'); |
} |
} |
Line 4869 function validTextbookReq() {
|
Line 4939 function validTextbookReq() {
|
} |
} |
} |
} |
var group; |
var group; |
if ((cloneChoice == 'textbook') || (cloneChoice == 'existing')) { |
if ((cloneChoice == 'textbook') || (cloneChoice == 'template') || (cloneChoice == 'existing')) { |
var group; |
var group; |
if (cloneChoice == 'textbook') { |
if (cloneChoice == 'textbook') { |
group = document.getElementsByName('book'); |
group = document.getElementsByName('book'); |
} else { |
} else { |
group = document.getElementsByName('owned'); |
if (cloneChoice == 'template') { |
|
group = document.getElementsByName('template'); |
|
} else { |
|
group = document.getElementsByName('owned'); |
|
} |
} |
} |
var groupLength = group.length; |
var groupLength = group.length; |
var chosen = 0; |
var chosen = 0; |
Line 4894 function validTextbookReq() {
|
Line 4968 function validTextbookReq() {
|
if (cloneChoice == 'textbook') { |
if (cloneChoice == 'textbook') { |
alert("$lt{'textbook'}"); |
alert("$lt{'textbook'}"); |
} else { |
} else { |
alert("$lt{'existing'}"); |
if (cloneChoice == 'template') { |
|
alert("$lt{'template'}"); |
|
} else { |
|
alert("$lt{'existing'}"); |
|
} |
} |
} |
return false; |
return false; |
} |
} |