version 1.1, 2002/07/24 14:52:32
|
version 1.26, 2003/10/07 16:07:39
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# (Publication Handler |
|
# |
# |
# $Id$ |
# $Id$ |
# |
# |
Line 25
|
Line 24
|
# |
# |
# http://www.lon-capa.org/ |
# 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::lonproblemanalysis; |
package Apache::lonproblemanalysis; |
|
|
use strict; |
use strict; |
use Apache::lonnet(); |
use Apache::lonnet(); |
use GDBM_File; |
use Apache::loncommon(); |
|
use Apache::lonhtmlcommon(); |
|
use Apache::loncoursedata(); |
|
use Apache::lonstatistics; |
|
use Apache::lonlocal; |
|
|
sub BuildProblemAnalysisPage { |
sub BuildProblemAnalysisPage { |
my ($cacheDB)=@_; |
my ($r,$c)=@_; |
|
$r->print('<h2>'.&mt('Option Response Problem Analysis').'</h2>'); |
my %cache; |
$r->print(&CreateInterface()); |
my $Str = ''; |
if (exists($ENV{'form.problemchoice'})) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
$r->print('<hr />'); |
$Str .= '<html><body>Unable to tie database.</body></html>'; |
&Apache::lonstatistics::Gather_Full_Student_Data($r); |
return $Str; |
# |
|
my ($symb,$part,$resid) = &get_problem_symb( |
|
&Apache::lonnet::unescape($ENV{'form.problemchoice'}) |
|
); |
|
my $resource = &get_resource_from_symb($symb); |
|
if (defined($resource)) { |
|
my %Data = &get_problem_data($resource->{'src'}); |
|
my $ORdata = $Data{$part.'.'.$resid}; |
|
## |
|
## Render the problem |
|
my $base; |
|
($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|); |
|
$base = "http://".$ENV{'SERVER_NAME'}.$base; |
|
my $rendered_problem = |
|
&Apache::lonnet::ssi_body($resource->{'src'}); |
|
$rendered_problem =~ s/<form /<nop /g; |
|
$rendered_problem =~ s/<\s*\/form\s>/<\/nop>/g; |
|
$r->print('<table bgcolor="ffffff"><tr><td>'. |
|
'<base href="'.$base.'" />'. |
|
$rendered_problem. |
|
'</td></tr></table>'); |
|
## |
|
## Analyze the problem |
|
my $PerformanceData = |
|
&Apache::loncoursedata::get_optionresponse_data |
|
(undef,$symb,$resid); |
|
if (defined($PerformanceData) && |
|
ref($PerformanceData) eq 'ARRAY') { |
|
my $analysis_html = &DoTriesAnalysis($PerformanceData,$ORdata); |
|
$r->print($analysis_html); |
|
} else { |
|
$r->print('<h2>'. |
|
&mt('There is no student data for this problem.'). |
|
'</h2>'); |
|
} |
|
} else { |
|
$r->print('resource is undefined'); |
|
} |
|
$r->print('<hr />'); |
|
} else { |
|
$r->print('<h3>No Problem Selected</h3>'); |
} |
} |
|
# Okay, they asked for data, so make sure we get the latest data. |
$Str .= &IntervalOptions($cache{'Interval'}); |
$r->print(&OptionResponseProblemSelector()); |
$Str .= &OptionResponseTable($cache{'OptionResponses'}); |
|
|
|
untie(%cache); |
|
|
|
return $Str; |
|
} |
} |
|
|
sub BuildAnalyzePage { |
|
my ($cacheDB, $students, $courseID)=@_; |
|
|
|
my $Str = ''; |
|
my %cache; |
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
|
$Str .= '<html><body>Unable to tie database.</body></html>'; |
|
return $Str; |
|
} |
|
|
|
my $uri = $cache{'AnalyzeURI'}, |
|
my $part = $cache{'AnalyzePart'}, |
|
my $problem = $cache{'AnalyzeProblem'}, |
|
my $title = $cache{'AnalyzeTitle'}, |
|
my $interval = $cache{'Interval'}, |
|
|
|
my %ConceptData; |
|
$ConceptData{"Interval"} = $interval; |
|
|
|
#Initialize the option response true answers |
|
my ($Concepts, $foil_to_concept, $answer) = &InitAnalysis($uri, $part, |
|
$problem, |
|
$students->[0], |
|
$courseID); |
|
|
|
#compute the intervals |
|
&Interval($part, $problem, $interval, $Concepts, \%ConceptData); |
|
|
|
$title =~ s/\ /"_"/eg; |
|
$Str .= '<br><b>'.$uri.'</b>'; |
|
|
|
#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, $answer); |
|
} |
|
&Close_PrgWin(); |
|
|
|
$Str .= '<br>'; |
|
for (my $k=0; $k<$interval; $k++ ) { |
|
$Str .= &DrawGraph($k, $title, $Concepts, \%ConceptData); |
|
} |
|
for (my $k=0; $k<$interval; $k++ ) { |
|
$Str .= &DrawTable($k, $Concepts, \%ConceptData); |
|
} |
|
#$Apache::lonxml::debug=1; |
|
#&Apache::lonhomework::showhash(%ConceptData); |
|
#$Apache::lonxml::debug=0; |
|
my $Answ=&Apache::lonnet::ssi($uri); |
|
$Str .= '<br><b>Here you can see the Problem:</b><br>'.$Answ; |
|
|
|
untie(%cache); |
sub DoTriesAnalysis { |
|
my ($PerformanceData,$ORdata) = @_; |
return $Str; |
my $mintries = 1; |
|
my $maxtries = 3; |
|
my %ResponseData = &analyze_option_data_by_tries($PerformanceData, |
|
$mintries,$maxtries); |
|
my @Foils = sort(keys(%ResponseData)); |
|
my %Row_Label; |
|
foreach my $foilid (@Foils) { |
|
my $value = $ORdata->{'Foiltext'}->{$foilid}; |
|
# &Apache::lonnet::logthis('row label '.$foilid.' = '.$value); |
|
$Row_Label{$foilid} = $ORdata->{'Foiltext'}->{$foilid}; |
|
} |
|
my @Rows; |
|
$Rows[0] = ['<td> </td>']; |
|
for (my $i=$mintries;$i<=$maxtries;$i++) { |
|
push (@{$Rows[0]}, |
|
'<th colspan="3">'.&mt('Attempt').' '.$i.'</th>'); |
|
} |
|
$Rows[1] = ['<th>'.&mt('Foil').'</th>']; |
|
for (my $i=$mintries;$i<=$maxtries;$i++) { |
|
push (@{$Rows[1]},('<th>'.&mt('Correct').'</th>', |
|
'<th>'.&mt('Incorrect').'</th>', |
|
'<th>'.&mt('Percent Correct').'</th>', |
|
)); |
|
} |
|
my @PlotData; |
|
my @CumulativePlotData; |
|
my $index = 1; |
|
foreach my $foilid (@Foils) { |
|
my @Data = ('<td>'.$index.' '.$Row_Label{$foilid}.'</td>'); |
|
for (my $i=$mintries;$i<=$maxtries;$i++) { |
|
push(@Data, |
|
('<td>'.$ResponseData{$foilid}->[$i]->{'correct'}.'</td>', |
|
'<td>'.$ResponseData{$foilid}->[$i]->{'incorrect'}. |
|
'</td>', |
|
'<td>'. |
|
sprintf("%4.2f", |
|
$ResponseData{$foilid}->[$i]->{'percent_corr'}). |
|
'</td>')); |
|
# |
|
# Gather the per-attempt data |
|
push (@{$PlotData[$i]->{'good'}}, |
|
$ResponseData{$foilid}->[$i]->{'percent_corr'}); |
|
push (@{$PlotData[$i]->{'bad'}}, |
|
100-$ResponseData{$foilid}->[$i]->{'percent_corr'}); |
|
} |
|
for (my $i=0;$i<=$maxtries;$i++) { |
|
push (@{$CumulativePlotData[$i]->{'good'}}, |
|
$CumulativePlotData[-1]->{'good'}+ |
|
$ResponseData{$foilid}->[$i]->{'correct'}); |
|
push (@{$CumulativePlotData[$i]->{'bad'}}, |
|
$CumulativePlotData[-1]->{'bad'}+ |
|
$ResponseData{$foilid}->[$i]->{'incorrect'}); |
|
} |
|
push(@Rows,\@Data); |
|
} continue { |
|
$index++; |
|
} |
|
my @Data = ('<td></td>'); |
|
for (my $i=$mintries;$i<=$maxtries;$i++) { |
|
push(@Data,'<td colspan="3">'.&DrawGraph('Attempt '.$i,'Foil Number', |
|
'Percent Correct',100, |
|
$PlotData[$i]->{'good'}, |
|
$PlotData[$i]->{'bad'}).'</td>'); |
|
} |
|
push (@Rows,\@Data); |
|
my $table = '<table border="1" >'."\n"; |
|
for (my $i=0; $i <=$#Rows;$i++) { |
|
$table .= '<tr>'.join('',@{$Rows[$i]})."</tr>\n"; |
|
} |
|
$table .= '</table>'; |
|
return ($table); |
} |
} |
|
|
#---- Problem Analysis Web Page ---------------------------------------------- |
sub analyze_option_data_by_tries { |
|
my ($PerformanceData,$mintries,$maxtries) = @_; |
sub IntervalOptions { |
my %Trydata; |
my ($selectedInterval)=@_; |
$mintries = 1 if (! defined($mintries) || $mintries < 1); |
|
$maxtries = $mintries if (! defined($maxtries) || $maxtries < $mintries); |
my $interval = 1; |
foreach my $row (@$PerformanceData) { |
for(my $n=1; $n<=7; $n++) { |
next if (! defined($row)); |
if($selectedInterval == $n) { |
my ($grading,$submission,$time,$tries) = @$row; |
$interval = $n; |
my @Foilgrades = split('&',$grading); |
|
my @Foilsubs = split('&',$submission); |
|
for (my $numtries = 1; $numtries <= $maxtries; $numtries++) { |
|
if ($tries == $numtries) { |
|
foreach my $foilgrade (@Foilgrades) { |
|
my ($foilid,$correct) = split('=',$foilgrade); |
|
if ($correct) { |
|
$Trydata{$foilid}->[$numtries]->{'correct'}++; |
|
} else { |
|
$Trydata{$foilid}->[$numtries]->{'incorrect'}++; |
|
} |
|
} |
|
} |
} |
} |
} |
} |
|
foreach my $foilid (keys(%Trydata)) { |
my $Ptr = '<br><b>Select number of intervals</b>'."\n". |
foreach my $tryhash (@{$Trydata{$foilid}}) { |
'<select name="Interval">'."\n"; |
next if ((! exists($tryhash->{'correct'}) && |
for(my $n=1; $n<=7;$ n++) { |
! exists($tryhash->{'incorrect'})) || |
$Ptr .= '<option'; |
($tryhash->{'correct'} < 1 && |
if($interval == $n) { |
$tryhash->{'incorrect'} < 1)); |
$Ptr .= ' selected'; |
$tryhash->{'percent_corr'} = 100 * |
|
($tryhash->{'correct'} / |
|
($tryhash->{'correct'} + $tryhash->{'incorrect'}) |
|
); |
} |
} |
$Ptr .= '>'.$n."</option>"."\n"; |
|
} |
} |
$Ptr .= '</select>'."\n"; |
return %Trydata; |
|
|
return $Ptr; |
|
} |
} |
|
|
sub OptionResponseTable { |
sub DrawGraph { |
my ($optionResponses)=@_; |
my ($title,$xlabel,$ylabel,$MaxY,$values1,$values2)=@_; |
my $Str = ''; |
if (! defined($values1) || ref($values1) ne 'ARRAY') { |
$Str .= '<br><b> Option Response Problems in this course:</b>'."\n"; |
return ''; |
$Str .= '<br><br>'."\n"; |
} |
$Str .= "<table border=2><tr><th> \# </th><th> Problem Title </th>"; |
$title = '' if (! defined($title)); |
$Str .= '<th> Resource </th><th> Analysis </th></tr>'."\n"; |
$xlabel = '' if (! defined($xlabel)); |
|
$ylabel = '' if (! defined($ylabel)); |
my $number=1; |
$title = &Apache::lonnet::escape($title); |
foreach (split(':::', $optionResponses)) { |
$xlabel = &Apache::lonnet::escape($xlabel); |
my ($uri,$title,$part,$problem)=split('::',$_); |
$ylabel = &Apache::lonnet::escape($ylabel); |
my $Temp = '<a href="'.$uri.'" target="_blank">'.$title.'</a>'; |
# |
$Str .= '<tr>'; |
my $sendValues1 = join(',', @$values1); |
$Str .= '<td> '.$number.' </td>'; |
my $sendValues2; |
$Str .= '<td bgcolor="#DDFFDD"> '.$Temp.' </td>'; |
if (defined($values2)) { |
$Str .= '<td bgcolor="#EEFFCC"> '.$uri.' </td>'; |
$sendValues2 = join(',', @$values2); |
$Str .= '<td><input type="submit" name="Analyze:::'.$uri.':::'; |
} |
$Str .= $title.':::'.$part.':::'.$problem.'" value="'; |
|
$Str .= 'Analyze" /></td></tr>'."\n"; |
my $sendCount = scalar(@$values1); |
$number++; |
$MaxY =1 if ($MaxY < 1); |
|
if ( int($MaxY) < $MaxY ) { |
|
$MaxY++; |
|
$MaxY = int($MaxY); |
|
} |
|
my @GData = ($title,$xlabel,$ylabel,$MaxY,$sendCount,$sendValues1); |
|
if (defined($sendValues2)) { |
|
push (@GData,$sendValues2); |
} |
} |
$Str .= '</table>'."\n"; |
return '<IMG src="/cgi-bin/graph.png?'. |
|
(join('&', @GData)).'" border="1" />'; |
return $Str; |
|
} |
} |
|
|
#---- END Problem Analysis Web Page ------------------------------------------ |
|
|
|
#---- Analyze Web Page ------------------------------------------------------- |
|
|
|
#restore the student submissions and finding the result |
sub get_problem_symb { |
sub OpStatus { |
my $problemstring = shift(); |
my ($problem, $student, $courseID, $ConceptData, $foil_to_concept, |
my ($symb,$partid,$resid) = ($problemstring=~ /^(.*):([^:]*):([^:]*)$/); |
$Answer)=@_; |
return ($symb,$partid,$resid); |
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", $foil_to_concept->{$_}, |
|
$time, $ConceptData); |
|
} else { |
|
&Decide("false", $foil_to_concept->{$_}, |
|
$time, $ConceptData);} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
|
|
sub DrawGraph { |
sub CreateInterface { |
my ($k,$Src,$Concepts,$ConceptData)=@_; |
my $Str = ''; |
my $Max=0; |
$Str .= '<table cellspacing="5">'."\n"; |
my @data1; |
$Str .= '<tr>'; |
my @data2; |
$Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>'; |
|
$Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>'; |
# Adjust Data and find the Max |
$Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>'; |
for (my $n=0; $n<(scalar @$Concepts); $n++ ) { |
$Str .= '</tr>'."\n"; |
my $tmp=$Concepts->[$n]; |
# |
$data1[$n]=$ConceptData->{$tmp.'.'.$k.'.true'}; |
$Str .= '<tr><td align="center">'."\n"; |
$data2[$n]=$ConceptData->{$tmp.'.'.$k.'.false'}; |
$Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); |
my $Sum=$data1[$n]+$data2[$n]; |
$Str .= '</td><td align="center">'; |
if($Max < $Sum) { |
$Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); |
$Max=$Sum; |
$Str .= '</td><td align="center">'; |
|
my $only_seq_with_assessments = sub { |
|
my $s=shift; |
|
if ($s->{'num_assess'} < 1) { |
|
return 0; |
|
} else { |
|
return 1; |
} |
} |
} |
}; |
for (my $n=0; $n<(scalar @$Concepts); $n++ ) { |
$Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, |
if ($data1[$n]+$data2[$n]<$Max) { |
$only_seq_with_assessments); |
$data2[$n]+=$Max-($data1[$n]+$data2[$n]); |
$Str .= '</td></tr>'."\n"; |
} |
$Str .= '</table>'."\n"; |
} |
$Str .= '<input type="submit" name="ProblemAnalysis" value="'. |
my $P_No = (scalar @data1); |
&mt('Analyze Problem').'" />'; |
|
$Str .= ' 'x5; |
if($Max > 1) { |
$Str .= '<input type="submit" name="ClearCache" value="'. |
$Max += (10 - $Max % 10); |
&mt('Clear Caches').'" />'; |
$Max = int($Max); |
$Str .= ' 'x5; |
} else { |
return ($Str); |
$Max = 1; |
|
} |
|
|
|
my $Titr=($ConceptData->{'Interval'}>1) ? $Src.'_interval_'.($k+1) : $Src; |
|
# $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2; |
|
my $GData = ''; |
|
$GData = $Titr.'&Concepts&Answers&'.$Max.'&'.$P_No.'&'; |
|
$GData .= (join(',',@data1)).'&'.(join(',',@data2)); |
|
|
|
return '<IMG src="/cgi-bin/graph.gif?'.$GData.'" border=1/>'; |
|
} |
} |
|
|
sub DrawTable { |
sub OptionResponseProblemSelector { |
my ($k,$Concepts,$ConceptData)=@_; |
my $Str; |
my $Max=0; |
$Str = "\n<table>\n"; |
my @data1; |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
my @data2; |
next if ($seq->{'num_assess'}<1); |
my $Correct=0; |
my $seq_str = ''; |
my $Wrong=0; |
foreach my $res (@{$seq->{'contents'}}) { |
for(my $n=0; $n<(scalar @$Concepts); $n++ ) { |
# &Apache::lonnet::logthis('checking '.$res->{'title'}); |
my $tmp=$Concepts->[$n]; |
next if ($res->{'type'} ne 'assessment'); |
$data1[$n]=$ConceptData->{$tmp.'.'.$k.'.true'}; |
foreach my $part (@{$res->{'parts'}}) { |
$Correct+=$data1[$n]; |
my $partdata = $res->{'partdata'}->{$part}; |
$data2[$n]=$ConceptData->{$tmp.'.'.$k.'.false'}; |
if (! exists($partdata->{'option'}) || |
$Wrong+=$data2[$n]; |
$partdata->{'option'} == 0) { |
my $Sum=$data1[$n]+$data2[$n]; |
next; |
if($Max < $Sum) { |
} |
$Max=$Sum; |
for (my $i=0;$i<scalar(@{$partdata->{'ResponseTypes'}});$i++){ |
|
my $respid = $partdata->{'ResponseIds'}->[$i]; |
|
my $resptype = $partdata->{'ResponseTypes'}->[$i]; |
|
if ($resptype eq 'option') { |
|
my $value = &Apache::lonnet::escape($res->{'symb'}.':'.$part.':'.$respid); |
|
my $checked = ''; |
|
if ($ENV{'form.problemchoice'} eq $value) { |
|
$checked = 'checked '; |
|
} |
|
$seq_str .= '<tr><td>'. |
|
'<input type="radio" name="problemchoice" value="'.$value.'" '.$checked.'/>'. |
|
'</td><td>'. |
|
'<a href="'.$res->{'src'}.'">'.$res->{'title'}.'</a> '; |
|
if ($partdata->{'option'} > 1) { |
|
$seq_str .= &mt('response').' '.$respid; |
|
} |
|
$seq_str .= "</td></tr>\n"; |
|
} |
|
} |
|
} |
|
} |
|
if ($seq_str ne '') { |
|
$Str .= '<tr><td> </td><td><b>'.$seq->{'title'}.'</b></td>'. |
|
"</tr>\n".$seq_str; |
} |
} |
} |
} |
for(my $n=0; $n<(scalar @$Concepts); $n++ ) { |
$Str .= "</table>\n"; |
if ($data1[$n]+$data2[$n]<$Max) { |
|
$data2[$n]+=$Max-($data1[$n]+$data2[$n]); |
|
} |
|
} |
|
my $P_No = (scalar @data1); |
|
my $Str = ''; |
|
# $Str .= '<br><b>From: ['.localtime($ConceptData->{'Int.'.($k-1)}); |
|
# $Str .= '] To: ['.localtime($ConceptData->{"Int.$k"}).']</b>'; |
|
$Str .= "\n".'<table border=2>'. |
|
"\n".'<tr>'. |
|
"\n".'<th> # </th>'. |
|
"\n".'<th> Concept </th>'. |
|
"\n".'<th> Correct </th>'. |
|
"\n".'<th> Wrong </th>'. |
|
"\n".'</tr>'; |
|
|
|
for(my $n=0; $n<(scalar @$Concepts); $n++ ) { |
|
$Str .= '<tr>'."\n"; |
|
$Str .= '<td>'.($n+1).'</td>'."\n"; |
|
$Str .= '<td bgcolor="EEFFCC">'.$Concepts->[$n]; |
|
$Str .= '</td>'."\n"; |
|
$Str .= '<td bgcolor="DDFFDD">'.$data1[$n].'</td>'."\n"; |
|
$Str .= '<td bgcolor="FFDDDD">'.$data2[$n].'</td>'."\n"; |
|
$Str .= '</tr>'."\n"; |
|
} |
|
$Str .= '<td></td><td><b>From:['.localtime($ConceptData->{'Int.'.$k}); |
|
$Str .= '] To: ['.localtime($ConceptData->{'Int.'.($k+1)}-1); |
|
$Str .= ']</b></td><td>'.$Correct.'</td><td>'.$Wrong.'</td>'; |
|
$Str .= '</table>'."\n"; |
|
|
|
return $Str; |
return $Str; |
#$Apache::lonxml::debug=1; |
|
#&Apache::lonhomework::showhash(%ConceptData); |
|
#$Apache::lonxml::debug=0; |
|
} |
} |
|
|
#---- END Analyze Web Page ---------------------------------------------- |
sub get_resource_from_symb { |
|
my ($symb) = @_; |
sub Decide { |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
#deciding the true or false answer belongs to each interval |
foreach my $res (@{$seq->{'contents'}}) { |
my ($type,$concept,$time,$ConceptData)=@_; |
if ($res->{'symb'} eq $symb) { |
my $k=0; |
return $res; |
while ($time>$ConceptData->{'Int.'.($k+1)} && |
} |
$k<$ConceptData->{'Interval'}) {$k++;} |
} |
$ConceptData->{$concept.'.'.$k.'.'.$type}++; |
} |
|
return undef; |
return; |
|
} |
} |
|
|
sub InitAnalysis { |
sub get_problem_data { |
my ($uri,$part,$problem,$student,$courseID)=@_; |
my ($url) = @_; |
my ($name,$domain)=split(/\:/,$student); |
# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze', |
|
# 'grade_username' => $sname, |
# Render the student's view of the problem. $Answ is the problem |
# 'grade_domain' => $sdom, |
# Stringafied |
# 'grade_courseid' => $cid, |
my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze', |
# 'grade_symb' => $symb)); |
'grade_username' => $name, |
my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze')); |
'grade_domain' => $domain, |
(my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2); |
'grade_courseid' => $courseID, |
my %Answer; |
'grade_symb' => $problem)); |
|
# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze')); |
|
|
|
# (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2); |
|
my %Answer=(); |
|
%Answer=&Apache::lonnet::str2hash($Answ); |
%Answer=&Apache::lonnet::str2hash($Answ); |
|
# &Apache::lonnet::logthis('keys of %Answer = '.join(', ',(keys(%Answer)))); |
my $parts=''; |
# &Apache::lonnet::logthis('$Answer{parts} = '. |
foreach my $elm (@{$Answer{'parts'}}) { |
# join(', ',@{$Answer{'parts'}})); |
$parts.= $elm.','; |
my %Partdata; |
} |
foreach my $part (@{$Answer{'parts'}}) { |
$parts =~ s/,$//; |
while (my($key,$value) = each(%Answer)) { |
|
next if ($key !~ /^$part/); |
my @Concepts=(); |
$key =~ s/^$part\.//; |
foreach my $elm (@{$Answer{$parts.'.concepts'}}) { |
if (ref($value) eq 'ARRAY') { |
push(@Concepts, $elm); |
if ($key eq 'options') { |
} |
$Partdata{$part}->{'Options'}=$value; |
|
} elsif ($key eq 'concepts') { |
my %foil_to_concept; |
$Partdata{$part}->{'Concepts'}=$value; |
foreach my $concept (@Concepts) { |
} elsif ($key =~ /^concept\.(.*)$/) { |
foreach my $foil (@{$Answer{$parts.'.concept.'.$concept}}) { |
my $concept = $1; |
$foil_to_concept{$foil} = $concept; |
foreach my $foil (@$value) { |
#$ConceptData{$foil} = $Answer{$parts.'.foil.value.'.$foil}; |
$Partdata{$part}->{$foil}->{'Concept'}=$concept; |
} |
} |
|
} |
|
# &Apache::lonnet::logthis($part.' '.$key.' (array) = '. |
|
# join(', ',@$value)); |
|
} else { |
|
$value =~ s/^\s*//g; |
|
$value =~ s/\s*$//g; |
|
if ($key=~ /^foil\.text\.(.*)$/) { |
|
my $foil = $1; |
|
$Partdata{$part}->{'Foiltext'}->{$foil}=$value; |
|
} elsif ($key =~ /^foil\.value\.(.*)$/) { |
|
my $foil = $1; |
|
$Partdata{$part}->{'FoilValues'}->{$foil}=$value; |
|
} |
|
# &Apache::lonnet::logthis($part.' '.$key.' = '.$value); |
|
} |
|
} |
} |
} |
|
|
return (\@Concepts, \%foil_to_concept, \%Answer); |
# 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"}; |
|
# } |
|
# } |
|
# return $symb; |
|
return %Partdata; |
} |
} |
|
|
sub Interval { |
|
my ($part,$symb,$interval,$Concepts,$ConceptData)=@_; |
|
my $Int=$interval; |
|
my $due = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb); |
|
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<(scalar @$Concepts); $n++ ) { |
|
my $tmp=$Concepts->[$n]; |
|
$ConceptData->{$tmp.'.'.$i.'.true'}=0; |
|
$ConceptData->{$tmp.'.'.$i.'.false'}=0; |
|
} |
|
} |
|
} |
|
1; |
1; |
|
|
__END__ |
__END__ |