--- loncom/interface/lonpickcourse.pm 2009/08/19 19:51:22 1.86 +++ loncom/interface/lonpickcourse.pm 2010/02/21 15:09:36 1.92 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a course # -# $Id: lonpickcourse.pm,v 1.86 2009/08/19 19:51:22 raeburn Exp $ +# $Id: lonpickcourse.pm,v 1.92 2010/02/21 15:09:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,7 +51,7 @@ sub handler { ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement', 'cdomelement','cnameelement','roleelement', 'multiple','type','setroles','fixeddom','cloner']); - my ($type,$title,$jscript,$multelement,$multiple,$roleelement, + my ($type,$title,$jscript,$multelement,$multiple,$roleelement,$typeelement, $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom); # Get course type - Course or Community. @@ -75,8 +75,11 @@ sub handler { $submitopener = &processpick(); $autosubmit = 'process_pick("'.$roledom.'")'; } + if ($env{'form.typeelement'} ne '') { + $typeelement = ''; + } - # if called when a DC is creating a course + # 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)$/); } @@ -102,7 +105,7 @@ sub handler { if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) && ($env{'form.pickedcourse'})) { - $loaditem{'onload'} .= 'setSections()'; + $loaditem{'onload'} .= 'setRoles();setSections();'; } my $js = &js_changer(); $r->print(&Apache::loncommon::start_page($title,$js, @@ -165,7 +168,7 @@ sub handler { $r->print(&build_filters($filterlist,$type,$roleelement,$multelement, $filter,$action,\$numtitles,undef,$cloneruname, - $clonerudom)); + $clonerudom,$typeelement)); } # ---------------------------------------------------------------- Get the data @@ -220,7 +223,12 @@ ENDONE $process_pick .= <<"ENDTWO"; if (pickedDomain == dom) { if (pickedCourse != '') { - var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse + var ccrole = "cc"; + var pickedType = "$env{'form.type'}"; + if (pickedType == "Community") { + ccrole = "co"; + } + var courseTarget = ccrole+"./"+pickedDomain+"/"+pickedCourse opener.document.title='Role selected. Please stand by.'; opener.status='Role selected. Please stand by.'; opener.document.rolechoice.newrole.value=courseTarget @@ -252,7 +260,12 @@ sub create_user_javascript { my $output; #javascript for reporting sections and groups then closing if ($env{'form.pickedcourse'}) { - my ($cdom,$cnum) = split/_/,$env{'form.pickedcourse'}; + my %coursedescription = + &Apache::lonnet::coursedescription($env{'form.pickedcourse'}, + {'one_time' => '1'}); + my $cdom = $coursedescription{'domain'}; + my $cnum = $coursedescription{'num'}; + my $crstype = $coursedescription{'type'}; my $sec_element = 'currsec'; my $grplist_element = 'groups'; my ($sections,$groups) = @@ -266,7 +279,10 @@ sub create_user_javascript { function setSections() { opener.document.$env{"form.form"}.$grplist_element.value='$groupslist'; window.opener.setSect('$seclist'); - self.close() + self.close(); +} +function setRoles() { + window.opener.setRole('$crstype'); } |; @@ -284,25 +300,38 @@ sub display_matched_courses { $r->print('