Diff for /loncom/interface/lonsyllabus.pm between versions 1.29 and 1.38

version 1.29, 2004/05/03 17:49:11 version 1.38, 2004/07/27 23:35:34
Line 36  use Apache::lontexconvert; Line 36  use Apache::lontexconvert;
 use Apache::lonfeedback;  use Apache::lonfeedback;
 use Apache::lonannounce;  use Apache::lonannounce;
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::lonhtmlcommon;
   use Apache::lonspeller();
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
Line 45  sub handler { Line 47  sub handler {
   
 # ------------------------------------------------------------ Print the screen  # ------------------------------------------------------------ Print the screen
     my $target=$ENV{'form.grade_target'};      my $target=$ENV{'form.grade_target'};
     &Apache::lonnet::logthis("NOW TARGET IS DEFINIED AS $target");  
     if ($target ne 'tex') {      if ($target ne 'tex') {
  $r->print(<<ENDDOCUMENT);   $r->print(<<ENDDOCUMENT);
 <html>  <html>
Line 99  ENDDOCUMENT Line 100  ENDDOCUMENT
 # ------------------------------------- There is such a course, get environment  # ------------------------------------- There is such a course, get environment
     my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);      my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
     if ($target ne 'tex') {      if ($target ne 'tex') {
  $r->print('</head>'.&Apache::loncommon::bodytag   $r->print(&Apache::lonhtmlcommon::htmlareaheaders().
     '</head>'.&Apache::loncommon::bodytag
             ("Syllabus",$forcestudent,$addentries,'',$cdom,$ENV{'form.register'}));              ("Syllabus",$forcestudent,$addentries,'',$cdom,$ENV{'form.register'}));
  $r->print('<h1>'.$courseenv{'description'}.'</h1><h3>'.   $r->print('<h1>'.$courseenv{'description'}.'</h1><h3>'.
                  $Apache::lonnet::domaindescription{$cdom}.'</h3>');                   $Apache::lonnet::domaindescription{$cdom}.'</h3>');
Line 108  ENDDOCUMENT Line 110  ENDDOCUMENT
                  $Apache::lonnet::domaindescription{$cdom}.'}\\\\');                   $Apache::lonnet::domaindescription{$cdom}.'}\\\\');
     }      }
 # -------------------------------------------------------------- Announcements?  # -------------------------------------------------------------- Announcements?
     $r->print(&Apache::lonannounce::showday(time,2,      if ($target ne 'tex') {
    $r->print(&Apache::lonannounce::showday(time,2,
                          &Apache::lonannounce::readcalendar($cdom.'_'.$cnum)));                           &Apache::lonannounce::readcalendar($cdom.'_'.$cnum)));
       } else {
    $r->print(&Apache::lonxml::xmlparse($r,'tex',
          &Apache::lonannounce::showday(time,2,
                          &Apache::lonannounce::readcalendar($cdom.'_'.$cnum))));
       }
 # -------------------------------------------------------- Get course personnel  # -------------------------------------------------------- Get course personnel
     my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);      my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
     if ($target ne 'tex') {      if ($target ne 'tex') {
  $r->print('<table border="2">');   $r->print('<table border="2">');
     } else {      } else {
  $r->print('\begin{tabular}{|c|c|}\hline');   $r->print('\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}\hline');
     }      }
     foreach (sort keys %coursepersonnel) {      foreach my $element (sort keys %coursepersonnel) {
  if ($target ne 'tex') {   if ($target ne 'tex') {
     $r->print('<tr><td>'.$_.'</td><td>');      $r->print('<tr><td>'.$element.'</td><td>');
  } else {   } else {
     $r->print(' '.$_.'\\\\  ');       $r->print(' '.&Apache::lonxml::xmlparse($r,'tex',$element).' & '); 
  }   }
         foreach (split(/\,/,$coursepersonnel{$_})) {          foreach (split(/\,/,$coursepersonnel{$element})) {
     my ($puname,$pudom)=split(/\:/,$_);      my ($puname,$pudom)=split(/\:/,$_);
     if ($target ne 'tex') {      if ($target ne 'tex') {
  $r->print(' '.&Apache::loncommon::aboutmewrapper(   $r->print(' '.&Apache::loncommon::aboutmewrapper(
Line 160  ENDDOCUMENT Line 168  ENDDOCUMENT
   if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {    if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
       $forcestudent='student';        $forcestudent='student';
   }    }
           if ($forcestudent) { $allowed=0; }            if ($forcestudent or $target eq 'tex') { $allowed=0; }
        }         }
        if ($allowed) {         if ($allowed) {
           $r->print('<p>'.            $r->print('<p>'.
Line 181  ENDDOCUMENT Line 189  ENDDOCUMENT
        if (($allowed) && ($ENV{'form.storesyl'})) {         if (($allowed) && ($ENV{'form.storesyl'})) {
    foreach (keys %syllabusfields) {     foreach (keys %syllabusfields) {
                my $field=$ENV{'form.'.$_};                 my $field=$ENV{'form.'.$_};
          chomp($field);
                $field=~s/\s+$//s;                 $field=~s/\s+$//s;
                $field=&Apache::lonfeedback::clear_out_html($field,1);         $field=~s/^\s+//s;
          $field=~s/\<br\s*\/*\>$//s;
          $field=&Apache::lonfeedback::clear_out_html($field,1);
        $syllabus{$_}=$field;         $syllabus{$_}=$field;
                if ($_ eq 'lll_includeurl') { # clean up included URLs                 if ($_ eq 'lll_includeurl') { # clean up included URLs
                   my $field='';                    my $field='';
Line 239  ENDDOCUMENT Line 250  ENDDOCUMENT
    $r->print('<form method="post">'.     $r->print('<form method="post">'.
      '<input type="hidden" name="forceedit" value="edit" />');       '<input type="hidden" name="forceedit" value="edit" />');
        }         }
          my @htmlids=();
        foreach (sort keys %syllabusfields) {         foreach (sort keys %syllabusfields) {
           if (($syllabus{$_}) || ($allowed)) {            if (($syllabus{$_}=~/\w/) || ($allowed)) {
               my $message=$syllabus{$_};                my $message=$syllabus{$_};
               if ($_ eq 'lll_includeurl') { # this is the "included" field                if ($_ eq 'lll_includeurl') { # this is the "included" field
   my $urls=$message;    my $urls=$message;
Line 257  ENDDOCUMENT Line 269  ENDDOCUMENT
 # embed as an image  # embed as an image
                          $output='<img src="'.$filelink.'" />';                           $output='<img src="'.$filelink.'" />';
       }        }
                       $message.='<p>'.$output.'</p>';        if ($target ne 'tex') {
     $message.='<p>'.$output.'</p>';
         } else {
     $message.=' '.&Apache::lonxml::xmlparse($r,'tex','<p>'.$output.'</p>').' ';
         }      
                   }                    }
                   if ($allowed) {                    if ($allowed) {
                      $r->print('<h3>'.$syllabusfields{$_}.                       $r->print('<h3>'.$syllabusfields{$_}.
Line 271  ENDDOCUMENT Line 287  ENDDOCUMENT
                  $message=~s/\n/\<br \/\>/g;                   $message=~s/\n/\<br \/\>/g;
                  $message                   $message
            =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;             =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
    if ($allowed) {
        $message=&Apache::lonspeller::markeduptext($message);
    }
          $message=&Apache::lontexconvert::msgtexconverted($message);           $message=&Apache::lontexconvert::msgtexconverted($message);
  if ($target ne 'tex') {   if ($target ne 'tex') {
      $r->print('<h3>'.$syllabusfields{$_}.'</h3><blockquote>'.       $r->print('<h3>'.$syllabusfields{$_}.'</h3><blockquote>'.
                                $message.'</blockquote>');                                 $message.'</blockquote>');
  } else {   } else {
      $r->print('\\\\\textbf{'.$syllabusfields{$_}.'}\\\\'.       $r->print('\\\\\textbf{'.$syllabusfields{$_}.'}\\\\'.
        &Apache::lonxml::xmlparse($r,' ',$message).'\\\\');         &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
  }   }
    push @htmlids,$_;
      }       }
               if ($allowed) {                if ($allowed) {
                  $r->print('<br /><textarea cols="80" rows="6" name="'.$_.'">'.                   $r->print(
      '<br /><textarea cols="80" rows="12" name="'.$_.'" id="'.$_.'">'.
    $syllabus{$_}.     $syllabus{$_}.
            '</textarea><input type="submit" name="storesyl" value="Store" />');             '</textarea> <input type="submit" name="storesyl" value="Store" />');
       }        }
   }    }
        }         }
        if ($allowed) {         if ($allowed) {
    $r->print('</form>');     $r->print('</form>'.
        &Apache::lonhtmlcommon::htmlareaselectactive(@htmlids));
        }         }
        if ($target ne 'tex') {$r->print('</p>');} else {$r->print('\\\\');}         if ($target ne 'tex') {$r->print('</p>');} else {$r->print('\\\\');}
     } else {      } else {
        $r->print('<p>No syllabus information provided.</p>');   if ($target ne 'tex') {$r->print('<p>');} else {$r->print('\par ');} 
    $r->print('No syllabus information provided.');
    if ($target ne 'tex') {$r->print('</p>');}
     }      }
     if ($target ne 'tex') {$r->print('</body></html>');} else {$r->print('\end{document}');}      if ($target ne 'tex') {$r->print('</body></html>');} else {$r->print('\end{document}');}
     return OK;      return OK;

Removed from v.1.29  
changed lines
  Added in v.1.38


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