version 1.1, 2002/07/24 14:52:32
|
version 1.3, 2002/08/01 20:49:06
|
Line 41 use strict;
|
Line 41 use strict;
|
use Apache::lonnet(); |
use Apache::lonnet(); |
use GDBM_File; |
use GDBM_File; |
|
|
|
my $jr; |
|
|
sub BuildProblemAnalysisPage { |
sub BuildProblemAnalysisPage { |
my ($cacheDB)=@_; |
my ($cacheDB)=@_; |
|
|
my %cache; |
my %cache; |
my $Str = ''; |
my $Str = ''; |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$Str .= '<html><body>Unable to tie database.</body></html>'; |
$Str .= '<html><body>Unable to tie database.</body></html>'; |
return $Str; |
return $Str; |
} |
} |
|
|
$Str .= &IntervalOptions($cache{'Interval'}); |
$Str .= &IntervalOptions($cache{'Interval'}); |
$Str .= &OptionResponseTable($cache{'OptionResponses'}); |
$Str .= &OptionResponseTable($cache{'OptionResponses'}, \%cache); |
|
|
untie(%cache); |
untie(%cache); |
|
|
Line 60 sub BuildProblemAnalysisPage {
|
Line 62 sub BuildProblemAnalysisPage {
|
} |
} |
|
|
sub BuildAnalyzePage { |
sub BuildAnalyzePage { |
my ($cacheDB, $students, $courseID)=@_; |
my ($cacheDB, $students, $courseID,$r)=@_; |
|
|
my $Str = ''; |
$jr = $r; |
|
my $c = $r->connection; |
|
|
|
my $Str = '</form>'; |
my %cache; |
my %cache; |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
foreach (@$students) { |
|
if($c->aborted) { |
|
return $Str; |
|
} |
|
my $downloadTime=''; |
|
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
|
$downloadTime = $cache{$_.':lastDownloadTime'}; |
|
untie(%cache); |
|
} |
|
if($downloadTime eq 'Not downloaded') { |
|
my $courseData = |
|
&Apache::loncoursedata::DownloadCourseInformation($_, |
|
$courseID); |
|
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
|
&Apache::loncoursedata::ProcessStudentData(\%cache, |
|
$courseData, $_); |
|
untie(%cache); |
|
} else { |
|
next; |
|
} |
|
} |
|
} |
|
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
$Str .= '<html><body>Unable to tie database.</body></html>'; |
$Str .= '<html><body>Unable to tie database.</body></html>'; |
return $Str; |
return $Str; |
} |
} |
|
|
my $uri = $cache{'AnalyzeURI'}, |
my ($problemId, $part, $responseId)=split(':',$cache{'AnalyzeInfo'}); |
my $part = $cache{'AnalyzePart'}, |
my $uri = $cache{$problemId.':source'}; |
my $problem = $cache{'AnalyzeProblem'}, |
my $problem = $cache{$problemId.':problem'}; |
my $title = $cache{'AnalyzeTitle'}, |
my $title = $cache{$problemId.':title'}; |
my $interval = $cache{'Interval'}, |
my $interval = $cache{'Interval'}; |
|
|
my %ConceptData; |
my %ConceptData; |
$ConceptData{"Interval"} = $interval; |
$ConceptData{"Interval"} = $interval; |
|
|
#Initialize the option response true answers |
#Initialize the option response true answers |
my ($Concepts, $foil_to_concept, $answer) = &InitAnalysis($uri, $part, |
my ($analyzeData) = &InitAnalysis($uri, $part, $responseId, $problem, |
$problem, |
$students->[0], $courseID); |
$students->[0], |
if(defined($analyzeData->{'error'})) { |
$courseID); |
$Str .= 'Incorrect part requested.<br>'; |
|
return $Str; |
|
} |
|
|
|
if($c->aborted()) { untie(%cache); return $Str; } |
|
|
#compute the intervals |
#compute the intervals |
&Interval($part, $problem, $interval, $Concepts, \%ConceptData); |
&Interval($part, $problem, $interval, $analyzeData->{'concepts'}, |
|
\%ConceptData); |
|
|
$title =~ s/\ /"_"/eg; |
$title =~ s/\ /"_"/eg; |
$Str .= '<br><b>'.$uri.'</b>'; |
$Str .= '<br><b>'.$uri.'</b>'; |
|
|
|
if($c->aborted()) { untie(%cache); return $Str; } |
|
|
#Java script Progress window |
#Java script Progress window |
&Create_PrgWin(); |
# &Create_PrgWin(); |
&Update_PrgWin("Starting-to-analyze-problem"); |
# &Update_PrgWin("Starting-to-analyze-problem"); |
for (my $index=0;$index<(scalar @$students);$index++) { |
for(my $index=0; $index<(scalar @$students); $index++) { |
&Update_PrgWin($index); |
if($c->aborted()) { untie(%cache); return $Str; } |
&OpStatus($problem, $students->[$index], $courseID, $answer); |
# &Update_PrgWin($index); |
|
# &OpStatus($problem, $students->[$index], $courseID, \%ConceptData, |
|
# $analyzeData->{'foil_to_concept'}, $analyzeData, \%cache); |
|
&OpStatus($problem, $students->[$index], \%ConceptData, |
|
$analyzeData->{'foil_to_concept'}, $analyzeData, \%cache); |
} |
} |
&Close_PrgWin(); |
# &Close_PrgWin(); |
|
|
$Str .= '<br>'; |
$Str .= '<br>'; |
for (my $k=0; $k<$interval; $k++ ) { |
for (my $k=0; $k<$interval; $k++ ) { |
$Str .= &DrawGraph($k, $title, $Concepts, \%ConceptData); |
if($c->aborted()) { untie(%cache); return $Str; } |
|
$Str .= &DrawGraph($k, $title, $analyzeData->{'concepts'}, |
|
\%ConceptData); |
} |
} |
for (my $k=0; $k<$interval; $k++ ) { |
for (my $k=0; $k<$interval; $k++ ) { |
$Str .= &DrawTable($k, $Concepts, \%ConceptData); |
if($c->aborted()) { untie(%cache); return $Str; } |
|
$Str .= &DrawTable($k, $analyzeData->{'concepts'}, \%ConceptData); |
} |
} |
#$Apache::lonxml::debug=1; |
|
#&Apache::lonhomework::showhash(%ConceptData); |
|
#$Apache::lonxml::debug=0; |
|
my $Answ=&Apache::lonnet::ssi($uri); |
my $Answ=&Apache::lonnet::ssi($uri); |
$Str .= '<br><b>Here you can see the Problem:</b><br>'.$Answ; |
$Str .= '<br><b>Here you can see the Problem:</b><br>'.$Answ; |
|
|
untie(%cache); |
untie(%cache); |
|
|
return $Str; |
return $Str.'<form>'; |
} |
} |
|
|
#---- Problem Analysis Web Page ---------------------------------------------- |
#---- Problem Analysis Web Page ---------------------------------------------- |
Line 144 sub IntervalOptions {
|
Line 183 sub IntervalOptions {
|
} |
} |
|
|
sub OptionResponseTable { |
sub OptionResponseTable { |
my ($optionResponses)=@_; |
my ($optionResponses,$cache)=@_; |
my $Str = ''; |
my $Str = ''; |
$Str .= '<br><b> Option Response Problems in this course:</b>'."\n"; |
$Str .= '<br><b> Option Response Problems in this course:</b>'."\n"; |
$Str .= '<br><br>'."\n"; |
$Str .= '<br><br>'."\n"; |
Line 152 sub OptionResponseTable {
|
Line 191 sub OptionResponseTable {
|
$Str .= '<th> Resource </th><th> Analysis </th></tr>'."\n"; |
$Str .= '<th> Resource </th><th> Analysis </th></tr>'."\n"; |
|
|
my $number=1; |
my $number=1; |
foreach (split(':::', $optionResponses)) { |
my @optionResponses=split(':::', $optionResponses); |
my ($uri,$title,$part,$problem)=split('::',$_); |
my %partCount; |
|
foreach (@optionResponses) { |
|
my ($problemId, $part, undef)=split(':',$_); |
|
$partCount{$problemId.':'.$part}++; |
|
} |
|
|
|
foreach (@optionResponses) { |
|
my ($problemId, $part, $response)=split(':',$_); |
|
my $uri = $cache->{$problemId.':source'}; |
|
my $title = $cache->{$problemId.':title'}; |
|
|
my $Temp = '<a href="'.$uri.'" target="_blank">'.$title.'</a>'; |
my $Temp = '<a href="'.$uri.'" target="_blank">'.$title.'</a>'; |
$Str .= '<tr>'; |
$Str .= '<tr>'; |
$Str .= '<td> '.$number.' </td>'; |
$Str .= '<td> '.$number.' </td>'; |
$Str .= '<td bgcolor="#DDFFDD"> '.$Temp.' </td>'; |
$Str .= '<td bgcolor="#DDFFDD">'.$Temp.'</td>'; |
$Str .= '<td bgcolor="#EEFFCC"> '.$uri.' </td>'; |
$Str .= '<td bgcolor="#EEFFCC">'.$uri.'</td>'; |
$Str .= '<td><input type="submit" name="Analyze:::'.$uri.':::'; |
if($partCount{$problemId.':'.$part} < 2) { |
$Str .= $title.':::'.$part.':::'.$problem.'" value="'; |
$Str .= '<td><input type="submit" name="Analyze:::'; |
$Str .= 'Analyze" /></td></tr>'."\n"; |
$Str .= $problemId.':'.$part.'" value="'; |
|
$Str .= 'Part '.$part; |
|
$Str .= '" /></td></tr>'."\n"; |
|
} else { |
|
$Str .= '<td><input type="submit" name="Analyze:::'.$_.'" value="'; |
|
$Str .= 'Part '.$part.' Response '.$response; |
|
$Str .= '" /></td></tr>'."\n"; |
|
} |
$number++; |
$number++; |
} |
} |
$Str .= '</table>'."\n"; |
$Str .= '</table>'."\n"; |
Line 175 sub OptionResponseTable {
|
Line 231 sub OptionResponseTable {
|
|
|
#restore the student submissions and finding the result |
#restore the student submissions and finding the result |
sub OpStatus { |
sub OpStatus { |
my ($problem, $student, $courseID, $ConceptData, $foil_to_concept, |
my ($problem, $student, $ConceptData, $foil_to_concept, |
$Answer)=@_; |
$analyzeData, $cache)=@_; |
my ($username,$userdomain)=split(/':'/,$student); |
|
my $code='U'; |
my $ids = $analyzeData->{'parts'}; |
my %reshash=&Apache::lonnet::restore($problem, $courseID, $userdomain, |
|
$username); |
|
my @True = (); |
my @True = (); |
my @False = (); |
my @False = (); |
my $flag=0; |
my $flag=0; |
if ($reshash{'version'}) { |
my $latestVersion = $cache->{$student.':version:'.$problem}; |
my $tries=0; |
if(!$latestVersion) { |
&Apache::lonhomework::showhash(%$Answer); |
return; |
for (my $version=1;$version<=$reshash{'version'};$version++) { |
} |
my $time=$reshash{"$version:timestamp"}; |
|
|
my $tries=0; |
foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) { |
for(my $version=1; $version<=$latestVersion; $version++) { |
if (($key=~/\.(\w+)\.(\w+)\.submission$/)) { |
my $time=$cache->{$student.':'.$version.':'.$problem.':timestamp'}; |
my $Id1 = $1; my $Id2 = $2; |
|
#check if this is a repeat submission, if so skip it |
foreach my $id (@$ids) { |
if ($reshash{"$version:resource.$Id1.previous"}) { next; } |
my ($currentPart, undef) = split(/\./, $id); |
#if no solved this wasn't a real submission, ignore it |
#check if this is a repeat submission, if so skip it |
if (!defined($reshash{"$version:resource.$Id1.solved"})) { |
next if($cache->{$student.':'.$version.':'.$problem. |
&Apache::lonxml::debug("skipping "); |
':resource.'.$currentPart.'.previous'}); |
next; |
#if no solved this wasn't a real submission, ignore it |
} |
if(!defined($cache->{"$student:$version:$problem". |
my $Resp = $reshash{"$version:$key"}; |
":resource.$currentPart.solved"})) { |
my %submission=&Apache::lonnet::str2hash($Resp); |
&Apache::lonxml::debug("skipping "); |
foreach (keys %submission) { |
next; |
my $Ansr = $Answer->{"$Id1.$Id2.foil.value.$_"}; |
} |
if ($submission{$_}) { |
my $Resp = $cache->{$student.':'.$version.':'.$problem. |
if ($submission{$_} eq $Ansr) { |
':resource.'.$id.'.submission'}; |
&Decide("true", $foil_to_concept->{$_}, |
my %submission=&Apache::lonnet::str2hash($Resp); |
$time, $ConceptData); |
foreach (keys(%submission)) { |
} else { |
if($submission{$_}) { |
&Decide("false", $foil_to_concept->{$_}, |
my $answer = $analyzeData->{$id.'.foil.value.'.$_}; |
$time, $ConceptData);} |
if($submission{$_} eq $answer) { |
} |
&Decide("true", $foil_to_concept->{$_}, |
} |
$time, $ConceptData); |
} |
} else { |
} |
&Decide("false", $foil_to_concept->{$_}, |
|
$time, $ConceptData); |
|
} |
|
} |
|
} |
} |
} |
} |
} |
|
|
|
return; |
} |
} |
|
|
sub DrawGraph { |
sub DrawGraph { |
Line 296 sub DrawTable {
|
Line 356 sub DrawTable {
|
for(my $n=0; $n<(scalar @$Concepts); $n++ ) { |
for(my $n=0; $n<(scalar @$Concepts); $n++ ) { |
$Str .= '<tr>'."\n"; |
$Str .= '<tr>'."\n"; |
$Str .= '<td>'.($n+1).'</td>'."\n"; |
$Str .= '<td>'.($n+1).'</td>'."\n"; |
$Str .= '<td bgcolor="EEFFCC">'.$Concepts->[$n]; |
my ($currentConcept) = split('::',$Concepts->[$n]); |
|
$Str .= '<td bgcolor="EEFFCC">'.$currentConcept; |
$Str .= '</td>'."\n"; |
$Str .= '</td>'."\n"; |
$Str .= '<td bgcolor="DDFFDD">'.$data1[$n].'</td>'."\n"; |
$Str .= '<td bgcolor="DDFFDD">'.$data1[$n].'</td>'."\n"; |
$Str .= '<td bgcolor="FFDDDD">'.$data2[$n].'</td>'."\n"; |
$Str .= '<td bgcolor="FFDDDD">'.$data2[$n].'</td>'."\n"; |
Line 319 sub Decide {
|
Line 380 sub Decide {
|
#deciding the true or false answer belongs to each interval |
#deciding the true or false answer belongs to each interval |
my ($type,$concept,$time,$ConceptData)=@_; |
my ($type,$concept,$time,$ConceptData)=@_; |
my $k=0; |
my $k=0; |
while ($time>$ConceptData->{'Int.'.($k+1)} && |
while($time > $ConceptData->{'Int.'.($k+1)} && |
$k<$ConceptData->{'Interval'}) {$k++;} |
$k < $ConceptData->{'Interval'}) { |
|
$k++; |
|
} |
$ConceptData->{$concept.'.'.$k.'.'.$type}++; |
$ConceptData->{$concept.'.'.$k.'.'.$type}++; |
|
|
return; |
return; |
} |
} |
|
|
sub InitAnalysis { |
sub InitAnalysis { |
my ($uri,$part,$problem,$student,$courseID)=@_; |
my ($uri,$part,$responseId,$problem,$student,$courseID)=@_; |
my ($name,$domain)=split(/\:/,$student); |
my ($name,$domain)=split(/\:/,$student); |
|
|
|
my %analyzeData; |
# Render the student's view of the problem. $Answ is the problem |
# Render the student's view of the problem. $Answ is the problem |
# Stringafied |
# Stringafied |
my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze', |
my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze', |
Line 337 sub InitAnalysis {
|
Line 401 sub InitAnalysis {
|
'grade_domain' => $domain, |
'grade_domain' => $domain, |
'grade_courseid' => $courseID, |
'grade_courseid' => $courseID, |
'grade_symb' => $problem)); |
'grade_symb' => $problem)); |
# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze')); |
|
|
|
# (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2); |
|
my %Answer=(); |
my %Answer=(); |
%Answer=&Apache::lonnet::str2hash($Answ); |
%Answer=&Apache::lonnet::str2hash($Answ); |
|
|
my $parts=''; |
my $found = 0; |
foreach my $elm (@{$Answer{'parts'}}) { |
my @parts=(); |
$parts.= $elm.','; |
if(defined($responseId)) { |
|
foreach (@{$Answer{'parts'}}) { |
|
if($_ eq $part.'.'.$responseId) { |
|
push(@parts, $_); |
|
$found = 1; |
|
last; |
|
} |
|
} |
|
} else { |
|
foreach (@{$Answer{'parts'}}) { |
|
if($_ =~ /$part/) { |
|
push(@parts, $_); |
|
$found = 1; |
|
last; |
|
} |
|
} |
} |
} |
$parts =~ s/,$//; |
|
|
|
my @Concepts=(); |
if($found == 0) { |
foreach my $elm (@{$Answer{$parts.'.concepts'}}) { |
$analyzeData{'error'} = 'No parts matching selected values'; |
push(@Concepts, $elm); |
return \%analyzeData; |
} |
} |
|
|
|
my @Concepts=(); |
my %foil_to_concept; |
my %foil_to_concept; |
foreach my $concept (@Concepts) { |
foreach my $currentPart (@parts) { |
foreach my $foil (@{$Answer{$parts.'.concept.'.$concept}}) { |
if(defined($Answer{$currentPart.'.concepts'})) { |
$foil_to_concept{$foil} = $concept; |
foreach my $concept (@{$Answer{$currentPart.'.concepts'}}) { |
#$ConceptData{$foil} = $Answer{$parts.'.foil.value.'.$foil}; |
push(@Concepts, $concept); |
} |
foreach my $foil (@{$Answer{$currentPart.'.concept.'. |
|
$concept}}) { |
|
$analyzeData{$currentPart.'.foil.value.'.$foil} = |
|
$Answer{$currentPart.'.foil.value.'.$foil}; |
|
$foil_to_concept{$foil} = $concept; |
|
} |
|
} |
|
} else { |
|
foreach (keys(%Answer)) { |
|
if(/$currentPart.foil\.value\.(.*)$/) { |
|
push(@Concepts, $1); |
|
$foil_to_concept{$1} = $1; |
|
$analyzeData{$currentPart.'.foil.value.'.$1} = |
|
$Answer{$currentPart.'.foil.value.'.$1}; |
|
} |
|
} |
|
} |
} |
} |
|
|
return (\@Concepts, \%foil_to_concept, \%Answer); |
$analyzeData{'parts'} = \@parts; |
|
$analyzeData{'concepts'} = \@Concepts; |
|
$analyzeData{'foil_to_concept'} = \%foil_to_concept; |
|
|
|
return \%analyzeData; |
} |
} |
|
|
sub Interval { |
sub Interval { |
Line 372 sub Interval {
|
Line 469 sub Interval {
|
my $opn = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb); |
my $opn = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb); |
my $add=int(($due-$opn)/$Int); |
my $add=int(($due-$opn)/$Int); |
$ConceptData->{'Int.0'}=$opn; |
$ConceptData->{'Int.0'}=$opn; |
for (my $i=1;$i<$Int;$i++) { |
for(my $i=1; $i<$Int; $i++) { |
$ConceptData->{'Int.'.$i}=$opn+$i*$add; |
$ConceptData->{'Int.'.$i}=$opn+$i*$add; |
} |
} |
$ConceptData->{'Int.'.$Int}=$due; |
$ConceptData->{'Int.'.$Int}=$due; |
for (my $i=0;$i<$Int;$i++) { |
for(my $i=0; $i<$Int; $i++) { |
for (my $n=0; $n<(scalar @$Concepts); $n++ ) { |
for(my $n=0; $n<(scalar @$Concepts); $n++ ) { |
my $tmp=$Concepts->[$n]; |
my $tmp=$Concepts->[$n]; |
$ConceptData->{$tmp.'.'.$i.'.true'}=0; |
$ConceptData->{$tmp.'.'.$i.'.true'}=0; |
$ConceptData->{$tmp.'.'.$i.'.false'}=0; |
$ConceptData->{$tmp.'.'.$i.'.false'}=0; |