Diff for /loncom/interface/lonevaluate.pm between versions 1.18 and 1.31

version 1.18, 2006/03/02 21:11:00 version 1.31, 2018/04/14 02:29:44
Line 26 Line 26
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
   
   
 package Apache::lonevaluate;  package Apache::lonevaluate;
   
 use strict;  use strict;
Line 33  use Apache::lonnet; Line 35  use Apache::lonnet;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonenc();  use Apache::lonenc();
   use Apache::lonlocal;
   use LONCAPA();
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
       &Apache::loncommon::no_cache($r);
       
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);
     my $feedurl=$env{'form.postdata'};      my $feedurl=$env{'form.postdata'};
     $feedurl=~s/^http\:\/\///;      $feedurl=~s/^https?\:\/\///;
     $feedurl=~s/^$ENV{'SERVER_NAME'}//;      $feedurl=~s/^$ENV{'SERVER_NAME'}//;
     $feedurl=~s/^$ENV{'HTTP_HOST'}//;      $feedurl=~s/^$ENV{'HTTP_HOST'}//;
   
Line 51  sub handler { Line 57  sub handler {
     my $title=&Apache::lonnet::gettitle($feedurl);      my $title=&Apache::lonnet::gettitle($feedurl);
     my $showurl=&Apache::lonenc::check_encrypt($feedurl);      my $showurl=&Apache::lonenc::check_encrypt($feedurl);
   
     my ($rdomain,$rauth)=($feedurl=~/^(\w+)\/(\w+)\//);      my ($rdomain,$rauth)=($feedurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\//);
   
     my $prefix=$env{'user.name'}.'@'.$env{'user.domain'}.'___'.      my $prefix=$env{'user.name'}.'@'.$env{'user.domain'}.'___'.
  $feedurl.'___';   $feedurl.'___';
Line 70  sub handler { Line 76  sub handler {
   
     my $warning='';      my $warning='';
   
     my $bodytag=&Apache::loncommon::bodytag('Evaluate Resource');      my $windowname = 'loncapaclient';
       if ($env{'request.lti.login'}) {
           $windowname .= 'lti';
       }
   
     if ($env{'form.submiteval'} eq 'true') {      if ($env{'form.submiteval'} eq 'true') {
 # ------------------------------------------------ User is submitting something  # ------------------------------------------------ User is submitting something
Line 84  sub handler { Line 93  sub handler {
         }          }
         if ($complete) {          if ($complete) {
     my $showurl=&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($feedurl));      my $showurl=&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($feedurl));
     my $html=&Apache::lonxml::xmlbegin();              my $js = &Apache::lonhtmlcommon::scripttag(<<ENDJS);
     $r->print(<<ENDHEADER);  
 $html  
 <head>  
 <title>Evaluation submitted</title>  
 <script type="text/javascript">  
     function goback() {      function goback() {
  if ((window.name=='loncapaclient')) {          if ((window.name=='$windowname')) {
             window.location='$showurl';              window.location='$showurl';
         } else {          } else {
             self.close();              self.close();
         }          }
     }      }
 </script>  ENDJS
 <meta http-equiv="pragma" content="no-cache"></meta>  
 </head>              # Breadcrumbs
 $bodytag              my $brcrum = [{'href' => '/adm/evaluate',
 <h1>Thank you for your input!</h1>                             'text' => 'Evaluate Resource'},
 ENDHEADER                            {'href' => '',
        $r->print('Storing feedback: '.                             'text' => 'Done'}];
            &Apache::lonnet::put('nohist_resevaldata',\%currenteval,$rdomain,$rauth));  
               my $start_page = &Apache::loncommon::start_page('Evaluate Resource',
                                                               $js,
                                                               {'bread_crumbs' => $brcrum,});
   
               $r->print($start_page
                        .'<p class="LC_success">'
                        .&mt('Saving feedback: [_1]'
                             ,&Apache::lonnet::put(
                                  'nohist_resevaldata',\%currenteval,$rdomain,$rauth))
                        .'</p>'
               );
            unless ($already) {             unless ($already) {
        $r->print('<br />Logging first evaluation');                 $r->print('<p>'.&mt('Logging first evaluation').'</p>');
            }             }
            $r->print(             $r->print('<p><b>'.&mt('Thank you for your input!').'</b></p>'
             '<script type="text/javascript">setTimeout("goback()",2000);</script></body></html>');                      .&Apache::lonhtmlcommon::scripttag(
                           'setTimeout("goback()",2000);')
                       .&Apache::loncommon::end_page()
              );
            return OK;             return OK;
         } else {          } else {
     $warning='Please fill out all fields below';              $warning=&mt('Please fill out all required fields below!');
         }          }
         
     }      }
Line 134  ENDHEADER Line 152  ENDHEADER
        }                }       
     }      }
 # ------------------------------------------------------- Print out eval screen  # ------------------------------------------------------- Print out eval screen
     my $standardoptions=(<<ENDOPTIONS);      my %lt=&Apache::lonlocal::texthash('a' => 'Strongly Disagree',
          'b' => 'Disagree',
          'c' => 'Neutral',
          'd' => 'Agree',
          'e' => 'Strongly Agree',);
       my $standardoptions='';
       $standardoptions = (<<ENDOPTIONS);
 <option value="0">-</option>  <option value="0">-</option>
 <option value="1">Strongly Disagree</option>  <option value="1">$lt{'a'}</option>
 <option value="2">Disagree</option>  <option value="2">$lt{'b'}</option>
 <option value="3">Neutral</option>  <option value="3">$lt{'c'}</option>
 <option value="4">Agree</option>  <option value="4">$lt{'d'}</option>
 <option value="5">Strongly Agree</option>  <option value="5">$lt{'e'}</option>
 ENDOPTIONS  ENDOPTIONS
       
     my $html=&Apache::lonxml::xmlbegin();      # Breadcrumbs
     $r->print(<<ENDDOCUMENT);      my $brcrum = [{'href' => '/adm/evaluate',
 $html                     'text' => 'Evaluate Resource'}];
 <head>  
 <title>The LearningOnline Network with CAPA</title>      my $start_page = &Apache::loncommon::start_page('Evaluate Resource',
 </head>                                                      undef,
 $bodytag                                                      {'bread_crumbs' => $brcrum,});
 <tt>$title</tt><br /><br />      my $end_page   = &Apache::loncommon::end_page();
 <h3><font color="red">$warning</font></h3>  
 Please rank the following criteria:      %lt=&Apache::lonlocal::texthash(
 <form method="post" name="evaluation" action="/adm/evaluate">         'pleaserank' => 'Please rank the following criteria:',
 <input type="hidden" name="submiteval" value="true" />         'required'   => '(All fields marked with * are required.)',
 <input type="hidden" name="postdata" value="$showurl" />         'correct'    => 'The material appears to be correct',
 The material appears to be correct         'helpful'    => 'The material is helpful',
 <br /><select name="correct">         'depth'      => 'The material is covered with sufficient depth',
 $standardoptions         'clear'      => 'The material is presented in a clear way',
 </select>         'technical'  => 'The resource is technically correct (loads fast enough, does not produce errors, links work, etc)',
 <hr />         'comments'   => 'Comments',
 The material is helpful         'submit'     => 'Submit Evaluation',
 <br /><select name="helpful">      );
 $standardoptions      $r->print(
 </select>          $start_page
 <hr />         .'<h2>'.$title.'</h2>');
 The material is covered with sufficient depth  
 <br /><select name="depth">      if ($warning) {
 $standardoptions          $r->print(
 </select>              &Apache::loncommon::confirmwrapper(
 <hr />                  &Apache::lonhtmlcommon::confirm_success(
 The material is presented in a clear way              $warning,1)));
 <br /><select name="clear">      }
 $standardoptions      $r->print(
 </select>          '<form method="post" name="evaluation" action="/adm/evaluate">'
 <hr />         .'<input type="hidden" name="submiteval" value="true" />'
 The resource is technically correct          .'<input type="hidden" name="postdata" value="'.$showurl.'" />'
 (loads fast enough, does not produce errors, links work, etc)       );
 <br /><select name="technical">      $r->print(
 $standardoptions          &Apache::lonhtmlcommon::start_pick_box()
 </select>         .&Apache::lonhtmlcommon::row_headline()
 <hr />         .$lt{'pleaserank'}.'<br />'
 Any comments?         .'<span class="LC_info">'.$lt{'required'}.'</span>'
 <br /><textarea name="comments" cols="40" rows="5">$oldcomments</textarea>         .&Apache::lonhtmlcommon::row_closure()
 <script type="text/javascript">$dialold</script>      );
 <br /><input type="submit" value="Submit Evaluation" />  
 </form>      foreach my $key ('correct', 'helpful', 'depth', 'clear', 'technical') {
 </body>          $r->print(
 </html>              &Apache::lonhtmlcommon::row_title(
 ENDDOCUMENT                  '<span title="'.&mt('required').'">'.$lt{$key}
                  .' <span class="LC_info">*</span></span>')
              .'<select name="'.$key.'">'
              .$standardoptions
              .'</select>'
              .&Apache::lonhtmlcommon::row_closure()
           );
       }
   
       $r->print(
           &Apache::lonhtmlcommon::row_title($lt{'comments'})
          .'<textarea name="comments" cols="40" rows="5">'
          .$oldcomments
          .'</textarea>'
          .&Apache::lonhtmlcommon::row_closure(1)
          .&Apache::lonhtmlcommon::end_pick_box()
          .'<p>'
          .'<input type="submit" value="'.$lt{'submit'}.'" />'
          .'</p>'
       );
   
       $r->print(
           &Apache::lonhtmlcommon::scripttag($dialold)
          .'</form>'
          .$end_page
       );
   
     return OK;      return OK;
 }   } 
   
 1;  1;
 __END__  __END__
   
   =pod
   
   =head1 NAME
   
   Apache::lonevaluate.pm
   
   =head1 SYNOPSIS
   
   Handles evaluation.
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   =head1 OVERVIEW
   
   None
   
   =cut

Removed from v.1.18  
changed lines
  Added in v.1.31


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