Diff for /loncom/interface/loncreatecourse.pm between versions 1.111 and 1.132

version 1.111, 2008/11/11 16:40:43 version 1.132, 2009/10/31 18:23:30
Line 39  courses and assign course coordinators. Line 39  courses and assign course coordinators.
 This is part of the LearningOnline Network with CAPA project  This is part of the LearningOnline Network with CAPA project
 described at http://www.lon-capa.org.  described at http://www.lon-capa.org.
   
 =head1 HANDLER SUBROUTINE  =head1 SUBROUTINES
   
 handler()  =over
   
 =head1 OTHER SUBROUTINES  =item handler()
   
 =over  =item print_course_creation_page()
   
   =item create_course()
   
 =item *  =item print_intro_page()
   
 print_course_creation_page()  =item upload_batchfile()
   
 =item *  =item process_batchfile()
   
 create_course()  =item courserequestbrowser_javascript()
   
 =item *  =item print_creation_logs()
   
 print_intro_page()  =item creation_display_filter()
   
 =item *  =item course_types()
   
 upload_batchfile()  =item context_names()
   
 =item *  =item instcode_srchstr()
   
 process_batchfile()  =item syllabuslink_javascript()
   
 =back  =back
   
Line 88  use LONCAPA; Line 90  use LONCAPA;
   
 sub print_course_creation_page {  sub print_course_creation_page {
     my $r=shift;      my $r=shift;
     my $crstype = 'Group';      my $crstype = 'Community';
     if ($env{'form.phase'} eq 'courseone') {      if ($env{'form.phase'} eq 'courseone') {
         $crstype = 'Course';          $crstype = 'Course';
     }      }
Line 130  sub print_course_creation_page { Line 132  sub print_course_creation_page {
         $intform = &Apache::loncommon::authform_internal(%param);          $intform = &Apache::loncommon::authform_internal(%param);
         $locform = &Apache::loncommon::authform_local(%param);          $locform = &Apache::loncommon::authform_local(%param);
     } else {      } else {
           my $title_alert = &mt('A Community title is required');
           my $coord_alert = &mt('The username of the Coordinator is required');
         $javascript_validations = qq|          $javascript_validations = qq|
 function validate(formname) {  function validate(formname) {
     if (formname.title == '') {      if (formname.title == '') {
         alert("A group title is required");          alert("$title_alert");
         return;          return;
     }      }
     if (formname.ccuname == '') {      if (formname.ccuname == '') {
         alert("The username of the group coordinator is required");          alert("$coord_alert");
     }      }
     formname.submit();      formname.submit();
 }  }
Line 168  function validate(formname) { Line 172  function validate(formname) {
                     'stco' => "standard courses only",                      'stco' => "standard courses only",
                     'blnk' => "Blank",                      'blnk' => "Blank",
                     'sllb' => "Syllabus",                      'sllb' => "Syllabus",
                     'navi' => "Navigate",                      'navi' => "Course Contents",
                     'cid'  => "Course ID",                      'cid'  => "Course ID",
                     'dmn'  => "Domain",                      'dmn'  => "Domain",
                     'dsh'  => "Date Shift",                      'dsh'  => "Date Shift",
Line 183  function validate(formname) { Line 187  function validate(formname) {
                     'scfc' => "Set content feedback to Course Coordinator",                      'scfc' => "Set content feedback to Course Coordinator",
                     'cmmn' => "Communication",                      'cmmn' => "Communication",
                     'dsrd' => "Disable student resource discussion",                      'dsrd' => "Disable student resource discussion",
                     'dsuc' => "Disable student use of chatrooms",                      'dsuc' => "Disable student use of chat rooms",
                     'acco' => "Access Control",                      'acco' => "Access Control",
                     'snak' => "Students need access key to enter course",                      'snak' => "Students need access key to enter course",
     'kaut' =>       'kaut' => 
     'Key authority (<tt>id@domain</tt>) if other than course',      'Key authority (<tt>id@domain</tt>) if other than course',
                     'cc'   => "Course Coordinator",                      'ow'   => "Course Owner",
                       'cc'   => "(will be assigned Course Coordinator role)",
                     'user' => "Username",                      'user' => "Username",
                     'aens' => "Automated enrollment settings",                      'aens' => "Automated enrollment settings",
                     'aesc' => "The following settings control automatic enrollment of students in this class based on information available for this specific course from your institution's official classlists.",                      'aesc' => "The following settings control automatic enrollment of students in this class based on information available for this specific course from your institution's official classlists.",
Line 197  function validate(formname) { Line 202  function validate(formname) {
                     'no'   => "No",                      'no'   => "No",
                     'audr' => "Automated drops",                      'audr' => "Automated drops",
                     'dacu' => "Duration of automated classlist updates",                      'dacu' => "Duration of automated classlist updates",
                       'dads' => 'Default Access Dates for Students',
                     'dacc' => "Default start and end dates for student access",                      'dacc' => "Default start and end dates for student access",
                     'psam' => "Please select the Authentication mechanism",                      'psam' => "Please select the Authentication mechanism",
                     'pcda' => "Please choose the default authentication method to be used by new users added to this LON-CAPA domain by the automated enrollment process",                      'pcda' => "Please choose the default authentication method to be used by new users added to this LON-CAPA domain by the automated enrollment process",
Line 206  function validate(formname) { Line 212  function validate(formname) {
                     'irsp' => "Include retrieval of student photographs?",                      'irsp' => "Include retrieval of student photographs?",
     'rshm' => 'Resource Space Home',      'rshm' => 'Resource Space Home',
                     'cgrs' => "Course Group Settings",                      'cgrs' => "Course Group Settings",
                     'cgrq' => "Set a quota for the total disk space available for storage of course group portfolio files.",                      'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files',
                     'opco' => "Open Course",                      'opco' => "Open Course",
                     'ginf' => "Group Information",                      'ginf' => "Community Information",
                     'gtit' => "Group Title",                      'gtit' => "Community Title",
                     'ghsr' => "Group Home Server",                      'ghsr' => "Community Home Server",
                     'gidn' => "Group ID/Number",                      'gidn' => "Community ID/Number",
                     'grco' => "Group Content",                      'grco' => "Community Content",
                     'cngr' => "Completely new group",                      'cngr' => "Completely new community",
                     'cegr' => "Clone an existing group",                      'cegr' => "Clone an existing community",
                     'sagr' => "Do NOT generate as standard group",                      'sagr' => "Do NOT generate as standard community",
                     'stgo' => "standard groups only",                      'stgo' => "standard communities only",
                     'sgpf' => "Set group policy feedback to Group Coordinator",                      'sgpf' => "Set community policy feedback to Coordinator",
                     'scfg' => "Set content feedback to Group Coordinator",                      'scfg' => "Set content feedback to Coordinator",
                     'dmrd' => "Disable member resource discussion",                      'dmrd' => "Disable member resource discussion",
                     'dmuc' => "Disable member use of chatrooms",                      'dmuc' => "Disable member use of chat rooms",
                     'mnak' => "Members need access key to enter group",                      'mnak' => "Members need access key to enter community",
                     'kaug' =>                      'kaug' =>
                     'Key authority (<tt>id@domain</tt>) if other than group',                      'Key authority (<tt>id@domain</tt>) if other than community',
                     'gc'   => "Group Coordinator",                      'co'   => "Community Owner", 
                     'gid'  => "Group ID",                      'gc'   => "(will be assigned Coordinator role)",
                     'crgr' => "Create Group",                      'gid'  => "Community ID",
                     'grts' => "Group Teams Settings",                      'crgr' => "Create Community",
                     'grtq' => "Set a quota for the total disk space available for storage of group team portfolio files.",                      'grts' => "Community Group Settings",
                       'grtq' => "Set a quota for the total disk space available for storage of community group portfolio files.",
   
        );         );
     my $js = <<END;      my $js = <<END;
Line 257  END Line 264  END
   
     my %titles = &Apache::lonlocal::texthash(      my %titles = &Apache::lonlocal::texthash(
                   courseone => 'Create a New Course',                    courseone => 'Create a New Course',
                   groupone => 'Create a New Group',                    groupone => 'Create a New Community',
     );        );  
     my $start_page =       my $start_page = 
         &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);          &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);
Line 270  END Line 277  END
     $r->print($start_page.$crumbs);      $r->print($start_page.$crumbs);
   
     if ($crstype eq 'Course') {      if ($crstype eq 'Course') {
         $r->print('<form action="/adm/createcourse" method="post" name="ccrs">'          $r->print('<form action="/adm/createcourse" method="post" name="ccrs"><div class="LC_createcourse">'
                  .&Apache::lonhtmlcommon::start_pick_box()                   .&Apache::lonhtmlcommon::start_pick_box()
   
                  .&Apache::lonhtmlcommon::row_headline()                   .&Apache::lonhtmlcommon::row_headline()
                    .'<h3>'.$lt{'ow'}.'&nbsp;'.$lt{'cc'}.'</h3>'
                    .&Apache::lonhtmlcommon::row_closure()
   
                    .&Apache::lonhtmlcommon::row_title($lt{'user'})
                    .'<input type="text" size="15" name="ccuname" />'
                    .&Apache::loncommon::studentbrowser_javascript()
                    .&Apache::loncommon::selectstudent_link('ccrs','ccuname','ccdomain')
                    .&Apache::lonhtmlcommon::row_closure()
   
                    .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")
                    .$domform
                    .&Apache::lonhtmlcommon::row_closure()
   
                    .&Apache::lonhtmlcommon::row_headline()
                  .'<h3>'.$lt{'cinf'}.'</h3>'                   .'<h3>'.$lt{'cinf'}.'</h3>'
                  .&Apache::lonhtmlcommon::row_closure()                   .&Apache::lonhtmlcommon::row_closure()
   
Line 386  END Line 407  END
         );          );
   
         $r->print(&Apache::lonhtmlcommon::row_headline()          $r->print(&Apache::lonhtmlcommon::row_headline()
                    .'<h3>'.$lt{'dads'}.'</h3>'
                    .&Apache::lonhtmlcommon::row_closure()
                    .&Apache::lonhtmlcommon::row_title($lt{'dacc'})
                    .$access_table
                    .&Apache::lonhtmlcommon::row_closure()
           );
   
           $r->print(&Apache::lonhtmlcommon::row_headline()
                  .'<h3>'.$lt{'assp'}.'</h3>'                   .'<h3>'.$lt{'assp'}.'</h3>'
                  .&Apache::lonhtmlcommon::row_closure()                   .&Apache::lonhtmlcommon::row_closure()
   
Line 414  END Line 443  END
                  .&Apache::lonhtmlcommon::row_closure()                   .&Apache::lonhtmlcommon::row_closure()
   
                  .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})                   .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})
                  .'<input type="checkbox" name="disablechat" /'                   .'<input type="checkbox" name="disablechat" />'
                  .&Apache::lonhtmlcommon::row_closure()                   .&Apache::lonhtmlcommon::row_closure()
   
                  .&Apache::lonhtmlcommon::row_headline()                   .&Apache::lonhtmlcommon::row_headline()
Line 455  END Line 484  END
                  .$enroll_table                   .$enroll_table
                  .&Apache::lonhtmlcommon::row_closure()                   .&Apache::lonhtmlcommon::row_closure()
   
                  .&Apache::lonhtmlcommon::row_title($lt{'dacc'})  
                  .$access_table  
                  .&Apache::lonhtmlcommon::row_closure()  
   
                  .&Apache::lonhtmlcommon::row_title($lt{'psam'})                   .&Apache::lonhtmlcommon::row_title($lt{'psam'})
                  .$lt{'pcda'}.'<br />'                   .$lt{'pcda'}.'<br />'
                  .$krbform.'<br />'                   .$krbform.'<br />'
Line 491  END Line 516  END
   
                  .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})                   .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})
                  .'<input type="text" name="crsquota" value="20" size="6" />Mb'                   .'<input type="text" name="crsquota" value="20" size="6" />Mb'
                  .&Apache::lonhtmlcommon::row_closure()  
   
                  .&Apache::lonhtmlcommon::row_headline()  
                  .'<h3>'.$lt{'cc'}.'</h3>'  
                  .&Apache::lonhtmlcommon::row_closure()  
   
                  .&Apache::lonhtmlcommon::row_title($lt{'user'})  
                  .'<input type="text" size="15" name="ccuname" />'  
                  .&Apache::lonhtmlcommon::row_closure()  
   
                  .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")  
                  .$domform  
                  .&Apache::lonhtmlcommon::row_closure(1)                   .&Apache::lonhtmlcommon::row_closure(1)
   
                  .&Apache::lonhtmlcommon::end_pick_box()                   .&Apache::lonhtmlcommon::end_pick_box()
         );          );
   
         $r->print(<<ENDDOCUMENT);          $r->print(<<ENDDOCUMENT);
   </div>
 <p>  <p>
 <input type="hidden" name="prevphase" value="courseone" />  <input type="hidden" name="prevphase" value="courseone" />
 <input type="hidden" name="phase" value="coursetwo" />  <input type="hidden" name="phase" value="coursetwo" />
Line 517  END Line 530  END
 </form>  </form>
 ENDDOCUMENT  ENDDOCUMENT
   
     } elsif ($crstype eq 'Group') {      } elsif ($crstype eq 'Community') {
         $r->print(<<ENDDOCUMENT);          $r->print(<<ENDDOCUMENT);
 <form action="/adm/createcourse" method="post" name="ccrs">  <form action="/adm/createcourse" method="post" name="ccrs">
   <h2>$lt{'co'}&nbsp;$lt{'gc'}</h2>
   <p>
   <label>
       <b>$lt{'user'}:</b> <input type="text" size="15" name="ccuname" />
   </label>
   </p><p>
   <label>
       <b>$lt{'dmn'}:</b> $domform
   </label>
   </p>
 <h2>$lt{'ginf'}</h2>  <h2>$lt{'ginf'}</h2>
 <p>  <p>
 <label><b>$lt{'gtit'}:</b>  <label><b>$lt{'gtit'}:</b>
Line 624  $lt{'asov'}. Line 647  $lt{'asov'}.
     <input type="text" name="reshome" size="30" value="/res/$defdom/" />      <input type="text" name="reshome" size="30" value="/res/$defdom/" />
 </label>  </label>
 </p>  </p>
 <p>  
 <h2>$lt{'grts'}</h2>  <h2>$lt{'grts'}</h2>
   <p>
 $lt{'grtq'}  $lt{'grtq'}
 <input type="text" name="crsquota" value="20" />Mb  <input type="text" name="crsquota" value="20" />Mb
 </p>  </p>
 <hr />  <hr />
 <h2>$lt{'gc'}</h2>  
 <p>  
 <label>  
     <b>$lt{'user'}:</b> <input type="text" size="15" name="ccuname" />  
 </label>  
 </p><p>  
 <label>  
     <b>$lt{'dmn'}:</b> $domform  
 </label>  
 </p>  
 <p>  <p>
 <input type="hidden" name="prevphase" value="groupone" />  <input type="hidden" name="prevphase" value="groupone" />
 <input type="hidden" name="phase" value="grouptwo" />  <input type="hidden" name="phase" value="grouptwo" />
Line 657  sub create_course { Line 670  sub create_course {
     my $r=shift;      my $r=shift;
     my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});      my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
     my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});      my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
     my $crstype = 'Group';      my $crstype = 'Community';
     my ($enrollstart,$enrollend,$startaccess,$endaccess);      my ($enrollstart,$enrollend,$startaccess,$endaccess);
   
     if ($env{'form.phase'} eq 'coursetwo') {      if ($env{'form.phase'} eq 'coursetwo') {
Line 767  sub create_course { Line 780  sub create_course {
  &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,   &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
      \$crsudom,\$crsunum,       \$crsudom,\$crsunum,
      $env{'user.domain'},       $env{'user.domain'},
      $env{'user.name'});       $env{'user.name'},'dc_create');
     $r->print($output);      $r->print($output);
     if ($success) {      if ($success) {
         #          #
  # Make the requested user a course coordinator or group coordinator   # Make the requested user a course coordinator or group coordinator
         #          #
  if (($ccdomain) && ($ccuname)) {   if (($ccdomain) && ($ccuname)) {
     $r->print(&mt('Assigning role of [_1] Coordinator to [_2] at [_3]: ',              my $ccrole = 'cc';
   $crstype,$ccuname,$ccdomain).              if ($crstype eq 'Community') {
       &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,                  $ccrole = 'co';
   'cc','','','','','createcourse').'<p>');              }    
       $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
    ,'<i>'.$ccuname.':'.$ccdomain.'</i>')
         .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
     $ccrole,'','','','','createcourse').'<p>');
  }   }
  if ($env{'form.setkeys'}) {   if ($env{'form.setkeys'}) {
     $r->print(      $r->print(
Line 788  sub create_course { Line 805  sub create_course {
  $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');   $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
     }      }
     $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.      $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
       &mt('Create Another [_1]',$crstype).'</a></p>'.        &mt("Create Another $crstype").'</a></p>'.
       &Apache::loncommon::end_page());        &Apache::loncommon::end_page());
 }  }
   
 sub print_intro_page {  sub print_intro_page {
     my $r = shift;      my $r = shift;
     my $start_page =      my $start_page =
         &Apache::loncommon::start_page('Create a New Course or Group Space');          &Apache::loncommon::start_page('Create a New Course or Community');
     my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');      my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
     my $end_page =      my $end_page =
         &Apache::loncommon::end_page();          &Apache::loncommon::end_page();
     my $helplink=&Apache::loncommon::help_open_topic('Create_Course_GroupSpace',&mt('Help on Creating Courses and Groups'));      my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
   
     my @choices = ({ internal_name => 'courseone',      my @choices = ({ internal_name => 'courseone',
                      name => &mt('Create a single course'),                       name => &mt('Create a single course'),
Line 807  sub print_intro_page { Line 824  sub print_intro_page {
     &mt('Create a new course by completing an online form.'),      &mt('Create a new course by completing an online form.'),
                  },                   },
                    { internal_name => 'groupone',                     { internal_name => 'groupone',
                      name => &mt('Create a single collaborative group space'),                       name => &mt('Create a single community'),
                      short_description =>                       short_description =>
     &mt('Create a new group space for non-course use by completing an online form.'),      &mt('Create a new collaborative community by completing an online form.'),
                  },                   },
                    { internal_name => 'batchone',                     { internal_name => 'batchone',
                      name => &mt('Create courses/groups by uploading an attributes file'),                       name => &mt('Create courses/communities by uploading an attributes file'),
                      short_description =>                       short_description =>
     &mt('Upload an attributes file containing specifications for one or more courses or groups in XML format.'),      &mt('Upload an attributes file containing specifications for one or more courses or communities in XML format.'),
                      help => 'Batch_Creation',                       help => 'Batch_Creation',
                  },                   },
                      { internal_name => 'requestdisplay',
                        name => &mt('Approve or reject course requests'),
                        short_description =>
       &mt('Display course creation requests submitted by authorized users, held pending approval by a Domain Coordinator.'),
                      },
                      { internal_name => 'creationlog',
                        name => &mt('View course creation log'),
                        short_description =>
       &mt('Display information about when, how and by whom courses were created in this domain.'),
                      },
     );      );
     my $options;      my $options;
     foreach my $choice (@choices) {      foreach my $choice (@choices) {
Line 841  ENDDOCUMENT Line 868  ENDDOCUMENT
 sub upload_batchfile {  sub upload_batchfile {
     my $r = shift;      my $r = shift;
     my $start_page =      my $start_page =
         &Apache::loncommon::start_page('Create a New Course or Group Space');          &Apache::loncommon::start_page('Create a New Course or Community');
     my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Group Attributes File','Create_Course',undef,'Create_Courses');      my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses');
     my $end_page =      my $end_page =
         &Apache::loncommon::end_page();          &Apache::loncommon::end_page();
     $r->print($start_page.$crumbs);      $r->print($start_page.$crumbs);
     $r->print('<h3>'.&mt('Upload a courses or groups attributes file').'</h3>');      $r->print('<h3>'.&mt('Upload a courses or communities attributes file').'</h3>');
     $r->print('<form name="batchcreate" method="post" '.      $r->print('<form name="batchcreate" method="post" '.
                 'enctype="multipart/form-data" action="/adm/createcourse">'.                  'enctype="multipart/form-data" action="/adm/createcourse">'.
               '<input type="file" name="coursecreatorxml" />'.                '<input type="file" name="coursecreatorxml" />'.
               '<input type="hidden" name="phase" value="batchtwo"><br /><br />'.                '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
               '<input type="submit" name="batchsubmit" '.                '<input type="submit" name="batchsubmit" '.
               'value="Create Courses/Groups" /></form>');                'value="Create Courses/Communities" /></form>');
     $r->print($end_page);      $r->print($end_page);
     return;      return;
 }  }
Line 860  sub upload_batchfile { Line 887  sub upload_batchfile {
 sub process_batchfile {  sub process_batchfile {
     my $r = shift;      my $r = shift;
     my $start_page =      my $start_page =
         &Apache::loncommon::start_page('Create a New Course or Group Space');          &Apache::loncommon::start_page('Create a New Course or Community');
     my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');      my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
     my $end_page =      my $end_page =
         &Apache::loncommon::end_page();          &Apache::loncommon::end_page();
Line 898  sub process_batchfile { Line 925  sub process_batchfile {
     
 }  }
   
   sub courserequestbrowser_javascript {
       return <<"ENDREQBRW";
   <script type="text/javascript">
   // <![CDATA[
   var steditbrowser;
   function opencoursereqdisplay(cdom,cnum) {
       var url = '/adm/requestcourse?action=display';
       url += '&showdom='+cdom+'&cnum='+cnum;
       var title = 'Course_Request_Browser';
       var options = 'scrollbars=1,resizable=1,menubar=0';
       options += ',width=700,height=600';
       var stdeditbrowser = open(url,title,options,'1');
       stdeditbrowser.focus();
   }
   // ]]>
   </script>
   ENDREQBRW
   }
   
   sub print_creation_logs {
       my ($r) = @_;
       my $formname = 'creationlog';
       my $dom = $env{'request.role.domain'};
       $r->print('<form action="/adm/createcourse" method="post" name="'.$formname.'">');
       # set defaults
       my $now = time();
       my $defstart = $now - (7*24*3600); #7 days ago
       my %defaults = (
                        page                => '1',
                        show                => '10',
                        type                => 'any',
                        context             => 'any',
                        created_before_date => $now,
                        created_after_date  => $defstart,
                      );
       my ($contexts,$contextnames) = &context_names();
       my $more_records = 0;
       my %curr;
       foreach my $item ('show','page','type','context') {
           $curr{$item} = $env{'form.'.$item};
       }
       my $createdafter = &Apache::lonhtmlcommon::get_date_from_form('created_after_date');
       my $createdbefore = &Apache::lonhtmlcommon::get_date_from_form('created_before_date');
       $curr{'created_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_after_date');
       $curr{'created_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_before_date');
       foreach my $key (keys(%defaults)) {
           if ($curr{$key} eq '') {
               $curr{$key} = $defaults{$key};
           }
       }
       my (%whodunit,$version);
       ($version) = ($r->dir_config('lonVersion') =~ /^([\d\.]+)\-/);
       $r->print(&creation_display_filter($formname,\%curr,$version));
       my $showntablehdr = 0;
       my $tablehdr = &Apache::loncommon::start_data_table().
                      &Apache::loncommon::start_data_table_header_row().
                      '<th>&nbsp;</th><th>'.&mt('Creation Date').'</th>'.
                      '<th>'.&mt('Creator').'</th><th>'.&mt('Description').'</th>'.
                      '<th>'.&mt('Owner(s)').'</th>';
       if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
          $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
       }
       if ($curr{'type'} eq 'any') { 
           $tablehdr .= '<th>'.&mt('Course Type').'</th>';
       }
       if ($curr{'context'} eq 'any') {
           $tablehdr .= '<th>'.&mt('Creation Context').'</th>';
       }
       $tablehdr .= &Apache::loncommon::end_data_table_header_row();
       my ($minshown,$maxshown);
       $minshown = 1;
       my $count = 0;
       if ($curr{'show'} ne &mt('all')) {
           $maxshown = $curr{'page'} * $curr{'show'};
           if ($curr{'page'} > 1) {
               $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
           }
       }
       my $crstype = 'Course';
       if ($curr{'type'} eq 'any') {
           $crstype = '.';
       } elsif ($curr{'type'} eq 'community') {
           $crstype = 'Community';
       }
   
       my ($instcodefilter,$regexpok);
       my (@codetitles,%cat_titles,%cat_order,%cat_items,$officialjs);
       my ($jscript,$totcodes,$numtitles,$lasttitle) =
           &Apache::courseclassifier::instcode_selectors_data($dom,$formname,
                              \%cat_items,\@codetitles,\%cat_titles,\%cat_order,
                              $officialjs);
       if ($numtitles) {
           if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'unofficial')) {
               $instcodefilter = &instcode_srchstr($dom,$numtitles);
                   &Apache::courseclassifier::instcode_search_str($dom,$numtitles);
               if ($curr{'type'} eq 'official') {
                   $regexpok = 1;
               } else {
                   unless ($instcodefilter eq '') {
                       $regexpok = -1;
                   }
               }
           }
       }
       if ($instcodefilter eq '') { $instcodefilter = '.'; }
   
       my $creationcontext = '.';
       my $context_regexp = join('|',@{$contexts});
       if ($curr{'context'} =~ /^($context_regexp)$/) {
           $creationcontext = $curr{'context'};
       } 
       my %courses = 
           &Apache::lonnet::courseiddump($dom,'.',1,$instcodefilter,'.','.',undef,undef,
                                         $crstype,$regexpok,undef,undef,'1','creationlog',
                                         undef,undef,undef,$curr{'created_before_date'},
                                         $curr{'created_after_date'},$creationcontext);
       foreach my $cid (sort { $courses{$b}{'created'}<=>$courses{$a}{'created'} } (keys(%courses))) {
           $count ++;
           next if ($count < $minshown);
           if (!$showntablehdr) {
               $r->print($tablehdr);
               $showntablehdr = 1;
           }
           if ($courses{$cid}{'creator'} ne '') {
               if ($whodunit{$courses{$cid}{'creator'}} eq '') {
                   my ($uname,$udom) = split(':',$courses{$cid}{'creator'});
                   $whodunit{$courses{$cid}{'creator'}} =
                       &Apache::loncommon::plainname($uname,$udom);
               }
           }
           my $description = $courses{$cid}{'description'};
           my @owners;
           my $singleowner = $courses{$cid}{'owner'};
           push(@owners,$singleowner);
           if (ref($courses{$cid}{'co-owners'}) eq 'ARRAY') {
               foreach my $item (@{$courses{$cid}{'co-owners'}}) {
                   push(@owners,$item);
               }
           }
           my %ownernames;
           foreach my $owner (@owners) {
               my ($ownername,$ownerdom);     
               if ($owner =~ /:/) {
                   ($ownername,$ownerdom) = split(/:/,$owner);
               } else {
                   $ownername = $owner;
                   if ($owner ne '') {
                       $ownerdom = $dom;
                   }
               }
               if ($ownername ne '' && $ownerdom ne '') {
                   unless (ref($ownernames{$ownername.':'.$ownerdom}) eq 'HASH') { 
                       my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
                       $ownernames{$ownername.':'.$ownerdom} = \%namehash;
                   }
               }
           }
           my @lastnames;
           foreach my $owner (keys(%ownernames)) {
               if (ref($ownernames{$owner}) eq 'HASH') {
                   push(@lastnames,$ownernames{$owner}{'lastname'});
               }
           }
           my $ownerlastnames = join(', ',sort(@lastnames));
           my $showtype;
           if ($courses{$cid}{type} eq 'Community') {
               $showtype = &mt('community');
           } else {
               my $instcode = $courses{$cid}{inst_code};
               if ($instcode ne '')  {
                   $showtype = &mt('official');
               } else {
                   $showtype = &mt('unofficial');
               }
           }
           my $showcontext;
           
           if ($courses{$cid}{context} =~ /^($context_regexp)$/) {
               $showcontext = $contextnames->{$courses{$cid}{context}};
           }
           my $created = &Apache::lonlocal::locallocaltime($courses{$cid}{'created'});
           my ($cdom,$cnum) = split('_',$cid);
           $r->print(&Apache::loncommon::start_data_table_row()."\n".
                     '<td>'.$count.'</td><td>'.$created.'</td>'."\n".
                     '<td>'.$whodunit{$courses{$cid}{creator}}.'</td>'."\n".
                     '<td>'.$description.'&nbsp;<a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a></td><td>'.$ownerlastnames.'</td>');
           if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
               $r->print('<td>'.$courses{$cid}{'inst_code'}.'</td>');
           }
           if ($curr{'type'} eq 'any') {
               $r->print('<td>'.$showtype.'</td>');
           }
           if ($curr{'context'} eq 'any') {
               $r->print('<td>'.$showcontext.'</td>');
           }
           $r->print('<td>'.&Apache::loncommon::end_data_table_row()."\n");
       }
       if ($showntablehdr) {
           $r->print(&Apache::loncommon::end_data_table().'<br />');
           if (($curr{'page'} > 1) || ($more_records)) {
               $r->print('<table><tr>');
               if ($curr{'page'} > 1) {
                   $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
               }
               if ($more_records) {
                   $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
               }
               $r->print('</tr></table>');
               $r->print(<<"ENDSCRIPT");
   <script type="text/javascript">
   // <![CDATA[
   function chgPage(caller) {
       if (caller == 'previous') {
           document.$formname.page.value --;
       }
       if (caller == 'next') {
           document.$formname.page.value ++;
       }
       document.$formname.submit();
       return;
   }
   // ]]>
   </script>
   ENDSCRIPT
           }
       } else {
           $r->print('<p class="LC_info">'.
                     &mt('There are no records to display').
                     '</p>');
       }
       $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
                 '<input type="hidden" name="phase" value="creationlog" /></form>');
       return;
   }
   
   sub creation_display_filter {
       my ($formname,$curr,$version) = @_;
       my $nolink = 1;
       my ($contexts,$contextnames) = &context_names();
       my $output = '<table><tr><td valign="top">'.
                    '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
                    &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
                                                 (&mt('all'),5,10,20,50,100,1000,10000)).
                    '</td><td>&nbsp;&nbsp;</td>';
       my $startform =
           &Apache::lonhtmlcommon::date_setter($formname,'created_after_date',
                                               $curr->{'created_after_date'},undef,
                                               undef,undef,undef,undef,undef,undef,$nolink);
       my $endform =
           &Apache::lonhtmlcommon::date_setter($formname,'created_before_date',
                                               $curr->{'created_before_date'},undef,
                                               undef,undef,undef,undef,undef,undef,$nolink);
       $output .= '<td valign="top"><b>'.&mt('Window during which course was created:').'</b><br />'.
                  '<table><tr><td>'.&mt('After:').
                  '</td><td>'.$startform.'</td></tr>'.
                  '<tr><td>'.&mt('Before:').'</td>'.
                  '<td>'.$endform.'</td></tr></table>'.
                  '</td>'.
                  '<td>&nbsp;&nbsp;</td>';
       my ($types,$typenames) = &course_types();
       if (ref($types) eq 'ARRAY') {
           if (@{$types} > 1) {
               $output .= '<td valign="top"><b>'.
                          &mt('Course Type:').'</b><br /><select name="type">';
               my $selstr = '';
               if ($curr->{'type'} eq 'any') {
                   $selstr = ' selected="selected"';
               }
               $output .= '<option value="any"'.$selstr.'>'.&mt('Any').'</option>'."\n";
               foreach my $type (@{$types}) {
                   my $selstr = '';
                   if ($curr->{'type'} eq $type) {
                       $selstr = ' selected="selected"';
                   }
                   my $typename = $type;
                   if (ref($typenames) eq 'HASH') {
                       if ($typenames->{$type} ne '') {
                           $typename = $typenames->{$type};
                       }
                   }
                   $output .= '<option value="'.$type.'"'.$selstr.'>'.$typename.'</option>'."\n";
               }
               $output .= '</select></td>';
           }
       }
       $output .= '<td>&nbsp;&nbsp;</td>'.
                  '<td valign="top"><b>'.
                  &mt('Creation Context:').'</b><br /><select name="context">';
       foreach my $context ('any',@{$contexts}) {
           my $selstr = '';
           if ($curr->{'context'} eq $context) {
               $selstr = ' selected="selected"';
           }
           $output .= '<option value="'.$context.'"'.$selstr.'>';
           if ($context eq 'any') {
               $output .= &mt('Any');
           } else {
               $output .= $contextnames->{$context};
           }
           $output .= '</option>'."\n";
       }
       $output .= '</select></td>'.
                  '</tr></table>';
   
       # Update Display button
       $output .= '<p>'.
                  '<input type="submit" value="'.&mt('Update Display').'" />'.
                  '</p>';
   
       # Server version info
       $output .= '<p class="LC_info">'.
                  &mt('Only courses and communities created from servers running LON-CAPA [_1] or later are displayed.','2.9.0');
       if ($version) {
           $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version);
       }
       $output .= '</p><hr />';
       return $output;
   }
   
   sub course_types {
       my @types = qw(official unofficial community);
       my %typename = (
                            official   => 'Official course',
                            unofficial => 'Unofficial course',
                            community  => 'Community',
                      );
       return (\@types,\%typename);
   }
   
   sub context_names {
       my @contexts = qw(auto web dc_create requestcourses);
       my %contextnames = 
           &Apache::lonlocal::texthash (
                           auto           => 'Automated creation from batch file',
                           web            => 'Batch creation from uploaded file',
                           dc_create      => 'Course or community created by Dom. Coord.', 
                           requestcourses => 'Processing of submitted course request',
           );
       return (\@contexts,\%contextnames);
   }
   
   sub instcode_srchstr {
       my ($domain,$numtitles) = @_;
       my $instcode;
       if (defined($numtitles) && $numtitles == 0) {
           $instcode = '.+';
       } else {
           my (%codedefaults,@code_order);
           my $defaults_result =
               &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
                                                       \@code_order);
           if ($defaults_result eq 'ok') {
               $instcode ='^';
               foreach my $item (@code_order) {
                   $instcode .= $codedefaults{$item};
               }
               $instcode .= '$';
           } else {
               $instcode = '.+';
           }
       }
       return $instcode;
   }
   
   sub syllabuslink_javascript {
       return <<"ENDJS";
   
   function ToSyllabus(cdom,cnum) {
       if (cdom == '' || cdom == null) {
           return;
       }
       if (cnum == '' || cnum == null) {
           return;
       }
       var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
       var url = "/public/"+cdom+"/"+cnum+"/syllabus";
       syllwin = window.open(url,'',options,1);
       syllwin.focus();
       return;
   }
   
   ENDJS
   
   }
   
 # ===================================================================== Handler  # ===================================================================== Handler
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
Line 953  sub handler { Line 1365  sub handler {
                    text=>"Creation Outcome",                     text=>"Creation Outcome",
                    faq=>9,bug=>'Dom Coord Interface',});                     faq=>9,bug=>'Dom Coord Interface',});
            &process_batchfile($r);             &process_batchfile($r);
          } elsif ($env{'form.phase'} eq 'requestdisplay') {
              &Apache::lonhtmlcommon::add_breadcrumb
                    ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
                      text=>&mt('[_1] Display Request Queue',),
                      faq=>9,bug=>'Dom Coord Interface',});
              my $js = &courserequestbrowser_javascript();
              my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
              my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Request',undef,'Course_Request');
              $r->print($start_page.$crumbs."\n".'<div>'.
                        &Apache::loncoursequeueadmin::display_queued_requests(
                            'domain',$env{'request.role.domain'}).'</div>'.
                        &Apache::loncommon::end_page());
          } elsif ($env{'form.phase'} eq 'requestchange') {
              &Apache::lonhtmlcommon::add_breadcrumb
                    ({href=>"/adm/createcourse?phase=requestdisplay",
                      text=>&mt('[_1] Display Request Queue',),
                      faq=>9,bug=>'Dom Coord Interface',},
                    {href=>"/adm/createcourse?phase=requestchange",
                      text=>&mt('[_1] Requests Updated',),
                      faq=>9,bug=>'Dom Coord Interface',},);
              my $start_page=&Apache::loncommon::start_page('Update Requests Result');
              my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Request',undef,'Course_Request');
              $r->print($start_page.$crumbs."\n".'<div>'.
                        &Apache::loncoursequeueadmin::update_request_queue(
                        'domain',$env{'request.role.domain'}).'</div>'.
                        &Apache::loncommon::end_page());
          } elsif ($env{'form.phase'} eq 'creationlog') {
              &Apache::lonhtmlcommon::add_breadcrumb
                    ({href=>"/adm/createcourse?phase=creationlog",
                      text=>&mt('[_1] Display Creation History',),});
              my $js = '<script type="text/javascript">'."\n".
                       '// <![CDATA['."\n".
                       &syllabuslink_javascript()."\n".
                       '// ]]>'."\n".
                       '</script>';
              my $start_page=&Apache::loncommon::start_page('Course/Community Creation Logs',$js);
              my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Created Courses/Communities','Creation_Log',undef,'Creation_Log');
              $r->print($start_page.$crumbs."\n".'<div>');
              &print_creation_logs($r);
              $r->print('</div>'.&Apache::loncommon::end_page());
        } else {         } else {
            &print_intro_page($r);             &print_intro_page($r);
        }         }
    } else {     } else {
       $env{'user.error.msg'}=        $env{'user.error.msg'}=
         "/adm/createcourse:ccc:0:0:Cannot create courses or groups";          "/adm/createcourse:ccc:0:0:Cannot create courses or communities";
       return HTTP_NOT_ACCEPTABLE;         return HTTP_NOT_ACCEPTABLE; 
    }     }
    return OK;     return OK;

Removed from v.1.111  
changed lines
  Added in v.1.132


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