version 1.121, 2004/03/07 20:53:40
|
version 1.123, 2004/03/08 16:12:35
|
Line 1867 populated and all local caching variable
|
Line 1867 populated and all local caching variable
|
properly. This means you need to call &ensure_current_data for |
properly. This means you need to call &ensure_current_data for |
the students you are concerned with prior to calling this routine. |
the students you are concerned with prior to calling this routine. |
|
|
Inputs: $students, $symb, $part, $courseid |
Inputs: $students, $symb, $part, $courseid, $starttime, $endtime |
|
|
=over 4 |
=over 4 |
|
|
Line 1880 Each hash must contain at least the 'use
|
Line 1880 Each hash must contain at least the 'use
|
|
|
=item $courseid is the course id, of course! |
=item $courseid is the course id, of course! |
|
|
|
=item $starttime and $endtime are unix times which to use to limit |
|
the statistical data. |
|
|
=back |
=back |
|
|
Outputs: See the code for up to date information. A hash reference is |
Outputs: See the code for up to date information. A hash reference is |
Line 1915 able to answer it correctly.
|
Line 1918 able to answer it correctly.
|
################################################ |
################################################ |
################################################ |
################################################ |
sub get_problem_statistics { |
sub get_problem_statistics { |
my ($Sections,$status,$symb,$part,$courseid) = @_; |
my ($Sections,$status,$symb,$part,$courseid,$starttime,$endtime) = @_; |
return if (! defined($symb) || ! defined($part)); |
return if (! defined($symb) || ! defined($part)); |
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |
# |
# |
Line 1927 sub get_problem_statistics {
|
Line 1930 sub get_problem_statistics {
|
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
return undef if (! defined($dbh)); |
return undef if (! defined($dbh)); |
# |
# |
|
# Clean out the table |
$dbh->do('DROP TABLE '.$stats_table); # May return an error |
$dbh->do('DROP TABLE '.$stats_table); # May return an error |
my $request = |
my $request = |
'CREATE TEMPORARY TABLE '.$stats_table.' '. |
'CREATE TEMPORARY TABLE '.$stats_table.' '. |
'SELECT a.student_id,a.solved,a.award,a.awarded,a.tries '. |
'SELECT a.student_id,a.solved,a.award,a.awarded,a.tries '. |
'FROM '.$performance_table.' AS a '; |
'FROM '.$performance_table.' AS a '; |
|
# |
|
# See if we need to include some requirements on the students |
if ((defined($Sections) && lc($Sections->[0]) ne 'all') || |
if ((defined($Sections) && lc($Sections->[0]) ne 'all') || |
(defined($status) && lc($status) ne 'any')) { |
(defined($status) && lc($status) ne 'any')) { |
$request .= 'NATURAL LEFT JOIN '.$student_table.' AS b '; |
$request .= 'NATURAL LEFT JOIN '.$student_table.' AS b '; |
} |
} |
$request .= ' WHERE a.symb_id='.$symb_id.' AND a.part_id='.$part_id; |
$request .= ' WHERE a.symb_id='.$symb_id.' AND a.part_id='.$part_id; |
|
# |
|
# Limit the students included to those specified |
if (defined($Sections) && lc($Sections->[0]) ne 'all') { |
if (defined($Sections) && lc($Sections->[0]) ne 'all') { |
$request .= ' AND ('. |
$request .= ' AND ('. |
join(' OR ', map { "b.section='".$_."'" } @$Sections |
join(' OR ', map { "b.section='".$_."'" } @$Sections |
Line 1945 sub get_problem_statistics {
|
Line 1953 sub get_problem_statistics {
|
if (defined($status) && lc($status) ne 'any') { |
if (defined($status) && lc($status) ne 'any') { |
$request .= " AND b.status='".$status."'"; |
$request .= " AND b.status='".$status."'"; |
} |
} |
|
# |
|
# Limit by starttime and endtime |
|
my $time_requirements = undef; |
|
if (defined($starttime)) { |
|
$time_requirements .= 'a.timestamp>='.$starttime; |
|
if (defined($endtime)) { |
|
$time_requirements .= ' AND a.timestamp<='.$endtime; |
|
} |
|
} elsif (defined($endtime)) { |
|
$time_requirements .= 'a.timestamp<='.$endtime; |
|
} |
|
if (defined($time_requirements)) { |
|
$request .= ' AND '.$time_requirements; |
|
} |
|
# |
|
# Finally, execute the request to create the temporary table |
$dbh->do($request); |
$dbh->do($request); |
# &Apache::lonnet::logthis('request = '.$/.$request); |
# |
|
# Collect the first suite of statistics |
$request = 'SELECT COUNT(*),SUM(tries),MAX(tries),AVG(tries),STD(tries) '. |
$request = 'SELECT COUNT(*),SUM(tries),MAX(tries),AVG(tries),STD(tries) '. |
'FROM '.$stats_table; |
'FROM '.$stats_table; |
my ($num,$tries,$mod,$mean,$STD) = &execute_SQL_request |
my ($num,$tries,$mod,$mean,$STD) = &execute_SQL_request |
($dbh,$request); |
($dbh,$request); |
# &Apache::lonnet::logthis('request = '.$/.$request); |
|
$request = 'SELECT SUM(awarded) FROM '.$stats_table; |
$request = 'SELECT SUM(awarded) FROM '.$stats_table; |
my ($Solved) = &execute_SQL_request($dbh,$request); |
my ($Solved) = &execute_SQL_request($dbh,$request); |
# &Apache::lonnet::logthis('request = '.$/.$request); |
|
$request = 'SELECT SUM(awarded) FROM '.$stats_table. |
$request = 'SELECT SUM(awarded) FROM '.$stats_table. |
" WHERE solved='correct_by_override'"; |
" WHERE solved='correct_by_override'"; |
# &Apache::lonnet::logthis('request = '.$/.$request); |
|
my ($solved) = &execute_SQL_request($dbh,$request); |
my ($solved) = &execute_SQL_request($dbh,$request); |
# $Solved = int($Solved); |
|
# $solved = int($solved); |
|
# |
# |
$num = 0 if (! defined($num)); |
$num = 0 if (! defined($num)); |
$tries = 0 if (! defined($tries)); |
$tries = 0 if (! defined($tries)); |
Line 1969 sub get_problem_statistics {
|
Line 1989 sub get_problem_statistics {
|
$Solved = 0 if (! defined($Solved)); |
$Solved = 0 if (! defined($Solved)); |
$solved = 0 if (! defined($solved)); |
$solved = 0 if (! defined($solved)); |
# |
# |
|
# Compute the more complicated statistics |
my $DegOfDiff = 'nan'; |
my $DegOfDiff = 'nan'; |
$DegOfDiff = 1-($Solved)/$tries if ($tries>0); |
$DegOfDiff = 1-($Solved)/$tries if ($tries>0); |
|
# |
my $SKEW = 'nan'; |
my $SKEW = 'nan'; |
my $wrongpercent = 0; |
my $wrongpercent = 0; |
if ($num > 0) { |
if ($num > 0) { |
Line 1981 sub get_problem_statistics {
|
Line 2002 sub get_problem_statistics {
|
$wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10; |
$wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10; |
} |
} |
# |
# |
# $dbh->do('DROP TABLE '.$stats_table); # May return an error |
# Drop the temporary table |
|
$dbh->do('DROP TABLE '.$stats_table); # May return an error |
# |
# |
# Store in metadata |
# Store in metadata |
# |
|
if ($num) { |
if ($num) { |
my %storestats=(); |
my %storestats=(); |
|
# |
my $urlres=(&Apache::lonnet::decode_symb($symb))[2]; |
my $urlres=(&Apache::lonnet::decode_symb($symb))[2]; |
|
# |
$storestats{$courseid.'___'.$urlres.'___timestamp'}=time; |
$storestats{$courseid.'___'.$urlres.'___timestamp'}=time; |
$storestats{$courseid.'___'.$urlres.'___stdno'}=$num; |
$storestats{$courseid.'___'.$urlres.'___stdno'}=$num; |
$storestats{$courseid.'___'.$urlres.'___avetries'}=$mean; |
$storestats{$courseid.'___'.$urlres.'___avetries'}=$mean; |
$storestats{$courseid.'___'.$urlres.'___difficulty'}=$DegOfDiff; |
$storestats{$courseid.'___'.$urlres.'___difficulty'}=$DegOfDiff; |
|
# |
$urlres=~/^(\w+)\/(\w+)/; |
$urlres=~/^(\w+)\/(\w+)/; |
&Apache::lonnet::put('nohist_resevaldata',\%storestats,$1,$2); |
&Apache::lonnet::put('nohist_resevaldata',\%storestats,$1,$2); |
} |
} |
# |
# |
# Return result |
# Return result |
# |
|
return { num_students => $num, |
return { num_students => $num, |
tries => $tries, |
tries => $tries, |
max_tries => $mod, |
max_tries => $mod, |
Line 2025 sub execute_SQL_request {
|
Line 2045 sub execute_SQL_request {
|
return (); |
return (); |
} |
} |
|
|
|
|
sub get_student_data { |
sub get_student_data { |
my ($students,$courseid) = @_; |
my ($students,$courseid) = @_; |
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |
$courseid = $ENV{'request.course.id'} if (! defined($courseid)); |