--- loncom/interface/lonstatistics.pm 2002/07/19 18:17:34 1.28 +++ loncom/interface/lonstatistics.pm 2009/12/11 00:12:21 1.144.2.1 @@ -1,7 +1,6 @@ # The LearningOnline Network with CAPA -# (Publication Handler # -# $Id: lonstatistics.pm,v 1.28 2002/07/19 18:17:34 minaeibi Exp $ +# $Id: lonstatistics.pm,v 1.144.2.1 2009/12/11 00:12:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,2142 +25,1153 @@ # http://www.lon-capa.org/ # # (Navigate problems for statistical reports -# YEAR=2001 -# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei -# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei -# YEAR=2002 -# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei -# 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei # ### -package Apache::lonstatistics; -use strict; -use Apache::Constants qw(:common :http); -use Apache::lonnet(); -use Apache::lonhomework; -use Apache::loncommon; -use HTML::TokeParser; -use GDBM_File; -# -------------------------------------------------------------- Module Globals -my %hash; -my %CachData; -my %GraphDat; -my $r; -my $GData; -my %color; -my %foil_to_concept; -my @Concepts; -my %ConceptData; -my %Answer=(); -my %mapsort; - -my %Activity=(); -my %Grade=(); -my %DoDiff=(); -my %Discuss=(); -my $TotalDiscuss=0; -my $TotalDiscuss_=0; - - -sub LoadDiscussion { -# my $symb=shift; -# $r->print('
$cid ... '.$symb); -# my %contrib=&Apache::lonnet::dump('msu_2964385f9033c63msul1','msu','2964385f9033c63msul1'); - my $cid=$ENV{'request.course.id'}; - my %contrib=&Apache::lonnet::dump( - $ENV{'request.course.id'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); - - foreach my $temp(keys %contrib) { - if ($temp=~/^version/) { - my $ver=$contrib{$temp}; - my ($dummy,$prb)=split(':',$temp); - for (my $idx=1; $idx<=$ver; $idx++ ) { - my $name=$contrib{"$idx:$prb:sendername"}; - $Discuss{"$name:$prb"}=$idx; - } - } - } -# $r->print('
cid='.$cid); -# my %contrib=&Apache::lonnet::restore($symb,$cid, -# $ENV{$cid.'.domain'}, -# $ENV{'course.'.$cid.'.num'}); - -# $Apache::lonxml::debug=1; -# &Apache::lonhomework::showhash(%Discuss); -# $Apache::lonxml::debug=0; -} +package Apache::lonstatistics; -sub LoadDoDiffFile { - my $file="/home/minaeibi/183d.txt"; - open(FILEID, "<$file"); - my $line=; - %DoDiff=(); - my @Act=split('&',$line); - -# $r->print('
'.$#Act); - for(my $n=0;$n<=$#Act;$n++){ - my ($res,$Degree)=split('@',$Act[$n]); - $DoDiff{$res}=$Degree; - } -} +use strict; +use Apache::Constants qw(:common :http); +use vars qw( + @FullClasslist + @Students + @Sections + @Groups + %StudentData + @StudentDataOrder + @SelectedStudentData + $enrollment_status); +use Apache::lonnet; +use Apache::lonhomework; +use Apache::loncommon; +use Apache::loncoursedata; +use Apache::lonhtmlcommon; +use Apache::lonmysql; +use Apache::lonlocal; +use Apache::longroup; +use Time::HiRes; +# +# Statistics Packages +use Apache::lonproblemanalysis(); +use Apache::lonsubmissiontimeanalysis(); +use Apache::loncorrectproblemplot(); +use Apache::lonproblemstatistics(); +use Apache::lonstudentassessment(); +use Apache::lonpercentage; +use Apache::lonstudentsubmissions(); +use Apache::lonsurveyreports(); +use Apache::longradinganalysis(); +use LONCAPA; -sub LoadClassFile { - my $file="/home/minaeibi/class.txt"; - open(FILEID, "<$file"); - my $line; - %Grade=(); - while ($line=) { - my ($id,$ex1,$ex2,$ex3,$ex4,$hw,$final,$grade)=split(' ',$line); - $Grade{$id}=$grade; +# +# Classlist variables +# +my $curr_student; +my $prev_student; +my $next_student; + + +sub clear_classlist_variables { + undef(@FullClasslist); + undef(@Students); + undef(@Sections); + undef(@Groups); + undef(%StudentData); + undef(@SelectedStudentData); + undef($curr_student); + undef($prev_student); + undef($next_student); +} + + +sub PrepareClasslist { + my %Sections; + &clear_classlist_variables(); + # + # Retrieve the classlist + my $cid = $env{'request.course.id'}; + my $cdom = $env{'course.'.$cid.'.domain'}; + my $cnum = $env{'course.'.$cid.'.num'}; + my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cdom, + $cnum); + my @selected_sections = &get_selected_sections(); + my @selected_groups = &get_selected_groups(); + # + # Deal with instructors with restricted section access + if ($env{'request.course.sec'} !~ /^\s*$/) { + @selected_sections = ($env{'request.course.sec'}); + } + # + # Set up %StudentData + @StudentDataOrder = qw/fullname username domain id section status groups comments/; + foreach my $field (@StudentDataOrder) { + $StudentData{$field}->{'title'} = &mt($field); + $StudentData{$field}->{'base_width'} = length(&mt($field)); + $StudentData{$field}->{'width'} = + $StudentData{$field}->{'base_width'}; + } + # + # get the status requested + $enrollment_status = 'Active'; + $enrollment_status = $env{'form.Status'} if (exists($env{'form.Status'})); + # + # Get groupmembership + my ($classgroups,$studentgroups); + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); + if (%curr_groups) { + ($classgroups,$studentgroups) = + &Apache::loncoursedata::get_group_memberships($classlist, + $field_names, + $cdom,$cnum); + } + my $now = time; + + # Process the classlist + while (my ($student,$student_data) = each (%$classlist)) { + my $studenthash = (); + for (my $i=0; $i< scalar(@$field_names);$i++) { + my $field = $field_names->[$i]; + # Store the data + $studenthash->{$field}=$student_data->[$i]; + # Keep track of the width of the fields + next if (! exists($StudentData{$field})); + my $length = length($student_data->[$i]); + if ($StudentData{$field}->{'width'} < $length) { + $StudentData{$field}->{'width'} = $length; + } + } + my @studentsgroups = &Apache::loncoursedata::get_students_groups + ($student,$enrollment_status, + $classgroups); + if (@studentsgroups) { + $studenthash->{'groups'} = join(', ',@studentsgroups); + $studenthash->{'groupref'} = \@studentsgroups; + } else { + $studenthash->{'groups'} = 'none'; + $studenthash->{'groupref'} = []; + } + push (@FullClasslist,$studenthash); + # + # Build up a list of sections + my $section = $studenthash->{'section'}; + if (! defined($section) || $section =~/^\s*$/ || $section == -1) { + $studenthash->{'section'} = 'none'; + $section = $studenthash->{'section'}; + } + $Sections{$section}++; + # + # Only put in the list those students we are interested in + foreach my $sect (@selected_sections) { + if ( (($sect eq 'all') || + ($section eq $sect)) && + (($studenthash->{'status'} eq $enrollment_status) || + ($enrollment_status eq 'Any')) + ){ + my $groupcheck = 0; + if (grep(/^all$/,@selected_groups)) { + push(@Students,$studenthash); + last; + } elsif (grep(/^none$/,@selected_groups)) { + if ($studenthash->{'groups'} eq 'none') { + push(@Students,$studenthash); + last; + } + } else { + foreach my $group (@selected_groups) { + if (grep(/^$group$/,@studentsgroups)) { + push(@Students,$studenthash); + $groupcheck = 1; + last; + } + } + if ($groupcheck) { + last; + } + } + } + } } -} - - -#------- Classification -sub Classify { - my ($DiscFac, $students)=@_; - &LoadClassFile(); - my $Count=0; - my @List=(); - my @LS=(); - my @LF=(); - my @LM=(); - my $cf=0; - my $cs=0; - my $cm=0; - foreach (keys(%$DiscFac)){ - my @l=split(/\:/,$_); - if (!($students->{$l[1]})) {next;} - my $Grade=$Grade{$students->{$l[1]}}; - if( $Grade > 3 ) { - $cs++; - push(@LS,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Successful")); - } elsif ( $Grade > 2 ) { - $cm++; - push(@LM,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Average")); - } else { - $cf++; - push(@LF,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Failed")); - } - } - for(my $n=0;$n<$cs;$n++){$r->print('
'.$LS[$n]);} - for(my $n=0;$n<$cm;$n++){$r->print('
'.$LM[$n]);} - for(my $n=0;$n<$cf;$n++){$r->print('
'.$LF[$n]);} -} - - -sub ProcAct { - # return; - my ($Act,$Submit)=@_; - my @Act=split(/\@/,$Act); - @Act = sort(@Act); - - ##$r->print('
'.$#Act); - ##for(my $n=0;$n<=$#Act;$n++){ -## $r->print('
n='.$n.')'.$Act[$n]); -## } - -# my $Beg=$Act[0]; - my $Dif=$Submit-$Act[0]; - $Dif = ($Dif>0) ? ($Dif/3600) : 0; - -# $r->print('
Access Number = '.$#Act.'
Submit Time='.$Submit.'
First Access='.$Act[0].'
Last Access='.$Act[$#Act].'
Submit - First = '.$Dif.''); - - -#time spent for solving the problem -# $r->print('
Def'.($Act[$#Act-1]-$Act[0])); - - return $Dif; -} - - - -sub LoadActivityLog { -# my $CacheDB = "/home/minaeibi/act183.log.cache"; - my $CacheDB = "/home/httpd/perl/tmp/act183.log.cache"; - - if (-e "$CacheDB") { - if (tie(%Activity,'GDBM_File',"$CacheDB",&GDBM_READER,0640)) { - return; - } - else { - $r->print("Unable to tie log Cache hash to db file"); + # + # Put the consolidated section data in the right place + if ($env{'request.course.sec'} !~ /^\s*$/) { + @Sections = ($env{'request.course.sec'}); + } else { + @Sections = sort { + if ($a == $a && $b == $b ) { return $a <=> $b; } + return $a cmp $b; + } keys(%Sections); + + unshift(@Sections,'all'); # Put 'all' at the front of the list + } + # Sort the groups + @Groups = sort {$a cmp $b} keys(%{$studentgroups}); + unshift(@Groups,'all'); # Put 'all' at the front of the list + + # + # Sort the Students + my $sortby = 'fullname'; + $sortby = $env{'form.sort'} if (exists($env{'form.sort'})); + my @TmpStudents = sort { lc($a->{$sortby}) cmp lc($b->{$sortby}) || + lc($a->{'fullname'}) cmp lc($b->{'fullname'}) || + lc($a->{'username'}) cmp lc($b->{'username'}) } @Students; + @Students = @TmpStudents; + # + # Now deal with that current student thing.... + $curr_student = undef; + if (exists($env{'form.SelectedStudent'})) { + my ($current_uname,$current_dom) = + split(':',$env{'form.SelectedStudent'}); + my $i; + for ($i = 0; $i<=$#Students; $i++) { + next if (($Students[$i]->{'username'} ne $current_uname) || + ($Students[$i]->{'domain'} ne $current_dom)); + $curr_student = $Students[$i]; + last; # If we get here, we have our student. + } + if (defined($curr_student)) { + if ($i == 0) { + $prev_student = undef; + } else { + $prev_student = $Students[$i-1]; + } + if ($i == $#Students) { + $next_student = undef; + } else { + $next_student = $Students[$i+1]; + } } } - else { - if (tie(%Activity,'GDBM_File',$CacheDB,&GDBM_WRCREAT,0640)) { - foreach (keys %Activity) {delete $Activity{$_};} - &Build_log(); - } - else { - $r->print("Unable to tie log Build hash to db file"); + # + if (exists($env{'form.StudentData'})) { + @SelectedStudentData = + &Apache::loncommon::get_env_multiple('form.StudentData'); + } else { + @SelectedStudentData = ('username'); + } + foreach (@SelectedStudentData) { + if ($_ eq 'all') { + @SelectedStudentData = ('all'); + last; } } + # + return; } -sub Build_log { - my $file="/home/minaeibi/act183.log"; - open(FILEID, "<$file"); - my $line; - my $count=0; - while ($line=) { - my ($time,$machine,$what)=split(':',$line); - $what=&Apache::lonnet::unescape($what); - my @accesses=split('&',$what); - - foreach my $access (@accesses) { - - $count++; - - my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); - if (!$resource) { next; } - my $res=&Apache::lonnet::unescape($resource); - if (($res =~ /\.problem/)) { - $Activity{$who.':'.$res}.=$date.'@'; - #$r->print('
'.$time.':'.$who.'---'.$res); - &Update_PrgInit($count); - - } - } - } - -# my $c=1; -# foreach (sort keys %Activity) { -# $r->print('
'.$c.')'.$_.' ... '.$Activity{$_}); -# $c++; -# } -} - -sub Activity { -# $rid=~/(\d+)\.(\d+)/; -# my $MapId=$1; -# my $PrbId=$2; -# my $MapOrg = $hash{'map_id_'.$MapId}; -# my $Map = &Apache::lonnet::declutter($MapOrg); -# my $URI = $hash{'src_'.$rid}; -# my $Symb = $Map.'___'.$PrbId.'___'.&Apache::lonnet::declutter($URI); - my $file="/home/minaeibi/activity.log"; - my $userid='adamsde1'; - $r->print("
Using $file"); - $r->rflush(); - open(FILEID, "<$file"); - my $line; - my @allaccess; - my $Count=0; - while ($line=) { - my ($time,$machine,$what)=split(':',$line); - $what=&Apache::lonnet::unescape($what); - my @accesses=split('&',$what); - foreach my $access (@accesses) { - my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); - #if ($who ne $userid) { next; } - if (!$resource) { next; } - my $res=&Apache::lonnet::unescape($resource); - if (($res =~ /\.(sequence|problem|htm|html|page)/)) { - $Count++; - $r->print("
$Count) ".localtime($date).": $who --> $res"); -# if ($post) { -# $Count++; -# $r->print("
$Count) Sent data ".join(':', -# &Apache::lonnet::unescape(@posts)).''); -# } - $r->rflush(); - } - #push (@allaccess,unescape($access)); - #print $machine; - } - } -# @allaccess=sort(@allaccess); -# $Count=0; -# foreach my $access (@allaccess) { -# my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); -# $Count++; -# $r->print("
$Count) $date: $who --> $resource"); -# $r->rflush(); -# if ($post) { -# $r->print("
Sent data ".join(':',unescape(@posts)).''); -# } -# } +sub get_selected_sections { + my @selected_sections = + &Apache::loncommon::get_env_multiple('form.Section'); + @selected_sections = ('all') if (! @selected_sections); + foreach (@selected_sections) { + if ($_ eq 'all') { + @selected_sections = ('all'); + } + } + # + # Deal with instructors with restricted section access + if ($env{'request.course.sec'} !~ /^\s*$/) { + @selected_sections = ($env{'request.course.sec'}); + } + return @selected_sections; } -sub InitAnalysis { - my ($uri,$part,$problem,$student,$courseID)=@_; - my ($uname,$udom)=split(/\:/,$student); - - - # Render the student's view of the problem. $Answ is the problem - # Stringafied - my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze', - 'grade_username' => $uname, - 'grade_domain' => $udom, - 'grade_courseid' => $courseID, - 'grade_symb' => $problem)); -# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze')); - -# (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2); - %Answer=(); - %Answer=&Apache::lonnet::str2hash($Answ); - - my $parts=''; - foreach my $elm (@{$Answer{"parts"}}) { - $parts.="$elm,"; - } - chop($parts); - my $conc=''; - foreach my $elm (@{$Answer{"$parts.concepts"}}) { - $conc.="$elm@"; - } - chop($conc); - - @Concepts=split(/\@/,$conc); - foreach my $concept (@{$Answer{"$parts.concepts"}}) { - foreach my $foil (@{$Answer{"$parts.concept.$concept"}}) { - $foil_to_concept{$foil} = $concept; - #$ConceptData{$foil} = $Answer{"$parts.foil.value.$foil"}; - } +sub get_selected_groups { + my @selected_groups = + &Apache::loncommon::get_env_multiple('form.Group'); + @selected_groups = ('all') if (! @selected_groups); + foreach my $grp (@selected_groups) { + if ($grp eq 'all') { + @selected_groups = ('all'); + last; + } } - - return; + return @selected_groups; } + -sub Interval { - my ($part,$symb)=@_; - my $Int=$ConceptData{"Interval"}; - my $due = &Apache::lonnet::EXT('resource.$part.duedate',$symb)+1; - my $opn = &Apache::lonnet::EXT('resource.$part.opendate',$symb); - my $add=int(($due-$opn)/$Int); - $ConceptData{"Int.0"}=$opn; - for (my $i=1;$i<$Int;$i++) { - $ConceptData{"Int.$i"}=$opn+$i*$add; - } - $ConceptData{"Int.$Int"}=$due; - for (my $i=0;$i<$Int;$i++) { - for (my $n=0; $n<=$#Concepts; $n++ ) { - my $tmp=$Concepts[$n]; - $ConceptData{"$tmp.$i.true"}=0; - $ConceptData{"$tmp.$i.false"}=0; - } +sub section_and_enrollment_description { + my ($mode) = @_; + if (! defined($mode)) { $mode = 'localized'; } + my @sections = &Apache::lonstatistics::get_selected_sections(); + my @groups = &Apache::lonstatistics::get_selected_groups(); + my $description; + if ($mode eq 'localized') { + $description = &mt('Unable to determine section, groups and access status'); + } elsif ($mode eq 'plaintext') { + $description = 'Unable to determine section, groups and access status'; + } else { + $description = 'Bad parameter passed to lonstatistics::section_and_enrollment_description'; + &Apache::lonnet::logthis($description); + } + $description = §ion_or_group_text($mode,'section',@sections). + ' '.§ion_or_group_text($mode,'group',@groups); + if ($mode eq 'localized') { + $description .= ' '.&mt($env{'form.Status'}.' access status.'); + } elsif ($mode eq 'plaintext') { + $description .= ' '.$env{'form.Status'}.' access status.'; } + return $description; } -sub ShowOpGraph { - my ($cache, $students, $courseID)=@_; - my $uri = $cache->{'AnalyzeURI'}; - my $part = $cache->{'AnalyzePart'}; - my $problem = $cache->{'AnalyzeProblem'}; - my $title = $cache->{'AnalyzeTitle'}; - my $interval = $cache->{'Interval'}; - $ConceptData{"Interval"} = $interval; - #Initialize the option response true answers - &InitAnalysis($uri, $part, $problem, $students->[0],$courseID); - #compute the intervals - &Interval($part,$problem); +sub section_or_group_text { + my ($mode,$type,@items) = @_; + my $text; + my %phrases = (); + %{$phrases{'section'}} = ( + single => 'Section', + all => 'All sections', + plural => 'Sections', + ); + %{$phrases{'group'}} = ( + single => 'Group', + all => 'All groups', + plural => 'Groups', + ); + if (scalar(@items) == 1 && $items[0] ne 'all') { + if ($mode eq 'localized') { + $text = &mt($phrases{$type}{single}.' [_1].',$items[0]); + } elsif ($mode eq 'plaintext') { + $text = $phrases{$type}{single}.' '.$items[0].'.'; - $title =~ s/\ /"_"/eg; - $r->print('
'.$uri.''); - $r->rflush(); - - #Java script Progress window - &Create_PrgWin(); - &Update_PrgWin("Starting-to-analyze-problem"); - for (my $index=0;$index<(scalar @$students);$index++) { - &Update_PrgWin($index); - &OpStatus($problem,$students->[$index],$courseID); - } - &Close_PrgWin(); - - $r->print('
'); - for (my $k=0; $k<$interval; $k++ ) { - &DrawGraph($k,$title); - } - for (my $k=0; $k<$interval; $k++ ) { - &DrawTable($k); - } -#$Apache::lonxml::debug=1; -#&Apache::lonhomework::showhash(%ConceptData); -#$Apache::lonxml::debug=0; - my $Answ=&Apache::lonnet::ssi($uri); - $r->print("
Here you can see the Problem:
$Answ"); + } + } elsif (scalar(@items) && $items[0] eq 'all') { + if ($mode eq 'localized') { + $text = &mt($phrases{$type}{all}.'.'); + } elsif ($mode eq 'plaintext') { + $text = $phrases{$type}{all}.'.'; + } + } elsif (scalar(@items)) { + my $lastitem = pop(@items); + if ($mode eq 'localized') { + $text = &mt($phrases{$type}{plural}.' [_1] and [_2].', + join(', ',@items),$lastitem); + } elsif ($mode eq 'plaintext') { + $text = $phrases{$type}{plural}.' '.join(', ',@items).' and '. + $lastitem.'.'; + } + } + return $text; } -sub DrawTable { - my $k=shift; - my $Max=0; - my @data1; - my @data2; - my $Correct=0; - my $Wrong=0; - for (my $n=0; $n<=$#Concepts; $n++ ) { - my $tmp=$Concepts[$n]; - $data1[$n]=$ConceptData{"$tmp.$k.true"}; - $Correct+=$data1[$n]; - $data2[$n]=$ConceptData{"$tmp.$k.false"}; - $Wrong+=$data2[$n]; - my $Sum=$data1[$n]+$data2[$n]; - if ( $Max<$Sum ) {$Max=$Sum;} - } - for (my $n=0; $n<=$#Concepts; $n++ ) { - if ($data1[$n]+$data2[$n]<$Max) { - $data2[$n]+=$Max-($data1[$n]+$data2[$n]); - } +sub get_students { + if (! @Students) { + &PrepareClasslist() } - my $P_No = $#data1+1; -# $r->print('
From: ['.localtime($ConceptData{'Int.'.($k-1)}). -# '] To: ['.localtime($ConceptData{"Int.$k"}).']'); - my $Str = "\n".''. - "\n".''. - "\n".''. - "\n".''. - "\n".''. - "\n".''. - "\n".''; - - for (my $n=0; $n<=$#Concepts; $n++ ) { - $Str .= "\n"."". - "\n"."". - "\n".'". - "\n".'". - "\n".'". - "\n".""; - } - $Str.='"; - - $Str .= "\n".'
# Concept Correct Wrong
".($n+1)." '.$Concepts[$n]." '.$data1[$n]." '.$data2[$n]."
From:['.localtime($ConceptData{'Int.'.$k}). - '] To: ['.localtime($ConceptData{'Int.'.($k+1)}-1). - "]$Correct$Wrong
'; - - $r->print($Str); -#$Apache::lonxml::debug=1; -#&Apache::lonhomework::showhash(%ConceptData); -#$Apache::lonxml::debug=0; + return @Students; } -sub DrawGraph { - my ($k,$Src)=@_; - my $Max=0; - my @data1; - my @data2; - - # Adjust Data and find the Max - for (my $n=0; $n<=$#Concepts; $n++ ) { - my $tmp=$Concepts[$n]; - $data1[$n]=$ConceptData{"$tmp.$k.true"}; - $data2[$n]=$ConceptData{"$tmp.$k.false"}; - my $Sum=$data1[$n]+$data2[$n]; - if ( $Max<$Sum ) {$Max=$Sum;} - } - for (my $n=0; $n<=$#Concepts; $n++ ) { - if ($data1[$n]+$data2[$n]<$Max) { - $data2[$n]+=$Max-($data1[$n]+$data2[$n]); - } - } - my $P_No = $#data1+1; - - if ( $Max > 1 ) { - $Max += (10 - $Max % 10); - $Max = int($Max); - } else { $Max = 1; } - - my $Titr=($ConceptData{'Interval'}>1) ? $Src.'_interval_'.($k+1) : $Src; -# $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2; - $GData="$Titr&Concepts&Answers&$Max&$P_No&". - (join(',',@data1)).'&'.(join(',',@data2)); - $r->print(''); +sub current_student { + return $curr_student; } -sub Decide { - #deciding the true or false answer belongs to each interval - my ($type,$foil,$time)=@_; - my $k=0; - while ($time>$ConceptData{'Int.'.($k+1)} && - $k<$ConceptData{'Interval'}) {$k++;} - $ConceptData{"$foil_to_concept{$foil}.$k.$type"}++; -} -#restore the student submissions and finding the result -sub OpStatus { - my ($problem, $student, $courseID)=@_; - my ($username,$userdomain)=split(/':'/,$student); - my $code='U'; - my %reshash=&Apache::lonnet::restore($problem, $courseID, $userdomain, - $username); - my @True = (); - my @False = (); - my $flag=0; - if ($reshash{'version'}) { - my $tries=0; - &Apache::lonhomework::showhash(%Answer); - for (my $version=1;$version<=$reshash{'version'};$version++) { - my $time=$reshash{"$version:timestamp"}; - - foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) { - if (($key=~/\.(\w+)\.(\w+)\.submission$/)) { - my $Id1 = $1; my $Id2 = $2; - #check if this is a repeat submission, if so skip it - if ($reshash{"$version:resource.$Id1.previous"}) { next; } - #if no solved this wasn't a real submission, ignore it - if (!defined($reshash{"$version:resource.$Id1.solved"})) { - &Apache::lonxml::debug("skipping "); - next; - } - my $Resp = $reshash{"$version:$key"}; - my %submission=&Apache::lonnet::str2hash($Resp); - foreach (keys %submission) { - my $Ansr = $Answer{"$Id1.$Id2.foil.value.$_"}; - if ($submission{$_}) { - if ($submission{$_} eq $Ansr) { - &Decide("true",$_,$time ); - } - else {&Decide("false",$_,$time );} - } - } - } - } - } - } +sub previous_student { + return $prev_student; } -#---- END Analyze Web Page ---------------------------------------------- -#---- Problem Statistics Web Page --------------------------------------- - -#------- Processing upperlist and lowerlist according to each problem -sub ProcessDiscriminant { - my ($List) = @_; - my @sortedList = sort (@$List); - my $Count = scalar @sortedList; - my $Problem; - my @Dis; - my $Slvd=0; - my $tmp; - my $Sum1=0; - my $Sum2=0; - my $nIndex=0; - my $nStudent=0; - my %Proc=undef; - while ($nIndex<$Count) { - ($Problem,$tmp)=split(/\=/,$sortedList[$nIndex]); - @Dis=split(/\+/,$tmp); - my $Temp = $Problem; - do { - $nIndex++; - $nStudent++; - $Sum1 += $Dis[0]; - $Sum2 += $Dis[1]; - ($Problem,$tmp)=split(/\=/,$sortedList[$nIndex]); - @Dis=split(/\+/,$tmp); - } while ( $Problem eq $Temp && $nIndex < $Count ); -# $Proc{$Temp}=($Sum1/$nStudent).':'.$nStudent; - $Proc{$Temp}=($Sum1/$nStudent).':'.($Sum2/$nStudent); -# $r->print("$nIndex) $Temp --> ($nStudent) $Proc{$Temp}
"); - $Sum1=0; - $Sum2=0; - $nStudent=0; - } - - return %Proc; +sub next_student { + return $next_student; } -#------- Creating Discimination factor -sub Discriminant { - my ($discriminantFactor)=@_; - my @discriminantKeys=keys(%$discriminantFactor); - my $Count = scalar @discriminantKeys; - - my $UpCnt = int(0.27*$Count); - my $low=0; - my $up=$Count-$UpCnt; - my @UpList=(); - my @LowList=(); - - $Count=0; - foreach my $key (sort(@discriminantKeys)) { - $Count++; - if($low < $UpCnt || $Count > $up) { - $low++; - my $str=$discriminantFactor->{$key}; - foreach(split(/\:/,$str)){ - if($_) { - if($low<$UpCnt) { push(@LowList,$_); } - else { push(@UpList,$_); } - } - } +sub StudentDataSelect { + my ($elementname,$status,$numvisible)=@_; + if ($numvisible < 1) { + return; + } + # + # Build the form element + my $Str = "\n"; + $Str .= ''.''."\n"; + $Str .= ">all\n"; + # + # Loop through the student data fields + foreach my $item (@StudentDataOrder) { + $Str .= '