# 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("render problem\n");
$r->print("image tag for plot\n");
$r->print("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";
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 .= '