--- loncom/interface/lonmainmenu.pm 2009/12/07 18:47:31 1.8.4.2 +++ loncom/interface/lonmainmenu.pm 2009/12/15 05:17:52 1.8.4.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # displays the main menu # -# $Id: lonmainmenu.pm,v 1.8.4.2 2009/12/07 18:47:31 raeburn Exp $ +# $Id: lonmainmenu.pm,v 1.8.4.5 2009/12/15 05:17:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -81,7 +81,11 @@ ENDSCRIPT $switcher_js = &gcitest_switcher_js($current,$numcourses); $script_tag= <<"ENDSCRIPT"; ENDSCRIPT } @@ -132,12 +136,12 @@ sub gcitest_switcher { } if ($default) { $output = '
'. - ''. ''; foreach my $item (@sorted_courses) { foreach my $course (@{$Sortby{$item}}) { my ($cdom,$cnum) = split('_',$course); - $output .= ''; + $output .= ''; } } $output .= '
'; @@ -145,6 +149,38 @@ sub gcitest_switcher { return $output; } +sub gcitest_switcher_js { + my ($current,$numcourses) = @_; + my $output = <<"ENDJS"; + +function courseswitcher(caller) { + var numcourses = $numcourses; + var current = '$current'; + var choice = document.pickrole.newrole.options[document.pickrole.newrole.selectedIndex].value; + if (choice == '') { + if (caller == 'icon') { + alert('No Concept Test selected'); + } + document.pickrole.selectrole.value = ''; + return; + } + if (choice == current) { + if ((caller != 'icon') && (numcourses > 1)) { + alert('You have selected the current course.\\nPlease select a different Concept Test course'); + } + document.pickrole.newrole.selectedIndex = 0; + document.pickrole.selectrole.value = ''; + return; + } + document.pickrole.selectrole.value = '1'; + document.pickrole.submit(); + return; +} + +ENDJS + return $output; +} + 1; __END__