--- loncom/interface/domainprefs.pm 2014/05/05 23:28:53 1.241
+++ loncom/interface/domainprefs.pm 2014/05/09 15:02:31 1.242
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.241 2014/05/05 23:28:53 raeburn Exp $
+# $Id: domainprefs.pm,v 1.242 2014/05/09 15:02:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -369,6 +369,8 @@ sub handler {
col2 => 'Value'},
{col1 => 'Available textbooks',
col2 => ''},
+ {col1 => 'Available templates',
+ col2 => ''},
{col1 => 'Validation (not official courses)',
col2 => 'Value'},],
print => \&print_quotas,
@@ -771,7 +773,18 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col1'}).' |
'.&mt($item->{'header'}->[2]->{'col2'}).' |
'.
- &print_textbookcourses($dom,$settings,\$rowtotal).'
+ &textbookcourses_javascript($settings).
+ &print_textbookcourses($dom,'textbooks',$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.&mt($item->{'header'}->[3]->{'col1'}).' |
+ '.&mt($item->{'header'}->[3]->{'col2'}).' | '.
+ &print_textbookcourses($dom,'templates',$settings,\$rowtotal).'
|
@@ -779,8 +792,8 @@ sub print_config_box {
- '.&mt($item->{'header'}->[3]->{'col1'}).' |
- '.&mt($item->{'header'}->[3]->{'col2'}).' |
+ '.&mt($item->{'header'}->[4]->{'col1'}).' |
+ '.&mt($item->{'header'}->[4]->{'col2'}).' |
'.
&print_validation_rows('requestcourses',$dom,$settings,\$rowtotal);
} elsif ($action eq 'requestauthor') {
@@ -2093,14 +2106,14 @@ sub print_studentcode {
}
sub print_textbookcourses {
- my ($dom,$settings,$rowtotal) = @_;
+ my ($dom,$type,$settings,$rowtotal) = @_;
my $rownum = 0;
my $css_class;
my $itemcount = 1;
my $maxnum = 0;
my $bookshash;
if (ref($settings) eq 'HASH') {
- $bookshash = $settings->{'textbooks'};
+ $bookshash = $settings->{$type};
}
my %ordered;
if (ref($bookshash) eq 'HASH') {
@@ -2113,8 +2126,8 @@ sub print_textbookcourses {
}
my $confname = $dom.'-domainconfig';
my $switchserver = &check_switchserver($dom,$confname);
- $maxnum = scalar(keys(%ordered));
- my $datatable = &textbookcourses_javascript(\%ordered);
+ my $maxnum = scalar(keys(%ordered));
+ my $datatable;
if (keys(%ordered)) {
my @items = sort { $a <=> $b } keys(%ordered);
for (my $i=0; $i<@items; $i++) {
@@ -2126,17 +2139,19 @@ sub print_textbookcourses {
if (ref($bookshash->{$key}) eq 'HASH') {
$subject = $bookshash->{$key}->{'subject'};
$title = $bookshash->{$key}->{'title'};
- $author = $bookshash->{$key}->{'author'};
- $image = $bookshash->{$key}->{'image'};
- if ($image ne '') {
- my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$});
- my $imagethumb = "$path/tn-".$imagefile;
- $imgsrc = '';
+ if ($type eq 'textbooks') {
+ $author = $bookshash->{$key}->{'author'};
+ $image = $bookshash->{$key}->{'image'};
+ if ($image ne '') {
+ my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$});
+ my $imagethumb = "$path/tn-".$imagefile;
+ $imgsrc = '';
+ }
}
}
- my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$key'".');"';
+ my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type".'_'."$key','$type'".');"';
$datatable .= ''
- .' | '.
''.
- ''.&mt('Subject:').' '.
- (' 'x2).
- ''.&mt('Title:').' '.
- (' 'x2).
- ''.&mt('Author(s):').' '.
+ ''.&mt('Subject:').' '.
(' 'x2).
- ''.&mt('Thumbnail:');
- if ($image) {
- $datatable .= ''.
- $imgsrc.
- ''.&mt('Delete?').' '.
- ' '.&mt('Replace:').' ';
- }
- if ($switchserver) {
- $datatable .= &mt('Upload to library server: [_1]',$switchserver);
- } else {
- $datatable .= '';
+ ''.&mt('Title:').' ';
+ if ($type eq 'textbooks') {
+ $datatable .= (' 'x2).
+ ''.&mt('Author(s):').' '.
+ (' 'x2).
+ ''.&mt('Thumbnail:');
+ if ($image) {
+ $datatable .= ''.
+ $imgsrc.
+ ''.&mt('Delete?').' '.
+ ' '.&mt('Replace:').' ';
+ }
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= '';
+ }
}
- $datatable .= ' '.
+ $datatable .= ' '.
''.&mt('LON-CAPA course:').' '.
$coursetitle.' | '."\n";
$itemcount ++;
}
}
$css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'addbook_pos'".');"';
+ my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type"."_addbook_pos','$type'".');"';
$datatable .= ''."\n".
- ''."\n".
- '';
+ ''."\n".
+ '';
for (my $k=0; $k<$maxnum+1; $k++) {
my $vpos = $k+1;
my $selstr;
@@ -2188,26 +2205,28 @@ sub print_textbookcourses {
$datatable .= '';
}
$datatable .= ' '."\n".
- ''.&mt('Add').' | '."\n".
+ ''.&mt('Add').''."\n".
''.
- ''.&mt('Subject:').' '."\n".
- (' 'x2).
- ''.&mt('Title:').' '."\n".
- (' 'x2).
- ''.&mt('Author(s):').' '."\n".
+ ''.&mt('Subject:').' '."\n".
(' 'x2).
- ''.&mt('Image:').' ';
- if ($switchserver) {
- $datatable .= &mt('Upload to library server: [_1]',$switchserver);
- } else {
- $datatable .= '';
+ ''.&mt('Title:').' '."\n".
+ (' 'x2);
+ if ($type eq 'textbooks') {
+ $datatable .= ''.&mt('Author(s):').' '."\n".
+ (' 'x2).
+ ''.&mt('Image:').' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= '';
+ }
}
$datatable .= ''."\n".
''.&mt('LON-CAPA course:').' '.
- &Apache::loncommon::select_dom_form($env{'request.role.domain'},'addbook_cdom').
- ''.
+ &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom').
+ ''.
&Apache::loncommon::selectcourse_link
- ('display','addbook_cnum','addbook_cdom',undef,undef,undef,'Course');
+ ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course');
' | '."\n".
' '."\n";
$itemcount ++;
@@ -2215,23 +2234,43 @@ sub print_textbookcourses {
}
sub textbookcourses_javascript {
- my ($textbooks) = @_;
- return unless(ref($textbooks) eq 'HASH');
- my $num = scalar(keys(%{$textbooks}));
- my @jsarray;
- foreach my $item (sort {$a <=> $b } (keys(%{$textbooks}))) {
- push(@jsarray,$textbooks->{$item});
+ my ($settings) = @_;
+ return unless(ref($settings) eq 'HASH');
+ my (%ordered,%total,%jstext);
+ foreach my $type ('textbooks','templates') {
+ $total{$type} = 0;
+ if (ref($settings->{$type}) eq 'HASH') {
+ foreach my $item (keys(%{$settings->{$type}})) {
+ if (ref($settings->{$type}->{$item}) eq 'HASH') {
+ my $num = $settings->{$type}->{$item}{'order'};
+ $ordered{$type}{$num} = $item;
+ }
+ }
+ $total{$type} = scalar(keys(%{$settings->{$type}}));
+ }
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%{$ordered{$type}}))) {
+ push(@jsarray,$ordered{$type}{$item});
+ }
+ $jstext{$type} = ' var '.$type.' = Array('."'".join("','",@jsarray)."'".');'."\n";
}
- my $jstext = ' var textbooks = Array('."'".join("','",@jsarray)."'".');'."\n";
return <<"ENDSCRIPT";
|