--- loncom/interface/lonmainmenu.pm 2009/12/07 18:47:31 1.8.4.2 +++ loncom/interface/lonmainmenu.pm 2009/12/07 22:33:26 1.8.4.3 @@ -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.3 2009/12/07 22:33:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -145,6 +145,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__