Diff for /loncom/interface/lonmodifycourse.pm between versions 1.16 and 1.25

version 1.16, 2005/04/07 06:56:23 version 1.25, 2006/05/30 12:46:09
Line 1 Line 1
   # The LearningOnline Network with CAPA
   # automated enrollment course setup handler
   #
   # $Id$
   #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
Line 30  use Apache::lonlocal; Line 35  use Apache::lonlocal;
 use Apache::londropadd;  use Apache::londropadd;
 use LONCAPA::Enrollment;  use LONCAPA::Enrollment;
 use lib '/home/httpd/lib/perl';  use lib '/home/httpd/lib/perl';
   use LONCAPA;
   
 sub print_course_selection_page {  sub print_course_selection_page {
     my ($r,$tasklongref) = @_;      my ($r,$tasklongref) = @_;
Line 45  sub print_course_selection_page { Line 51  sub print_course_selection_page {
     );      );
                                                                                                                                                                               
 # Determine the courses  # Determine the courses
     my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.');      my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.');
     &print_header($r,$tasklongref);      &print_header($r,$tasklongref);
     $r->print(<<ENDBLOCK);      $r->print(<<ENDBLOCK);
 <form action="/adm/modifycourse" method="post" name="cmod">  <form action="/adm/modifycourse" method="post" name="cmod">
Line 96  ENDBLOCK Line 102  ENDBLOCK
             if ($item =~ m/^($dom)_(\w+)$/) {              if ($item =~ m/^($dom)_(\w+)$/) {
                 $crs = $2;                  $crs = $2;
                 if ($courseIDs{$item} =~ /^([^:]*):([^:]*):([^:]*)/) {                  if ($courseIDs{$item} =~ /^([^:]*):([^:]*):([^:]*)/) {
                     $description = &Apache::lonnet::unescape($1);                      $description = &unescape($1);
                     $owner = &Apache::lonnet::unescape($3);                      $owner = &unescape($3);
                 } elsif ($courseIDs{$item} =~ /^([^:]*):([^:]*)$/) {                  } elsif ($courseIDs{$item} =~ /^([^:]*):([^:]*)$/) {
                     $description = &Apache::lonnet::unescape($1);                      $description = &unescape($1);
                 } else {                     } else {   
                     $description = &Apache::lonnet::unescape($courseIDs{$item});                      $description = &unescape($courseIDs{$item});
                 }                  }
 # Get course owner  # Get course owner
                 if ($owner eq '') {                  if ($owner eq '') {
Line 142  sub print_course_modification_page { Line 148  sub print_course_modification_page {
     } else {      } else {
         $ok_course = &check_course($dom,$course);          $ok_course = &check_course($dom,$course);
     }      }
     print STDERR "Response was $ok_course for $dom,$course\n";  
   
     unless ($ok_course eq 'ok') {      unless ($ok_course eq 'ok') {
         &print_header($r,$tasklongref,'',\$javascript_validations);          &print_header($r,$tasklongref,'',\$javascript_validations);
Line 191  all settings except course code, course Line 196  all settings except course code, course
     $enrollvar{'autharg'} = '';      $enrollvar{'autharg'} = '';
     $enrollvar{'authtype'} = '';      $enrollvar{'authtype'} = '';
     foreach my $item (keys %settings) {      foreach my $item (keys %settings) {
         if ($item =~ m/^internal\.(.+)$/) {   if ($item =~ m/^internal\.(.+)$/) {
             if ( ($1 eq "autoadds") || ($1 eq "autodrops") ) {      my $type = $1;
   
               if ( ($type eq "autoadds") || ($type eq "autodrops") ) {
         if ($settings{$item} == 1) {          if ($settings{$item} == 1) {
             $enrollvar{$1} = "ON";              $enrollvar{$type} = "ON";
         } else {          } else {
             $enrollvar{$1} = "OFF";              $enrollvar{$type} = "OFF";
         }          }
             } elsif ( ($1 eq "autostart") || ($1 eq "autoend") ) {              } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
         if ( ($1 eq "autoend") && ($settings{$item} == 0) ) {          if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
             $enrollvar{$1} = $lt{'noen'};              $enrollvar{$type} = $lt{'noen'};
         } else {          } else {
             $enrollvar{$1} = localtime($settings{$item});              $enrollvar{$type} = localtime($settings{$item});
         }          }
             } elsif ($1 eq "courseowner" || $1 eq "authtype" || $1 eq "autharg" || $1 eq "sectionnums" || $1 eq "coursecode" || $1 eq "crosslistings") {      } elsif ($type eq "sectionums") {
         $enrollvar{$1} = $settings{$item};   $enrollvar{$type} = $settings{$item};
    $enrollvar{$type} =~ s/,/, /g;
               } elsif ($type eq "courseowner"   || $type eq "authtype" 
        || $type eq "autharg"    || $type eq "coursecode"
        || $type eq "crosslistings") {
           $enrollvar{$type} = $settings{$item};
             }              }
         } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {          } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
             if ( ($1 eq 'end') && ($settings{$item} == 0) ) {      my $type = $1;
               if ( ($type eq 'end') && ($settings{$item} == 0) ) {
                 $enrollvar{$item} = $lt{'noen'};                  $enrollvar{$item} = $lt{'noen'};
             } elsif ( ($1 eq 'start') && ($settings{$item} eq '') ) {              } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
                 $enrollvar{$item} = 'When enrolled';                  $enrollvar{$item} = 'When enrolled';
             } else {              } else {
                 $enrollvar{$item} = localtime($settings{$item});                  $enrollvar{$item} = localtime($settings{$item});
Line 227  all settings except course code, course Line 240  all settings except course code, course
         my @roleinfo = split/:/,$_;          my @roleinfo = split/:/,$_;
         if ( ($roleinfo[0] eq 'cc')  && ($roleinfo[2] eq $dom) )  {          if ( ($roleinfo[0] eq 'cc')  && ($roleinfo[2] eq $dom) )  {
             unless (grep/^$roleinfo[1]$/,@local_ccs) {              unless (grep/^$roleinfo[1]$/,@local_ccs) {
                 $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$course,'cc');                  $active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$dom,$course,'cc');
                 if ($active_cc eq 'ok') {                  if ($active_cc eq 'active') {
                     push @local_ccs, $roleinfo[1];                      push @local_ccs, $roleinfo[1];
                     $pname{$roleinfo[1]} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);                      $pname{$roleinfo[1]} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
                     $cc_status{$roleinfo[1]} = $lt{'actv'};                      $cc_status{$roleinfo[1]} = $lt{'actv'};
Line 239  all settings except course code, course Line 252  all settings except course code, course
     unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') )  {      unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') )  {
         push @local_ccs, $enrollvar{'courseowner'};          push @local_ccs, $enrollvar{'courseowner'};
         $pname{$enrollvar{'courseowner'}} =  &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom);          $pname{$enrollvar{'courseowner'}} =  &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom);
         $active_cc = &LONCAPA::Enrollment::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc');          $active_cc = &Apache::loncommon::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc');
         if ($active_cc eq 'ok') {          if ($active_cc eq 'active') {
             $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};              $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
         } else {          } else {
             $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};              $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
         }          }
     }      }
     my $numlocalcc = @local_ccs;      my $numlocalcc = @local_ccs;
     my $bodytag=&Apache::loncommon::bodytag(&mt("Modify Course Settings"));  
     my $helplink=&Apache::loncommon::help_open_topic('Modify_Course',&mt("Help on Modifying Courses"));      my $helplink=&Apache::loncommon::help_open_topic('Modify_Course',&mt("Help on Modifying Courses"));
     my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($dom);      my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($dom);
     my $curr_authtype = '';      my $curr_authtype = '';
Line 522  sub modify_course { Line 535  sub modify_course {
         }          }
     }      }
     if ($changeowner == 1 || $changecode == 1) {      if ($changeowner == 1 || $changecode == 1) {
         my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).':'.&Apache::lonnet::escape($env{'form.coursecode'}).':'.&Apache::lonnet::escape($env{'form.courseowner'});          my $courseid_entry = &escape($dom.'_'.$crs).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'});
         &Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom));          &Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom));
     }      }
   
Line 636  sub modify_course { Line 649  sub modify_course {
 sub print_header {  sub print_header {
     my ($r,$tasklongref,$description,$javascriptref) = @_;      my ($r,$tasklongref,$description,$javascriptref) = @_;
     my %lt =&Apache::lonlocal::texthash(      my %lt =&Apache::lonlocal::texthash(
              'vmcs' => 'View/Modify Course Settings',  
              'chco' => 'Choose a course',               'chco' => 'Choose a course',
              'main' => 'Main Menu',               'main' => 'Main Menu',
              'comg' => 'Course Manager',               'comg' => 'Course Manager',
Line 649  sub print_header { Line 661  sub print_header {
         $description = $lt{'comg'};          $description = $lt{'comg'};
     }      }
     my $page = '';      my $page = '';
     my $bodytag=&Apache::loncommon::bodytag($lt{'vmcs'});  
     if ($action eq 'start') {        if ($action eq 'start') {  
         $page = "<b>$lt{'chco'}</b>";          $page = "<b>$lt{'chco'}</b>";
     } else {      } else {
Line 661  sub print_header { Line 673  sub print_header {
             $page .=  " -&gt; <b>".$$tasklongref{$action}."</b>";              $page .=  " -&gt; <b>".$$tasklongref{$action}."</b>";
         }          }
     }      }
     my $html=&Apache::lonxml::xmlbegin();  
     $r->print("      my $js;
 $html  
 <head>  
 ");  
     if ($action eq 'display') {      if ($action eq 'display') {
         $r->print("   $js = '<script  type="text/javascript">
 <script language=\"JavaScript\" type=\"text/javascript\">                    '.$$javascriptref.'
 $$javascriptref                 </script>';
 </script>");  
     }      }
       $r->print(&Apache::loncommon::start_page('View/Modify Course Settings',
        $js));
     $r->print(<<ENDTHIS);      $r->print(<<ENDTHIS);
 <title>The LearningOnline Network with CAPA</title>  
 </head>  
 $bodytag  
 <table width="100%" border="0" cellpadding="0" cellspacing="0">  <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>   <tr>
   <td bgcolor="#CCCC99">    <td bgcolor="#CCCC99">
Line 691  ENDTHIS Line 698  ENDTHIS
 }  }
   
 sub print_footer {  sub print_footer {
     my $r = shift;      my ($r) = @_;
     $r->print(<<ENDBASE);      $r->print('<br />'.&Apache::loncommon::end_page());
 <br/>  
 </body>  
 </html>  
 ENDBASE  
     return;      return;
 }  }
   
 sub check_course {  sub check_course {
     my ($dom,$course) = @_;      my ($dom,$course) = @_;
     my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.');      my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.');
     foreach my $key (sort keys %courseIDs) {      foreach my $key (sort keys %courseIDs) {
         if ($key =~ m/^($dom)_(\w+)$/) {          if ($key =~ m/^($dom)_(\w+)$/) {
             if ($2 eq $course) {              if ($2 eq $course) {

Removed from v.1.16  
changed lines
  Added in v.1.25


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