Annotation of loncom/interface/statistics/longradinganalysis.pm, revision 1.2

1.1       albertel    1: # The LearningOnline Network with CAPA
                      2: #
1.2     ! albertel    3: # $Id: longradinganalysis.pm,v 1.1 2006/02/14 16:05:46 albertel Exp $
1.1       albertel    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);
1.2     ! albertel  161: 	my $last_grader;
1.1       albertel  162: 	foreach my $ver (0..$data{'version'}) {
                    163: 	    if (exists($data{"$ver:resource.0.regrader"})
                    164: 		&& $data{"$ver:resource.0.regrader"} =~ /\S/) {
1.2     ! albertel  165: 		$last_grader=$data{"$ver:resource.0.regrader"};
1.1       albertel  166: 	    }
1.2     ! albertel  167: 	    if (exists($data{"$ver:resource.0.version"})
        !           168: 		&& $last_grader =~ /\S/) {
        !           169: 		$graders{$last_grader}++;
        !           170: 	    }
        !           171: 	}
        !           172: 	if ($last_grader =~ /\S/) {
        !           173: 	    $graders{$last_grader}++;
1.1       albertel  174: 	}
1.2     ! albertel  175: 
1.1       albertel  176: 	&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
                    177:                                                  &mt('last student'));
                    178: 
                    179:     }
                    180:     if ($env{'form.output'} eq 'csv') {
                    181:     } elsif ($env{'form.output'} eq 'excel') {
                    182:     } else {
                    183: 	$r->print('<table class="thinborder">');
                    184: 	foreach my $grader (sort(keys(%graders))) {
                    185: 	    my ($gname,$gdom) = split('@',$grader,2);
                    186: 	    my $name = &Apache::loncommon::plainname($gname,$gdom);
                    187: 	    my $link = &Apache::loncommon::aboutmewrapper($name,$gname,$gdom);
                    188: 	    $r->print("<tr><td>$link (<tt>$grader</tt>)</td><td>$graders{$grader}</td></tr>");
                    189: 	}
                    190: 	$r->print('</table>');
                    191:     }
                    192:     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
                    193: }
                    194: 
                    195: #########################################################
                    196: #########################################################
                    197: ##
                    198: ##   Generic Interface Routines
                    199: ##
                    200: #########################################################
                    201: #########################################################
                    202: sub create_interface {
                    203:     ##
                    204:     ## Build the menu
                    205:     my $output_selector = $/.'<select name="output">'.$/;
                    206:     foreach ('HTML','Excel','CSV') {
                    207:         $output_selector .= '    <option value="'.lc($_).'"';
                    208:         if ($env{'form.output'} eq lc($_)) {
                    209:             $output_selector .= ' selected ';
                    210:         }
                    211:         $output_selector .='>'.&mt($_).'</option>'.$/;
                    212:     } 
                    213:     $output_selector .= '</select>'.$/;
                    214: 
                    215:     my $str = '';
                    216:     $str .= &Apache::lonhtmlcommon::breadcrumbs
                    217:         (undef,'Detailed Grading Statistics');
                    218:     $str .= '<table cellspacing="5">'."\n";
                    219:     $str .= '<tr>';
                    220:     $str .= '<td align="center"><b>'.&mt('Sections').'</b></td>';
                    221:     $str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>';
                    222:     $str .= '<td>'.&mt('<b>Output as</b> [_1]',$output_selector).'</td>';
                    223:     $str .= '</tr>'."\n";
                    224:     ##
                    225:     ## 
                    226:     $str .= '<tr><td align="center">'."\n";
                    227:     $str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
                    228:     $str .= '</td>';
                    229:     #
                    230:     $str .= '<td align="center">';
                    231:     $str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
                    232:     $str .= '</td>';
                    233:     #
                    234:     $str .= '<td>';
                    235:     ##
                    236:     $str .= '<nobr><label>'.&mt('Status: [_1]',
                    237:                                  '<input type="text" '.
                    238:                                  'name="stats_status" size="60" value="" />'
                    239:                                  ).
                    240:                     '</label></nobr>';
                    241:     $str .= '</td>';
                    242:     ##
                    243:     ##
                    244:     $str .= '</tr>'."\n";
                    245:     $str .= '</table>'."\n";
                    246:     return $str;
                    247: }
                    248: 
                    249: 1;
                    250: 
                    251: __END__

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