--- loncom/interface/lonrequestcourse.pm 2014/05/06 20:42:27 1.80 +++ loncom/interface/lonrequestcourse.pm 2014/05/09 15:02:31 1.81 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.80 2014/05/06 20:42:27 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.81 2014/05/09 15:02:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4393,25 +4393,26 @@ sub generate_date_items { sub print_textbook_form { my ($r,$dom,$incdoms,$domdefs,$settings,$can_request) = @_; - my ($bookshash,%ordered); + my (%prefab,%ordered,%numprefab); 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; - if (ref($settings) eq 'HASH') { - $bookshash = $settings->{'textbooks'}; - if (ref($bookshash) eq 'HASH') { - foreach my $item (keys(%{$bookshash})) { - my ($clonedom,$clonecrs) = split(/_/,$item); - if (ref($bookshash->{$item}) eq 'HASH') { + foreach my $type ('textbooks','templates') { + $numprefab{$type} = 0; + if (ref($settings) eq 'HASH') { + $prefab{$type} = $settings->{$type}; + if (ref($prefab{$type}) eq 'HASH') { + foreach my $item (keys(%{$prefab{$type}})) { my ($clonedom,$clonecrs) = split(/_/,$item); - if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, - $env{'user.domain'},$clonecrs,$clonedom,$crstype)) { - - my $num = $bookshash->{$item}{'order'}; - $ordered{$num} = $item; - $numbook ++; + if (ref($prefab{$type}{$item}) eq 'HASH') { + if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, + $env{'user.domain'},$clonecrs,$clonedom,$crstype)) { + + my $num = $prefab{$type}{$item}{'order'}; + $ordered{$type}{$num} = $item; + $numprefab{$type} ++; + } } } } @@ -4447,7 +4448,7 @@ sub print_textbook_form { my $numcurrent = scalar(keys(%cloneable)); - my $jscript = &textbook_request_javascript($numbook,$numcurrent); + my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent); my %loaditems; $loaditems{'onload'} = 'javascript:uncheckAllRadio();'; $r->print(&header('Course Request',$jscript,\%loaditems)); @@ -4498,9 +4499,16 @@ sub print_textbook_form { $r->print('