--- loncom/interface/lonpickcourse.pm 2009/05/04 13:24:12 1.79
+++ loncom/interface/lonpickcourse.pm 2009/08/19 19:51:22 1.86
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Pick a course
#
-# $Id: lonpickcourse.pm,v 1.79 2009/05/04 13:24:12 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.86 2009/08/19 19:51:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,7 @@ use Apache::lonnet;
use Apache::lonlocal;
use Apache::longroup;
use Apache::courseclassifier;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
sub handler {
my $r = shift;
@@ -50,23 +50,22 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi
($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement',
'cdomelement','cnameelement','roleelement',
- 'multiple','type','setroles','fixeddom']);
-
+ 'multiple','type','setroles','fixeddom','cloner']);
my ($type,$title,$jscript,$multelement,$multiple,$roleelement,
- $lastaction,$autosubmit,$submitopener);
+ $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom);
- # Get course type - Course or Non-standard Course.
+ # Get course type - Course or Community.
$type = $env{'form.type'};
if (!defined($env{'form.type'})) {
$type = 'Course';
}
- $title = &mt('Selecting a [_1]',$type);
+ $title = 'Selecting a '.$type;
# Setup for multiple course selections, if flag for multiples set.
$multiple = $env{'form.multiple'};
if ($multiple) {
($jscript,$multelement) = &multiples_tag();
- $title = &mt('Selecting [_1](s)',lc($type));
+ $title = 'Selecting '.$type.'(s)';
}
# if called when a DC is selecting a course
@@ -77,6 +76,17 @@ sub handler {
$autosubmit = 'process_pick("'.$roledom.'")';
}
+ # if called when a DC is creating a course
+ if ($env{'form.form'} eq 'ccrs') {
+ ($cloneruname,$clonerudom) = ($env{'form.cloner'} =~ /^($match_username):($match_domain)$/);
+ }
+
+ # if called when requesting a course
+ if ($env{'form.form'} eq 'requestcrs') {
+ $cloneruname = $env{'user.name'};
+ $clonerudom = $env{'user.domain'};
+ }
+
my $onlyown = 0;
# if called to assign course-based portfolio access control
if ((($env{'form.form'} eq 'portform') && (!$env{'user.adv'}))) {
@@ -84,15 +94,18 @@ sub handler {
}
my %loaditem;
- if ($env{'form.numtitles'}) {
- $loaditem{'onload'} = 'setElements(); ';
+ if (($env{'form.type'} eq 'Course') && ($env{'form.numtitles'})) {
+ if (($env{'form.official'} eq 'on') && ($env{'form.state'} eq 'listing')) {
+ $loaditem{'onload'} = 'setElements(document.filterpicker); ';
+ }
}
if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) &&
($env{'form.pickedcourse'})) {
$loaditem{'onload'} .= 'setSections()';
}
- $r->print(&Apache::loncommon::start_page($title,undef,
+ my $js = &js_changer();
+ $r->print(&Apache::loncommon::start_page($title,$js,
{'add_entries' => \%loaditem,
'no_nav_bar' => 1, }));
@@ -113,7 +126,8 @@ sub handler {
}
# print javascript functions for choosing a course
- if ($env{'form.gosearch'} || $onlyown) {
+ if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) ||
+ $onlyown) {
$r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction));
}
$r->print('
+
+ENDJS
+
+}
+
sub processpick {
my $openerform = 'rolechoice';
if ($env{'form.form'} eq 'studentform') {
@@ -237,7 +276,7 @@ function setSections() {
}
sub display_matched_courses {
- my ($r,$type,$multiple,$action,$showroles,%courses) = @_;
+ my ($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,%courses) = @_;
if ($env{'form.form'} eq 'portform') {
$action = '/adm/portfolio';
}
@@ -314,11 +353,26 @@ sub display_matched_courses {
my $cleandesc=&HTML::Entities::encode($description,'<>&"');
$cleandesc=~s/'/\\'/g;
my ($cdom,$cnum)=split(/\_/,$course);
- my ($descr,$instcode,$ttype,@owners);
+ my ($descr,$instcode,$ttype,$canclone,@owners);
if (ref($courses{$course}) eq 'HASH') {
$descr = $courses{$course}{'description'};
- $instcode = $courses{$course}{'inst_code'};
- $ttype = $courses{$course}{'type'};
+ $instcode = $courses{$course}{'inst_code'};
+ $ttype = $courses{$course}{'type'};
+ if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
+ my $cloners = $courses{$course}{'cloners'};
+ if ($cloners ne '') {
+ my @cloneable = split(',',$cloners);
+ if (grep(/^\*$/,@cloneable)) {
+ $canclone = 1;
+ }
+ if (grep(/^\*:\Q$env{'form.clonerudom'}\E$/,@cloneable)) {
+ $canclone = 1;
+ }
+ if (grep(/^\Q$cloneruname\E:\Q$clonerudom\E$/,@cloneable)) {
+ $canclone = 1;
+ }
+ }
+ }
push(@owners,&unescape($courses{$course}{'owner'}));
if (ref($courses{$course}{'co-owners'}) eq 'ARRAY') {
foreach my $item (@{$courses{$course}{'co-owners'}}) {
@@ -331,7 +385,7 @@ sub display_matched_courses {
push(@owners,&unescape($singleowner));
}
my $ownerstr = join(', ',@owners);
- $r->print('
'.&course_chooser($multiple,$cdom,$cnum,$cleandesc).' | ');
+ $r->print(''.&course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone).' | ');
$r->print(''.$description.' | ');
$r->print('');
$r->print(&Apache::lonnet::domain($cdom,'description')?
@@ -423,12 +477,17 @@ sub multiples_tag {
sub build_filters {
my ($filterlist,$type,$roleelement,$multelement,$filter,$action,
- $numtitlesref) = @_;
- my $list;
- my $formname;
- my ($fixeddom,$codedom,$jscript);
+ $numtitlesref,$caller,$cloneruname,$clonerudom) = @_;
+ my ($list,$formname,$fixeddom,$codedom,$jscript);
+ $codedom = $env{'request.role.domain'};
if (defined($env{'form.form'})) {
- $formname = $env{'form.form'};
+ $formname = $env{'form.form'};
+ } else {
+ $formname = $caller;
+ }
+ my $onchange;
+ unless ($env{'form.interface'} eq 'textual') {
+ $onchange = 'javascript:updateFilters(this)';
}
my ($domainselectform,$sincefilterform,$ownerdomselectform,$persondomselectform,
$instcodeform,$typeselectform,$instcodetitle);
@@ -485,7 +544,7 @@ sub build_filters {
$domainselectform =
&Apache::loncommon::select_dom_form($filter->{$item},
'domainfilter',
- $allow_blank);
+ $allow_blank,'',$onchange);
$codedom = $filter->{'domainfilter'};
}
} else {
@@ -517,32 +576,58 @@ sub build_filters {
'inc' => &mt('Institutional Categorization'),
'cow' => &mt("$type Owner/Co-owner"),
'cop' => &mt("$type Personnel Includes"),
- 'cog' => &mt('Course Type')
+ 'cog' => &mt('Type')
);
- $typeselectform = ' |