Diff for /loncom/interface/loncreatecourse.pm between versions 1.80 and 1.89

version 1.80, 2005/07/08 14:27:14 version 1.89, 2006/05/30 12:46:09
Line 38  use Apache::londocs; Line 38  use Apache::londocs;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::londropadd;  use Apache::londropadd;
 use lib '/home/httpd/lib/perl';  use lib '/home/httpd/lib/perl';
   use LONCAPA;
   
 # ================================================ Get course directory listing  # ================================================ Get course directory listing
   
Line 57  sub innercrsdirlist { Line 58  sub innercrsdirlist {
     my %crsdata=&Apache::lonnet::coursedescription($courseid);      my %crsdata=&Apache::lonnet::coursedescription($courseid);
     my @listing=&Apache::lonnet::dirlist      my @listing=&Apache::lonnet::dirlist
  ($which,$crsdata{'domain'},$crsdata{'num'},   ($which,$crsdata{'domain'},$crsdata{'num'},
  &Apache::loncommon::propath($crsdata{'domain'},$crsdata{'num'}));   &propath($crsdata{'domain'},$crsdata{'num'}));
     foreach (@listing) {      foreach (@listing) {
  unless ($_=~/^\./) {   unless ($_=~/^\./) {
     my @unpackline = split (/\&/,$_);      my @unpackline = split (/\&/,$_);
Line 159  sub copyresourcedb { Line 160  sub copyresourcedb {
     my %newdata=();      my %newdata=();
     undef %newdata;      undef %newdata;
     my $startdate=$data{$origcrsid.'.0.opendate'};      my $startdate=$data{$origcrsid.'.0.opendate'};
       if (!$startdate) {
    # now global start date for assements try the enrollment start
    my %start=&Apache::lonnet::get('environment',
      ['default_enrollment_start_date'],
      $origcrsdata{'domain'},$origcrsdata{'num'});
   
    $startdate = $start{'default_enrollment_start_date'};
       }
     my $today=time;      my $today=time;
     my $delta=0;      my $delta=0;
     if ($startdate) {      if ($startdate) {
Line 193  sub copyresourcedb { Line 202  sub copyresourcedb {
  $thiskey=~s/^$origcrsid/$newcrsid/;   $thiskey=~s/^$origcrsid/$newcrsid/;
  $newdata{$thiskey}=$data{$_};   $newdata{$thiskey}=$data{$_};
  if ($data{$_.'.type'}=~/^date_(start|end)$/) {   if ($data{$_.'.type'}=~/^date_(start|end)$/) {
     $newdata{$thiskey}=$newdata{$thiskey}+$delta;      if ($delta > 0) {
    $newdata{$thiskey}=$newdata{$thiskey}+$delta;
       } else {
    # no delta, it's unlikely we want the old dates and times
    delete($newdata{$thiskey});
    delete($newdata{$thiskey.'.type'});
       }
  }   }
     }      }
     return &Apache::lonnet::put      return &Apache::lonnet::put
Line 214  sub copyuserfiles { Line 229  sub copyuserfiles {
   
 sub copydbfiles {  sub copydbfiles {
     my ($origcrsid,$newcrsid)=@_;      my ($origcrsid,$newcrsid)=@_;
   
       my ($origcrs_discussion) = ($origcrsid=~m|^/(.*)|);
       $origcrs_discussion=~s|/|_|g;
     foreach (&crsdirlist($origcrsid)) {      foreach (&crsdirlist($origcrsid)) {
  if ($_=~/\.db$/) {   if ($_=~/\.db$/) {
     unless       unless 
              ($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata)/) {               ($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations|gradingqueue|reviewqueue|CODEs)/) {
  &copydb($origcrsid,$newcrsid,$_);   &copydb($origcrsid,$newcrsid,$_);
  my $histfile=$_;   my $histfile=$_;
  $histfile=~s/\.db$/\.hist/;   $histfile=~s/\.db$/\.hist/;
Line 252  sub print_course_creation_page { Line 270  sub print_course_creation_page {
     }      }
     $course_home .= "\n</select>\n";      $course_home .= "\n</select>\n";
     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');      my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
     my $bodytag=&Apache::loncommon::bodytag('Create a New Course');  
     my $helplink=&Apache::loncommon::help_open_topic('Create_Course',&mt('Help on Creating Courses'));      my $helplink=&Apache::loncommon::help_open_topic('Create_Course',&mt('Help on Creating Courses'));
     my $cloneform=&Apache::loncommon::select_dom_form      my $cloneform=&Apache::loncommon::select_dom_form
  ($env{'request.role.domain'},'clonedomain').   ($env{'request.role.domain'},'clonedomain').
Line 334  sub print_course_creation_page { Line 351  sub print_course_creation_page {
     'rshm' => 'Resource Space Home',      'rshm' => 'Resource Space Home',
                     'opco' => "Open Course"                      'opco' => "Open Course"
        );         );
     my $html=&Apache::lonxml::xmlbegin();      my $js = <<END;
     $r->print(<<ENDDOCUMENT);  <script type="text/javascript">
 $html  
 <head>  
 <script language="JavaScript" type="text/javascript">  
 var editbrowser = null;  var editbrowser = null;
 function openbrowser(formname,elementname) {  function openbrowser(formname,elementname) {
     var url = '/res/?';      var url = '/res/?';
Line 359  function openbrowser(formname,elementnam Line 373  function openbrowser(formname,elementnam
 $javascript_validations  $javascript_validations
 </script>  </script>
 $coursebrowserjs  $coursebrowserjs
 <title>The LearningOnline Network with CAPA</title>  END
 </head>  
 $bodytag      my $start_page = 
           &Apache::loncommon::start_page('Create a New Course',$js);
       my $end_page = 
           &Apache::loncommon::end_page();
   
       $r->print(<<ENDDOCUMENT);
   $start_page
 $helplink  $helplink
 <form action="/adm/createcourse" method="post" name="ccrs">  <form action="/adm/createcourse" method="post" name="ccrs">
 <h2>$lt{'cinf'}</h2>  <h2>$lt{'cinf'}</h2>
Line 565  $lt{'ndcl'}<br/> Line 585  $lt{'ndcl'}<br/>
 <input type="button" onClick="verify_message(this.form)" value="$lt{'opco'}" />  <input type="button" onClick="verify_message(this.form)" value="$lt{'opco'}" />
 </p>  </p>
 </form>  </form>
 </body>  $end_page
 </html>  
 ENDDOCUMENT  ENDDOCUMENT
 }  }
   
Line 604  sub create_course { Line 623  sub create_course {
     }      }
   
     my $logmsg;      my $logmsg;
     my $html=&Apache::lonxml::xmlbegin();      my $start_page=&Apache::loncommon::start_page('Create a New Course');
     my $bodytag=&Apache::loncommon::bodytag('Create a New Course');      $r->print($start_page);
     $r->print(<<ENDENHEAD);  
 $html  
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 </head>  
 $bodytag  
 ENDENHEAD  
   
     my $args = {      my $args = {
                ccuname => $ccuname,                 ccuname => $ccuname,
Line 666  ENDENHEAD Line 678  ENDENHEAD
             <input type="hidden" name="ccdomain" value="'.$ccdomain.'" />              <input type="hidden" name="ccdomain" value="'.$ccdomain.'" />
             <input name="userrole" type="submit" value="'.              <input name="userrole" type="submit" value="'.
   &mt('Create User').'" />    &mt('Create User').'" />
  </form></body></html>');   </form>'.&Apache::loncommon::end_page());
  return;   return;
     }      }
     # Check the proposed home server for the course      # Check the proposed home server for the course
Line 674  ENDENHEAD Line 686  ENDENHEAD
         ($env{'request.role.domain'});          ($env{'request.role.domain'});
     if (! exists($host_servers{$env{'form.course_home'}})) {      if (! exists($host_servers{$env{'form.course_home'}})) {
         $r->print(&mt('Invalid home server for course').': '.          $r->print(&mt('Invalid home server for course').': '.
                   $env{'form.course_home'}.'</body></html>');                    $env{'form.course_home'}.&Apache::loncommon::end_page());
         return;          return;
     }      }
     my ($courseid,$crsudom,$crsunum);      my ($courseid,$crsudom,$crsunum);
Line 694  ENDENHEAD Line 706  ENDENHEAD
     }      }
 # Flush the course logs so reverse user roles immediately updated  # Flush the course logs so reverse user roles immediately updated
     &Apache::lonnet::flushcourselogs();      &Apache::lonnet::flushcourselogs();
     $r->print('<p>'.&mt('Roles will be active at next login').'.</p></body></html>');      $r->print('<p>'.&mt('Roles will be active at next login').'.</p>'.
         '<p><a href="/adm/createcourse">'.
         &mt('Create Another Course').'</a></p>'.
         &Apache::loncommon::end_page());
 }  }
   
 sub construct_course {  sub construct_course {
Line 784  sub construct_course { Line 799  sub construct_course {
             foreach my $item (@sections) {              foreach my $item (@sections) {
                 my ($sec,$gp) = split/:/,$item;                  my ($sec,$gp) = split/:/,$item;
                 my $class = $args->{'crscode'}.$sec;                  my $class = $args->{'crscode'}.$sec;
                 my $addcheck = &Apache::lonnet::auto_new_course($crsunum,$crsudom,$class,$cenv{'internal.courseowner'});                  my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'});
                 $cenv{'internal.sectionnums'} .= $item.',';                  $cenv{'internal.sectionnums'} .= $item.',';
                 unless ($addcheck eq 'ok') {                  unless ($addcheck eq 'ok') {
                     push @badclasses, $class;                      push @badclasses, $class;

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


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