# The LearningOnline Network with CAPA # # $Id: lonproblemanalysis.pm,v 1.24 2003/09/29 21:13:23 matthew Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # # (Navigate problems for statistical reports # YEAR=2002 # 5/12,7/26,9/7,11/22 Behrouz Minaei # ### package Apache::lonproblemanalysis; use strict; use Apache::lonnet(); use Apache::lonhtmlcommon(); use Apache::loncoursedata(); use Apache::lonstatistics; use Apache::lonlocal; sub BuildProblemAnalysisPage { my ($r,$c)=@_; $r->print('

'.&mt('Option Response Problem Analysis').'

'); if (exists($ENV{'form.problemchoice'})) { # This is me getting around my own cleverness: &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, undef); # my ($symb,$id) = &get_problem_symb( &Apache::lonnet::unescape($ENV{'form.problemchoice'}) ); $r->print('
'); my $resource = &get_resource_from_symb($symb); if (defined($resource)) { $r->print('
'. # Oh this is dumb! Need to rewrite relative links # otherwise images (for example) will not show. &Apache::lonnet::ssi_body($resource->{'src'}). '
'); } else { $r->print('resource is undefined'); } $r->print('
    '); $r->print("
  1. render problem\n"); $r->print("
  2. image tag for plot\n"); $r->print("
  3. plot key\n"); $r->print('
'); $r->print("
\nProblem choice = $symb $id\n
\n"); $r->print('
'); } $r->print(''); $r->print(&CreateInterface()); if (! exists($ENV{'form.analysisfirstcall'})) { return; } # Okay, they asked for data, so make sure we get the latest data. &Apache::lonnet::logthis('got here for some reason'); # &Apache::lonstatistics::Gather_Full_Student_Data($r); $r->print(&OptionResponseProblemSelector()); } sub get_problem_symb { my $problemstring = shift(); my ($symb,$id) = ($problemstring=~ /^(.*):([^:]*)$/); return ($symb,$id); } sub CreateInterface { my $Str = ''; $Str .= ''."\n"; $Str .= ''; $Str .= ''; $Str .= ''; $Str .= ''; $Str .= ''."\n"; # $Str .= ''."\n"; $Str .= '
'.&mt('Sections').''.&mt('Enrollment Status').''.&mt('Sequences and Folders').'
'."\n"; $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); $Str .= ''; $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); $Str .= ''; my $only_seq_with_assessments = sub { my $s=shift; if ($s->{'num_assess'} < 1) { return 0; } else { return 1; } }; $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, $only_seq_with_assessments); $Str .= '
'."\n"; $Str .= ''; $Str .= ' 'x5; $Str .= ''; $Str .= ' 'x5; return ($Str); } sub OptionResponseProblemSelector { my $Str; $Str = "\n\n"; foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { next if ($seq->{'num_assess'}<1); my $seq_str = ''; foreach my $res (@{$seq->{'contents'}}) { # &Apache::lonnet::logthis('checking '.$res->{'title'}); # next if ($res->{'type'} ne 'assessment'); foreach my $part (@{$res->{'parts'}}) { my $partdata = $res->{'partdata'}->{$part}; if (! exists($partdata->{'option'}) || $partdata->{'option'} == 0) { next; } for (my $i=0;$i{'ResponseTypes'}});$i++){ my $respid = $partdata->{'ResponseIds'}->[$i]; my $resptype = $partdata->{'ResponseTypes'}->[$i]; if ($resptype eq 'option') { my $value = &Apache::lonnet::escape($res->{'symb'}.':'.$respid); my $checked = ''; if ($ENV{'form.problemchoice'} eq $value) { $checked = 'checked '; } $seq_str .= '\n"; } } } } if ($seq_str ne '') { $Str .= ''. "\n".$seq_str; } } $Str .= "
'. ''. ''. ''.$res->{'title'}.' '; if ($partdata->{'option'} > 1) { $seq_str .= &mt('response').' '.$respid; } $seq_str .= "
 '.$seq->{'title'}.'
\n"; return $Str; } sub get_resource_from_symb { my ($symb) = @_; &Apache::lonnet::logthis('target symb = :'.$symb.':'); foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { foreach my $res (@{$seq->{'contents'}}) { &Apache::lonnet::logthis('symb = :'.$res->{'symb'}.':'); if ($res->{'symb'} eq $symb) { return $res; } } } return undef; } =pod sub InitAnalysis { my ($resource,$sname,$sdom)=@_; my $symb = $resource-> my $URI = $hash{'src_'.$rid}; my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze', 'grade_username' => $sname, 'grade_domain' => $sdom, 'grade_courseid' => $cid, 'grade_symb' => $symb)); # 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"}; } } return $symb; } =cut 1; __END__