--- loncom/interface/lonrequestcourse.pm 2010/02/25 05:01:25 1.41.2.5 +++ loncom/interface/lonrequestcourse.pm 2010/02/26 22:38:31 1.41.2.6 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.41.2.5 2010/02/25 05:01:25 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.41.2.6 2010/02/26 22:38:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -285,6 +285,9 @@ sub handler { $jscript = &mainmenu_javascript(); } else { $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored); + if ($state eq 'courseinfo') { + $jscript .= &cloning_javascript(); + } } } @@ -292,7 +295,7 @@ sub handler { $jscript .= "\n".&Apache::loncommon::userbrowser_javascript(); } - my $loaditems = &onload_action($action,$state); + my $loaditems = &onload_action($action,$state,$dom); my (%can_request,%request_domains); my $canreq = @@ -364,6 +367,22 @@ function setAction(courseForm) { END } +sub cloning_javascript { + return <<"END"; +function setCloneDisplay(courseForm) { + if (courseForm.cloning.length > 1) { + for (var i=0; i { cdescr => 'text', + cloning => 'radio', clonecrs => 'text', clonedom => 'selectbox', datemode => 'radio', @@ -518,8 +538,13 @@ sub form_elements { if ($dom eq 'gcitest') { %{$elements{'new'}{'courseinfo'}} = ( cdescr => 'text', - concepttest => 'radio', + concepttest => 'radio', ); + if (&show_cloneable()) { + $elements{'new'}{'courseinfo'}{'clonecrs'} = 'selectbox'; + $elements{'new'}{'courseinfo'}{'clonedom'} = 'hidden'; + $elements{'new'}{'courseinfo'}{'cloneroster'} = 'checkbox'; + } } my $numlib = keys(%servers); if ($numlib > 1) { @@ -625,7 +650,12 @@ sub onload_action { if ($state eq 'crstype') { $loaditems{'onload'} = 'javascript:setAction(document.mainmenu_action);javascript:setType(document.mainmenu_coursetype)'; } else { - $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)'; + $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs);'; + } + if ($state eq 'courseinfo') { + if (&show_cloneable()) { + $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);'; + } } if (($state eq 'process') && ($env{'form.concepttest'} eq 'editmyown')) { $loaditems{'onload'} = 'javascript:setInitialVisibility()'; @@ -755,8 +785,9 @@ END '
  • '.&mt('Creation of a course "container" and setting of access dates').'
  • '. '
  • '.&mt('Assembly of a valid test from Concept Inventory questions').'
  • '. '
  • '.&mt('Enrollment of students').'
  • '. - '

    '.&mt('When assembling a test you may either:'). - '
    '.&mt('(a) have a valid test built automatically by the WebCenter, or').'
    '.&mt('(b) select the questions to include by combining questions chosen from eleven bins with four mandatory questions.').'

    '.&mt('The most efficient way to enroll students is to upload a text file containing usernames and passwords.').'
    '.&mt("Students' full e-mail addresses should be used as their usernames to ensure uniqueness.").'

    '. + '

    '.&mt('When assembling a test you may:'). + '
    '.&mt('(a) have a valid test built automatically by the WebCenter, or').'
    '.&mt('(b) select the questions to include by combining questions chosen from eleven bins with four mandatory questions, or'). + '
    '.&mt('(c) copy one of your existing tests (including optional copying of the student roster)').'

    '.&mt('The most efficient way to enroll students is to upload a text file containing usernames and passwords.').'
    '.&mt("Students' full e-mail addresses should be used as their usernames to ensure uniqueness.").'

    '. '
    '."\n". ''."\n". ''."\n". @@ -2250,11 +2281,16 @@ sub print_review { $concepttest = 'Auto-generated'; } elsif ($env{'form.concepttest'} eq 'editmyown') { $concepttest = 'Manually selected'; + } elsif ($env{'form.concepttest'} eq 'cloning') { + $concepttest = 'Copied from existing test'; } - $inst_values .= ''.$concepttest.''; - } else { - $inst_headers .= ''.&mt('Clone From').''; - if (($env{'form.clonecrs'} =~ /^$match_name$/) && + $inst_values .= ''.$concepttest.(' 'x2).''; + } + if (&show_cloneable()) { + $inst_headers .= ''.&mt('Copy From').''; + if ((($env{'form.cloning'}) || + (($dom eq 'gcitest') && ($env{'form.concepttest'} eq 'cloning'))) && + ($env{'form.clonecrs'} =~ /^$match_name$/) && ($env{'form.clonedom'} =~ /^$match_domain$/)) { my $canclone = &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'}, $env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'}, @@ -2263,21 +2299,35 @@ sub print_review { my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'}, $env{'form.clonecrs'},('description','internal.coursecode')); if (keys(%courseenv) > 0) { - $inst_headers .= ''.$ctxt{'dsh'}.''; + if ($dom eq 'gcitest') { + $inst_headers .= ''.$ctxt{'ros'}.''; + } else { + $inst_headers .= ''.$ctxt{'dsh'}.''; + } $inst_values .= ''.$courseenv{'description'}.' '; my $cloneinst = $courseenv{'internal.coursecode'}; if ($cloneinst ne '') { $inst_values .= $cloneinst.' '.&mt('in').' '.$env{'form.clonedom'}; } else { - $inst_values .= &mt('from').' '.$env{'form.clonedom'}; + unless ($dom eq 'gcitest') { + $inst_values .= &mt('from').' '.$env{'form.clonedom'}; + } } - $inst_values .= ''; - if ($env{'form.datemode'} eq 'preserve') { - $inst_values .= $ctxt{'prd'}; - } elsif ($env{'form.datemode'} eq 'shift') { - $inst_values .= &mt('Shift dates by [_1] days',$env{'form.dateshift'}); + $inst_values .= (' 'x2).''; + if ($dom eq 'gcitest') { + if ($env{'form.cloneroster'}) { + $inst_values .= &mt('Yes'); + } else { + $inst_values .= &mt('No'); + } } else { - $inst_values .= $ctxt{'ncd'}; + if ($env{'form.datemode'} eq 'preserve') { + $inst_values .= $ctxt{'prd'}; + } elsif ($env{'form.datemode'} eq 'shift') { + $inst_values .= &mt('Shift dates by [_1] days',$env{'form.dateshift'}); + } else { + $inst_values .= $ctxt{'ncd'}; + } } $inst_values .= ''; } else { @@ -2437,6 +2487,24 @@ function validateForm() { } nextPage(document.$formname,'$next'); } + +function toggleCloning() { + var willclone; + if (document.$formname.cloning.length > 1) { + for (var i=0; i @@ -2447,20 +2515,26 @@ ENDJS $title = &mt('Concept Test Course Information'); $desctitle = &mt('Concept Test Title'); } - my $clonetitle = &mt('Clone content and settings from an existing course?'); + my $clonetitle = &mt('Copy content and settings from an existing course?'); if ($crstype eq 'community') { $title = &mt('Brief Community Description'); - $clonetitle = &mt('Clone content and settings from an existing community?'); + $clonetitle = &mt('Copy content and settings from an existing community?'); } - my $output .= $js_validate."\n".'
    '.&Apache::lonhtmlcommon::start_pick_box(). + my $output .= $js_validate."\n".&Apache::lonhtmlcommon::start_pick_box(). &Apache::lonhtmlcommon::row_headline(). '

    '.&Apache::loncommon::help_open_topic('Course_Request_Description').' '.$title.'

    '. &Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::row_title($desctitle). ''; + my $showclone; + if ($dom eq 'gcitest') { + $showclone = &show_cloneable(); + } else { + $showclone = 1; + } if ($dom eq 'gcitest') { $output .= &Apache::lonhtmlcommon::row_closure(1). - &concepttest_form(); + &concepttest_form($showclone); } my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($dom,'chome', @@ -2471,31 +2545,82 @@ ENDJS } $output .= $home_server_pick. &Apache::lonhtmlcommon::row_closure(); + if ($showclone && $dom ne 'gcitest') { + $output .= &Apache::lonhtmlcommon::row_headline(). + '

    '.&Apache::loncommon::help_open_topic('Course_Request_Clone').' '.$clonetitle. + ''. + '

    '. + &Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::row_headline(). + ''; + } if ($dom eq 'gcitest') { my ($instcode,@codetitles,%cat_titles,%cat_order,@code_order); my $invalidcrosslist = []; $output .= &print_enrollment_menu($formname,$instcode,$dom, \@codetitles,\%cat_titles,\%cat_order, \@code_order,$invalidcrosslist); - } else { - $output .= - &Apache::lonhtmlcommon::row_headline(). - '

    '.&Apache::loncommon::help_open_topic('Course_Request_Clone').' '.$clonetitle.'

    '. - &Apache::lonhtmlcommon::row_closure(1). - &clone_form($dom,$formname,$crstype); } - $output .= &Apache::lonhtmlcommon::end_pick_box().'
    '."\n"; + $output .= &Apache::lonhtmlcommon::end_pick_box()."\n"; return $output; } sub concepttest_form { - return &Apache::lonhtmlcommon::row_title(&mt('Questions included in Concept Test')). - ' '. - &mt('Automatically selected by WebCenter'). - '