Diff for /loncom/interface/lonrequestcourse.pm between versions 1.85 and 1.89

version 1.85, 2014/06/16 01:42:22 version 1.89, 2015/06/09 21:22:57
Line 768  END Line 768  END
 ";  ";
         }          }
     }      }
     my %lt = &Apache::lonlocal::texthash(      my %js_lt = &Apache::lonlocal::texthash(
         official => 'You are not permitted to request creation of an official course in this domain.',          official => 'You are not permitted to request creation of an official course in this domain.',
         unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',          unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',
         community => 'You are not permitted to request creation of a community in this domain.',          community => 'You are not permitted to request creation of a community in this domain.',
Line 776  END Line 776  END
         all => 'You must choose a specific course type when making a new course request.',          all => 'You must choose a specific course type when making a new course request.',
         allt => '"All types" is not allowed.',          allt => '"All types" is not allowed.',
     );       ); 
       &js_escape(\%js_lt);
     $js .= <<END;      $js .= <<END;
     if (crschoice == 'official') {      if (crschoice == 'official') {
         if (official != 1) {          if (official != 1) {
             alert("$lt{'official'}");              alert("$js_lt{'official'}");
             return false;              return false;
         }          }
     } else {      } else {
         if (crschoice == 'unofficial') {          if (crschoice == 'unofficial') {
             if (unofficial != 1) {              if (unofficial != 1) {
                 alert("$lt{'unofficial'}");                  alert("$js_lt{'unofficial'}");
                 return false;                  return false;
             }              }
         } else {          } else {
             if (crschoice == 'community') {              if (crschoice == 'community') {
                 if (community != 1) {                  if (community != 1) {
                     alert("$lt{'community'}");                      alert("$js_lt{'community'}");
                     return false;                      return false;
                 }                  }
             } else {              } else {
                 if (crschoice == 'textbook') {                  if (crschoice == 'textbook') {
                     if (textbook != 1) {                      if (textbook != 1) {
                         alert("$lt{'community'}");                          alert("$js_lt{'textbook'}");
                         return false;                          return false;
                     }                      }
                 } else {                  } else {
                     if (actionchoice == 'new') {                      if (actionchoice == 'new') {
                         alert('$lt{'all'}'+'\\n'+'$lt{'allt'}');                          alert('$js_lt{'all'}'+'\\n'+'$js_lt{'allt'}');
                         return false;                          return false;
                     }                      }
                 }                  }
Line 939  END Line 940  END
     if ($action eq 'new') {      if ($action eq 'new') {
         my $jsextra;          my $jsextra;
         if (($state eq 'courseinfo') || ($state eq 'codepick')) {          if (($state eq 'courseinfo') || ($state eq 'codepick')) {
             $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);              $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom,'','','','','',
                                                                            $newinstcode);
         } elsif ($state eq 'enrollment') {          } elsif ($state eq 'enrollment') {
             if (($env{'form.crstype'} eq 'official') &&               if (($env{'form.crstype'} eq 'official') && 
                 (&Apache::lonnet::auto_run('',$dom))) {                  (&Apache::lonnet::auto_run('',$dom))) {
Line 1174  sub enrollment_lcsec_js { Line 1176  sub enrollment_lcsec_js {
     my %alerts = &section_check_alerts();      my %alerts = &section_check_alerts();
     my $secname = $alerts{'badsec'};      my $secname = $alerts{'badsec'};
     my $secnone = $alerts{'reserved'};      my $secnone = $alerts{'reserved'};
       &js_escape(\$secname);
       &js_escape(\$secnone);
     my $output = '      my $output = '
 function validateEnrollSections(formname,nextstate) {  function validateEnrollSections(formname,nextstate) {
     var badsectotal = 0;      var badsectotal = 0;
Line 1231  function validateEnrollSections(formname Line 1235  function validateEnrollSections(formname
   
 sub personnel_lcsec_js {  sub personnel_lcsec_js {
     my %alerts = &section_check_alerts();      my %alerts = &section_check_alerts();
     my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'};      my $secname = $alerts{'badsec'}."\n".$alerts{'separate'};
     my $secnone = $alerts{'reserved'};      my $secnone = $alerts{'reserved'};
       &js_escape(\$secname);
       &js_escape(\$secnone);
     my $output = '      my $output = '
 function validatePersonnelSections(formname,nextstate) {  function validatePersonnelSections(formname,nextstate) {
     var badsectotal = 0;      var badsectotal = 0;
Line 2415  ENDJS Line 2421  ENDJS
 }  }
   
 sub viewcancel_javascript {  sub viewcancel_javascript {
     my $alert = &mt('Are you sure you want to cancel this request?').'\\n'.      my $alert = &mt('Are you sure you want to cancel this request?')."\n".
                 &mt('Your request will be removed.');                  &mt('Your request will be removed.');
       &js_escape(\$alert);
     return << "ENDJS";      return << "ENDJS";
 function nextPage(formname,nextstate) {  function nextPage(formname,nextstate) {
     if (confirm('$alert')) {      if (confirm('$alert')) {
Line 2788  sub print_review { Line 2795  sub print_review {
   
     my $enrollrow_title = &mt('Default Access Dates').'<br />'.      my $enrollrow_title = &mt('Default Access Dates').'<br />'.
                           '('.&Apache::lonnet::plaintext('st',$category).')';                            '('.&Apache::lonnet::plaintext('st',$category).')';
       my $instcode;
     if ($env{'form.crstype'} eq 'official') {      if ($env{'form.crstype'} eq 'official') {
         if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) {          if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) {
             foreach my $title (@{$codetitles}) {              foreach my $title (@{$codetitles}) {
Line 2803  sub print_review { Line 2811  sub print_review {
                 }                  }
             }              }
         }          }
           if (ref($code_order) eq 'ARRAY') {
               foreach my $item (@{$code_order}) {
                   $instcode .= $env{'form.instcode_'.$item};
               }
           }
         $inst_headers .= '<th>'.&mt('Credits').'</th>';          $inst_headers .= '<th>'.&mt('Credits').'</th>';
         if ($instcredits) {          if ($instcredits) {
             $inst_values .= '<td>'.$instcredits.'</td>';              $inst_values .= '<td>'.$instcredits.'</td>';
Line 2890  sub print_review { Line 2903  sub print_review {
         ($env{'form.clonedom'} =~ /^$match_domain$/)) {          ($env{'form.clonedom'} =~ /^$match_domain$/)) {
         my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname,          my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname,
                            $udom,$env{'form.clonecrs'},$env{'form.clonedom'},                             $udom,$env{'form.clonecrs'},$env{'form.clonedom'},
                            $env{'form.crstype'});                             $env{'form.crstype'},$dom,$instcode);
         if ($canclone) {          if ($canclone) {
             my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},              my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},
                               $env{'form.clonecrs'},('description','internal.coursecode'));                                $env{'form.clonecrs'},('description','internal.coursecode'));
Line 3052  sub dates_from_form { Line 3065  sub dates_from_form {
   
 sub courseinfo_form {  sub courseinfo_form {
     my ($dom,$formname,$crstype,$next,$description) = @_;      my ($dom,$formname,$crstype,$next,$description) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %js_lt = &Apache::lonlocal::texthash(
                 official => 'You must provide a (brief) course description.',                  official => 'You must provide a (brief) course description.',
                 community => 'You must provide a (brief) community description.'                  community => 'You must provide a (brief) community description.'
              );               );
     $lt{'unofficial'} = $lt{'official'};      &js_escape(\%js_lt);
     $lt{'textbook'} = $lt{'official'};      $js_lt{'unofficial'} = $js_lt{'official'};
       $js_lt{'textbook'} = $js_lt{'official'};
     my $js_validate = <<"ENDJS";      my $js_validate = <<"ENDJS";
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA['  // <![CDATA['
   
 function validateForm() {  function validateForm() {
     if ((document.$formname.cdescr.value == "")  || (document.$formname.cdescr.value == "undefined")) {      if ((document.$formname.cdescr.value == "")  || (document.$formname.cdescr.value == "undefined")) {
         alert('$lt{$crstype}');          alert('$js_lt{$crstype}');
         return;          return;
     }      }
     nextPage(document.$formname,'$next');      nextPage(document.$formname,'$next');
Line 3588  sub print_request_outcome { Line 3602  sub print_request_outcome {
             my $canclone =                my $canclone =  
                 &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},                  &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
                         $env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'},                          $env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'},
                         $crstype);                          $crstype,$dom,$instcode);
             if ($canclone) {              if ($canclone) {
                 $clonecrs = $env{'form.clonecrs'};                  $clonecrs = $env{'form.clonecrs'};
                 $clonedom = $env{'form.clonedom'};                  $clonedom = $env{'form.clonedom'};
Line 3670  sub process_request { Line 3684  sub process_request {
                                             $dom,$crstype,$limit,\$message);                                              $dom,$crstype,$limit,\$message);
         } elsif ($val eq 'validate') {          } elsif ($val eq 'validate') {
             my ($inststatuslist,$validationchk,$validation,%custominfo);              my ($inststatuslist,$validationchk,$validation,%custominfo);
               if (ref($details) eq 'HASH') {
                   if ($details->{'clonecrs'}) {
                       $custominfo{'_LC_clonefrom'} = $details->{'clonedom'}.'_'.$details->{'clonecrs'};
                   }
               }
             if (@inststatuses > 0) {              if (@inststatuses > 0) {
                 $inststatuslist = join(',',@inststatuses);                  $inststatuslist = join(',',@inststatuses);
             }              }
Line 3762  sub process_request { Line 3781  sub process_request {
                       &mt('Your request is being processed; this page will update when processing is complete.').                        &mt('Your request is being processed; this page will update when processing is complete.').
                       '</div>');                        '</div>');
             $r->rflush();              $r->rflush();
               if (ref($details) eq 'HASH') {
                   if ($details->{'clonecrs'}) {
                       $customitems{'_LC_clonefrom'} = $details->{'clonedom'}.'_'.$details->{'clonecrs'};
                   }
               }
             my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,              my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
                                           'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,                                            'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
                                           \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,                                            \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,
Line 4452  sub print_textbook_form { Line 4476  sub print_textbook_form {
                     my ($clonedom,$clonecrs) = split(/_/,$item);                      my ($clonedom,$clonecrs) = split(/_/,$item);
                     if (ref($prefab{$type}{$item}) eq 'HASH') {                      if (ref($prefab{$type}{$item}) eq 'HASH') {
                         if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},                          if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
                                           $env{'user.domain'},$clonecrs,$clonedom,$crstype)) {                                            $env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom)) {
   
                             my $num = $prefab{$type}{$item}{'order'};                              my $num = $prefab{$type}{$item}{'order'};
                             $ordered{$type}{$num} = $item;                              $ordered{$type}{$num} = $item;
Line 4794  sub process_textbook_request { Line 4818  sub process_textbook_request {
         if (&Apache::lonnet::homeserver($clonecrs,$clonedom) ne 'no_host') {          if (&Apache::lonnet::homeserver($clonecrs,$clonedom) ne 'no_host') {
             my $canclone =              my $canclone =
                 &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},                  &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
                             $env{'user.domain'},$clonecrs,$clonedom,$crstype);                              $env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom);
             unless ($canclone) {              unless ($canclone) {
                 undef($clonecrs);                  undef($clonecrs);
                 undef($clonedom);                  undef($clonedom);
Line 4864  sub textbook_request_javascript { Line 4888  sub textbook_request_javascript {
     my ($numprefab,$numcurrent) = @_;      my ($numprefab,$numcurrent) = @_;
     return unless (ref($numprefab) eq 'HASH');      return unless (ref($numprefab) eq 'HASH');
     return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent);      return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent);
     my %lt = &Apache::lonlocal::texthash(      my %js_lt = &Apache::lonlocal::texthash(
                  choose   => 'Please select a content option.',                   choose   => 'Please select a content option.',
                  textbook => 'Please select a textbook, or choose a different option.',                   textbook => 'Please select a textbook, or choose a different option.',
                  template => 'Please select a template, or choose a different option.',                           template => 'Please select a template, or choose a different option.',        
                  existing => 'Please select one of your existing courses to copy, or choose a different option.',                   existing => 'Please select one of your existing courses to copy, or choose a different option.',
                  title    => 'Please enter a course title.',                   title    => 'Please enter a course title.',
              );               );
       &js_escape(\%js_lt);
     return <<"ENDSCRIPT";      return <<"ENDSCRIPT";
 function cloneChoice() {  function cloneChoice() {
     if (document.requestcourse.cloning) {      if (document.requestcourse.cloning) {
Line 4933  function uncheckAllRadio() { Line 4958  function uncheckAllRadio() {
     if (numbook > 0) {      if (numbook > 0) {
         uncheckRadio('textbook');           uncheckRadio('textbook'); 
     }      }
     if (nutemplate > 0) {      if (numtemplate > 0) {
         uncheckRadio('template');          uncheckRadio('template');
     }m      }
     if (numcurrent > 0) {      if (numcurrent > 0) {
         uncheckRadio('existing');          uncheckRadio('existing');
     }      }
Line 4948  function validTextbookReq() { Line 4973  function validTextbookReq() {
         var radioLength = document.requestcourse.cloning.length;          var radioLength = document.requestcourse.cloning.length;
         if (radioLength == undefined) {          if (radioLength == undefined) {
             if (document.requestcourse.cloning.checked == false) {              if (document.requestcourse.cloning.checked == false) {
                 alert("$lt{'choose'}");                  alert("$js_lt{'choose'}");
                 return false;                  return false;
             } else {              } else {
                 cloneChoice = document.requestcourse.cloning.value;                  cloneChoice = document.requestcourse.cloning.value;
Line 4961  function validTextbookReq() { Line 4986  function validTextbookReq() {
                 }                  }
             }              }
             if (cloneChoice == 0) {              if (cloneChoice == 0) {
                 alert("$lt{'choose'}");                  alert("$js_lt{'choose'}");
                 return false;                  return false;
             }              }
         }          }
Line 4993  function validTextbookReq() { Line 5018  function validTextbookReq() {
            }             }
            if (chosen == 0) {             if (chosen == 0) {
                if (cloneChoice == 'textbook') {                 if (cloneChoice == 'textbook') {
                    alert("$lt{'textbook'}");                     alert("$js_lt{'textbook'}");
                } else {                 } else {
                    if (cloneChoice == 'template') {                     if (cloneChoice == 'template') {
                        alert("$lt{'template'}");                         alert("$js_lt{'template'}");
                    } else {                     } else {
                        alert("$lt{'existing'}");                         alert("$js_lt{'existing'}");
                    }                     }
                }                 }
                return false;                 return false;
Line 5006  function validTextbookReq() { Line 5031  function validTextbookReq() {
         }          }
     }      }
     if (document.requestcourse.cdescr.value == '') {      if (document.requestcourse.cdescr.value == '') {
         alert("$lt{'title'}");          alert("$js_lt{'title'}");
         return false;          return false;
     }      }
     return true;      return true;

Removed from v.1.85  
changed lines
  Added in v.1.89


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>