--- loncom/interface/lonpickcourse.pm 2007/06/01 18:07:47 1.63.2.1 +++ loncom/interface/lonpickcourse.pm 2008/01/02 11:25:38 1.67.2.2 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a course # -# $Id: lonpickcourse.pm,v 1.63.2.1 2007/06/01 18:07:47 albertel Exp $ +# $Id: lonpickcourse.pm,v 1.67.2.2 2008/01/02 11:25:38 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,7 +72,7 @@ sub handler { my $roledom = $env{'form.roleelement'}; if ($roledom) { $roleelement = ''; - $submitopener = &Apache::lonroles::processpick(); + $submitopener = &processpick(); $autosubmit = 'process_pick("'.$roledom.'")'; } @@ -83,7 +83,8 @@ sub handler { } my %loaditem; - if ($env{'form.form'} eq 'cu' && $env{'form.pickedcourse'}) { + 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, @@ -92,7 +93,8 @@ sub handler { if ($env{'form.form'} eq 'portform') { $lastaction = 'document.courselist.submit()'; - } elsif ($env{'form.form'} eq 'cu') { + } elsif ($env{'form.form'} eq 'cu' || ($env{'form.form'} eq 'studentform' && + !$multiple)) { $lastaction = 'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n". 'document.courselist.submit();'; @@ -101,8 +103,8 @@ sub handler { } # if called to assign a role in a course to a user via CUSR - if ($env{'form.form'} eq 'cu') { - $r->print(&create_user_javascript($type)); + if ($env{'form.form'} eq 'cu' || $env{'form.form'} eq 'studentform') { + $r->print(&create_user_javascript($type)); } # print javascript functions for choosing a course @@ -137,6 +139,49 @@ sub handler { return OK; } +sub processpick { + my $openerform = 'rolechoice'; + if ($env{'form.form'} eq 'studentform') { + $openerform = $env{'form.form'}; + } + my $process_pick = <<"ENDONE"; + +"; + return $process_pick; +} + sub create_user_javascript { my ($type) = @_; my $output; @@ -170,12 +215,35 @@ sub display_matched_courses { if ($env{'form.form'} eq 'portform') { $action = '/adm/portfolio'; } + my $numcourses = keys(%courses); $r->print('