File:  [LON-CAPA] / loncom / interface / statistics / longradinganalysis.pm
Revision 1.1: download - view: text, annotated - select for diffs
Tue Feb 14 16:05:46 2006 UTC (18 years, 4 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- adding a mode to do analysis of grading events for bridge tasks

    1: # The LearningOnline Network with CAPA
    2: #
    3: # $Id: longradinganalysis.pm,v 1.1 2006/02/14 16:05:46 albertel Exp $
    4: #
    5: # Copyright Michigan State University Board of Trustees
    6: #
    7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    8: #
    9: # LON-CAPA is free software; you can redistribute it and/or modify
   10: # it under the terms of the GNU General Public License as published by
   11: # the Free Software Foundation; either version 2 of the License, or
   12: # (at your option) any later version.
   13: #
   14: # LON-CAPA is distributed in the hope that it will be useful,
   15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17: # GNU General Public License for more details.
   18: #
   19: # You should have received a copy of the GNU General Public License
   20: # along with LON-CAPA; if not, write to the Free Software
   21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22: #
   23: # /home/httpd/html/adm/gpl.txt
   24: #
   25: # http://www.lon-capa.org/
   26: #
   27: package Apache::longradinganalysis;
   28: 
   29: use strict;
   30: use Apache::lonnet;
   31: use Apache::loncommon();
   32: use Apache::lonhtmlcommon();
   33: use Apache::loncoursedata();
   34: use Apache::lonstatistics;
   35: use Apache::lonlocal;
   36: use Apache::lonstathelpers();
   37: use Apache::lonstudentsubmissions();
   38: use HTML::Entities();
   39: use Time::Local();
   40: use Data::Dumper;
   41: 
   42: my @submit_buttons = ({ name => 'PrevProblemAnalysis',
   43: 			text => 'Previous Problem' },
   44: 		      { name => 'ProblemAnalysis',
   45: 			text => 'Analyze Problem Again' },
   46: 		      { name => 'NextProblemAnalysis',
   47: 			text => 'Next Problem' },
   48: 		      { name => 'break'},
   49: 		      { name => 'SelectAnother',
   50: 			text => 'Choose a different Problem' });
   51: 
   52: sub build_grading_analysis_page {
   53:     my ($r,$c)=@_;
   54:     #
   55:     my %saveable_parameters = ('Status' => 'scalar',
   56:                                'Section' => 'array',
   57:                                );
   58:     &Apache::loncommon::store_course_settings('grading_analysis',
   59:                                               \%saveable_parameters);
   60:     &Apache::loncommon::restore_course_settings('grading_analysis',
   61:                                                 \%saveable_parameters);
   62:     #
   63:     &Apache::lonstatistics::PrepareClasslist();
   64:     #
   65:     $r->print(&create_interface());
   66:     #
   67:     my @students = @Apache::lonstatistics::Students;
   68:     #
   69:     if (@students < 1 && exists($env{'form.firstrun'})) {
   70:         $r->print('<h2>There are no students in the sections selected</h2>');
   71:     }
   72:     #
   73:     #my @cache_button_HTML = 
   74:     #    &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
   75:     $r->rflush();
   76:     #
   77:     if (exists($env{'form.problemchoice'}) && 
   78:         ! exists($env{'form.SelectAnother'})) {
   79:         foreach my $button (@submit_buttons) {
   80:             if ($button->{'name'} eq 'break') {
   81:                 $r->print("<br />\n");
   82:             } else {
   83:                 $r->print('<input type="submit" name="'.$button->{'name'}.'" '.
   84:                           'value="'.&mt($button->{'text'}).'" />');
   85:                 $r->print('&nbsp;'x5);
   86:             }
   87:         }
   88: #        foreach my $html (@cache_button_HTML) {
   89: #            $r->print($html.('&nbsp;'x5));
   90: #        }
   91:         #
   92:         #$r->print(&Apache::lonstathelpers::submission_report_form('grading_analysis'));
   93:         #
   94:         $r->print('<hr />');
   95:         $r->rflush();
   96:         #
   97:         # Determine which problem we are to analyze
   98:         my $current_problem = &Apache::lonstathelpers::get_target_from_id
   99:             ($env{'form.problemchoice'});
  100:         #
  101:         my ($navmap,$prev,$curr,$next) = 
  102:             &Apache::lonstathelpers::get_prev_curr_next($current_problem,
  103: 							undef,
  104:                                                         'part_task',
  105:                                                         );
  106:         if (exists($env{'form.PrevProblemAnalysis'}) && defined($prev)) {
  107:             $current_problem = $prev;
  108:         } elsif (exists($env{'form.NextProblemAnalysis'}) && defined($next)) {
  109:             $current_problem = $next;
  110:         } else {
  111:             $current_problem = $curr;
  112:         }
  113:         #
  114:         # Store the current problem choice and send it out in the form
  115:         $env{'form.problemchoice'} = 
  116:             &Apache::lonstathelpers::make_target_id($current_problem);
  117:         $r->print('<input type="hidden" name="problemchoice" value="'.
  118:                   $env{'form.problemchoice'}.'" />');
  119:         #
  120: 	if (! defined($current_problem->{'resource'})) {
  121:             $r->print('resource is undefined');
  122:         } else {
  123:             my $resource = $current_problem->{'resource'};
  124:             $r->print('<h1>'.$resource->compTitle.'</h1>');
  125:             $r->print('<h3>'.$resource->src.'</h3>');
  126:             $r->print('<h4>'.&Apache::lonstatistics::section_and_enrollment_description().'</h4>');
  127:             $r->rflush();
  128:             if ($resource->is_task()) {
  129: 		&task_analysis($r,$resource,\@students);
  130:             } else {
  131:                 $r->print('<h2>Analysis of '.$resource->src().' is not supported</h2>');
  132:             }
  133:         }
  134:         $r->print('<hr />');
  135:     } else {
  136:         my $submit_button = '<input type="submit" '.
  137:             'name="ProblemAnalysis" value="'.
  138:             &mt('Analyze Problem').'" />';
  139:         $r->print($submit_button);
  140:         $r->print('&nbsp;'x5);
  141:         $r->print('<h3>'.&mt('Please select a problem to analyze').'</h3>');
  142:         #FIXME need a task only selector.
  143:         $r->print(&Apache::lonstathelpers::problem_selector('.',
  144:                                                             $submit_button));
  145:     }
  146: }
  147: 
  148: sub task_analysis {
  149:     my ($r,$problem,$students) = @_;
  150:     my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
  151:         ($r,'Student Answer Compilation Status',
  152:          'Student Answer Compilation Progress', scalar(@$students),
  153:          'inline',undef,'Statistics','stats_status');
  154:     my %graders;
  155:     foreach my $student (@$students) {
  156: 	my $sname = $student->{'username'};
  157:         my $sdom = $student->{'domain'};
  158: 	my %data =  &Apache::lonnet::restore($problem->symb(),
  159: 					     $env{'request.course.id'},
  160: 					     $sdom,$sname);
  161: 	foreach my $ver (0..$data{'version'}) {
  162: 	    if (exists($data{"$ver:resource.0.regrader"})
  163: 		&& $data{"$ver:resource.0.regrader"} =~ /\S/) {
  164: 		$graders{$data{"$ver:resource.0.regrader"}}++;
  165: 	    }
  166: 	}
  167: 	&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
  168:                                                  &mt('last student'));
  169: 
  170:     }
  171:     if ($env{'form.output'} eq 'csv') {
  172:     } elsif ($env{'form.output'} eq 'excel') {
  173:     } else {
  174: 	$r->print('<table class="thinborder">');
  175: 	foreach my $grader (sort(keys(%graders))) {
  176: 	    my ($gname,$gdom) = split('@',$grader,2);
  177: 	    my $name = &Apache::loncommon::plainname($gname,$gdom);
  178: 	    my $link = &Apache::loncommon::aboutmewrapper($name,$gname,$gdom);
  179: 	    $r->print("<tr><td>$link (<tt>$grader</tt>)</td><td>$graders{$grader}</td></tr>");
  180: 	}
  181: 	$r->print('</table>');
  182:     }
  183:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
  184: }
  185: 
  186: #########################################################
  187: #########################################################
  188: ##
  189: ##   Generic Interface Routines
  190: ##
  191: #########################################################
  192: #########################################################
  193: sub create_interface {
  194:     ##
  195:     ## Build the menu
  196:     my $output_selector = $/.'<select name="output">'.$/;
  197:     foreach ('HTML','Excel','CSV') {
  198:         $output_selector .= '    <option value="'.lc($_).'"';
  199:         if ($env{'form.output'} eq lc($_)) {
  200:             $output_selector .= ' selected ';
  201:         }
  202:         $output_selector .='>'.&mt($_).'</option>'.$/;
  203:     } 
  204:     $output_selector .= '</select>'.$/;
  205: 
  206:     my $str = '';
  207:     $str .= &Apache::lonhtmlcommon::breadcrumbs
  208:         (undef,'Detailed Grading Statistics');
  209:     $str .= '<table cellspacing="5">'."\n";
  210:     $str .= '<tr>';
  211:     $str .= '<td align="center"><b>'.&mt('Sections').'</b></td>';
  212:     $str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>';
  213:     $str .= '<td>'.&mt('<b>Output as</b> [_1]',$output_selector).'</td>';
  214:     $str .= '</tr>'."\n";
  215:     ##
  216:     ## 
  217:     $str .= '<tr><td align="center">'."\n";
  218:     $str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
  219:     $str .= '</td>';
  220:     #
  221:     $str .= '<td align="center">';
  222:     $str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
  223:     $str .= '</td>';
  224:     #
  225:     $str .= '<td>';
  226:     ##
  227:     $str .= '<nobr><label>'.&mt('Status: [_1]',
  228:                                  '<input type="text" '.
  229:                                  'name="stats_status" size="60" value="" />'
  230:                                  ).
  231:                     '</label></nobr>';
  232:     $str .= '</td>';
  233:     ##
  234:     ##
  235:     $str .= '</tr>'."\n";
  236:     $str .= '</table>'."\n";
  237:     return $str;
  238: }
  239: 
  240: 1;
  241: 
  242: __END__

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