version 1.80, 2014/05/06 20:42:27
|
version 1.81, 2014/05/09 15:02:31
|
Line 4393 sub generate_date_items {
|
Line 4393 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 = 0; |
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 4447 sub print_textbook_form {
|
Line 4448 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 4498 sub print_textbook_form {
|
Line 4499 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 template content').'</span>'.(' 'x2).' '); |
|
} |
} |
} |
if (keys(%cloneable)) { |
if (keys(%cloneable)) { |
$r->print('<span class="LC_nobreak"><label>'. |
$r->print('<span class="LC_nobreak"><label>'. |
Line 4518 sub print_textbook_form {
|
Line 4526 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('Book').'</th>'); |
'<td>'.$bookshash->{$item}->{'subject'}.'</td>'. |
} |
'<td><img border="0" src="'.$bookshash->{$item}->{'image'}. |
$r->print(&Apache::loncommon::end_data_table_header_row()); |
'" alt="'.$cleantitle.'" /></td>'. |
my @items = sort { $a <=> $b } keys(%{$ordered{$type}}); |
&Apache::loncommon::end_data_table_row()); |
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><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 4710 sub process_textbook_request {
|
Line 4736 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 4781 sub process_textbook_request {
|
Line 4809 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 4807 function cloneChoice() {
|
Line 4837 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 4815 function cloneChoice() {
|
Line 4845 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 4842 function uncheckRadio(radioGroupName) {
|
Line 4875 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 4877 function validTextbookReq() {
|
Line 4914 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 4902 function validTextbookReq() {
|
Line 4943 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; |
} |
} |