--- loncom/interface/lonpickcourse.pm 2014/03/17 02:45:25 1.112
+++ loncom/interface/lonpickcourse.pm 2016/11/02 22:41:18 1.122
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Pick a course
#
-# $Id: lonpickcourse.pm,v 1.112 2014/03/17 02:45:25 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.122 2016/11/02 22:41:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -50,11 +50,12 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi
($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement',
'cdomelement','cnameelement','roleelement',
- 'multiple','type','setroles','fixeddom','cloner']);
+ 'multiple','type','setroles','fixeddom','cloner',
+ 'crscode','crsdom']);
my ($type,$title,$jscript,$multelement,$multiple,$roleelement,$typeelement,
- $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom);
+ $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom,$crscode,$crsdom);
- # Get course type - Course or Community.
+ # Get course type - Course, Community or Placement.
$type = $env{'form.type'};
if (!defined($env{'form.type'})) {
$type = 'Course';
@@ -68,12 +69,12 @@ sub handler {
$title = 'Selecting '.$type.'(s)';
}
- # if called when a DC is selecting a course
- my $roledom = $env{'form.roleelement'};
+ # if called when a DC or DH is selecting a course
+ my ($roledom,$rolename) = split(/:/,$env{'form.roleelement'});
if ($roledom) {
- $roleelement = '';
+ $roleelement = '';
$submitopener = &processpick();
- $autosubmit = 'process_pick("'.$roledom.'")';
+ $autosubmit = 'process_pick("'.$roledom.'","'.$rolename.'")';
}
if ($env{'form.typeelement'} ne '') {
$typeelement = '';
@@ -82,12 +83,16 @@ sub handler {
# if called when a DC is creating a course for another user.
if ($env{'form.form'} eq 'ccrs') {
($cloneruname,$clonerudom) = ($env{'form.cloner'} =~ /^($match_username):($match_domain)$/);
+ $crscode = $env{'form.crscode'};
+ $crsdom = $env{'request.role.domain'};
}
# if called when requesting a course
if ($env{'form.form'} eq 'requestcrs') {
$cloneruname = $env{'user.name'};
$clonerudom = $env{'user.domain'};
+ $crscode = $env{'form.crscode'};
+ $crsdom = $env{'form.crsdom'};
}
my $onlyown = 0;
@@ -105,7 +110,20 @@ sub handler {
if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) &&
($env{'form.pickedcourse'})) {
- $loaditem{'onload'} .= 'setDefaultCredits();setRoles();setSections();';
+ if ($type ne 'Community') {
+ my %coursedescription =
+ &Apache::lonnet::coursedescription($env{'form.pickedcourse'},
+ {'one_time' => '1'});
+ my $cdom = $coursedescription{'domain'};
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ if (($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'})) {
+ $loaditem{'onload'} .= 'setDefaultCredits();';
+ }
+ }
+ $loaditem{'onload'} .= 'setRoles();setSections();';
+ }
+ if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) && (!$onlyown)) {
+ $loaditem{'onload'} .= 'hideSearching(); ';
}
my $js = &Apache::loncommon::js_changer();
$r->print(&Apache::loncommon::start_page($title,$js,
@@ -207,6 +225,12 @@ sub handler {
if ($coord_cloneable) {
$clonetext .= '';
}
+ if ($crscode ne '') {
+ $clonetext .= '';
+ }
+ if ($crsdom ne '') {
+ $clonetext .= '';
+ }
}
$r->print(&Apache::loncommon::build_filters($filterlist,$type,$roleelement,$multelement,
$filter,$action,\$numtitles,undef,$cloneruname,
@@ -234,7 +258,8 @@ sub handler {
my $srchdom = $filter->{'domainfilter'};
%courses = &Apache::loncommon::search_courses($srchdom,$type,$filter,$numtitles,
$cloneruname,$clonerudom,$domcloner,
- \@codetitles,$env{'form.cc_clone'});
+ \@codetitles,$env{'form.cc_clone'},
+ $crsdom,$crscode);
} else {
$r->print('
');
my %coursehash = &Apache::loncommon::findallcourses();
@@ -249,7 +274,7 @@ sub handler {
''.$filter->{'persondomfilter'}.'').'');
} else {
&display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,
- $clonerudom,%courses);
+ $clonerudom,$crsdom,$crscode,%courses);
}
}
$r->print(&Apache::loncommon::end_page());
@@ -263,7 +288,7 @@ sub processpick {
}
my $process_pick = <<"ENDONE";