--- loncom/interface/statistics/lonsubmissiontimeanalysis.pm 2003/10/29 15:22:04 1.1
+++ loncom/interface/statistics/lonsubmissiontimeanalysis.pm 2003/12/18 16:36:12 1.6
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonsubmissiontimeanalysis.pm,v 1.1 2003/10/29 15:22:04 matthew Exp $
+# $Id: lonsubmissiontimeanalysis.pm,v 1.6 2003/12/18 16:36:12 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -69,6 +69,16 @@ sub render_resource {
sub BuildSubmissionTimePage {
my ($r,$c)=@_;
+ #
+ my %Saveable_Parameters = ('Status' => 'scalar',
+ 'Section' => 'array');
+ &Apache::loncommon::store_course_settings('submissiontime_analysis',
+ \%Saveable_Parameters);
+ &Apache::loncommon::restore_course_settings('submissiontime_analysis',
+ \%Saveable_Parameters);
+ #
+ &Apache::lonstatistics::PrepareClasslist();
+ #
$r->print('
'.&mt('Submission Time Plots').'
');
$r->print(&CreateInterface());
#
@@ -149,6 +159,13 @@ sub get_week_start {
sub analyze_times {
my ($r,$resource,$students,$part) = @_;
+ #
+ # Convenience arrays
+ my @FullWeekDay = (qw/Sunday Monday Tuesday Wednesday Thursday Friday
+ Saturday/);
+ my @WeekDay = (qw/SUN MON TUE WED THU FRI SAT SUN/);
+ my @Month = (qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/);
+ #
my $html; # holds results of analysis
# Get the data
my $SubData = &Apache::loncoursedata::get_response_time_data
@@ -163,34 +180,24 @@ sub analyze_times {
return $html;
}
# Process the data
- # Get first and last times
- my $span = &get_time_from_row($SubData->[-1]) -
- &get_time_from_row($SubData->[0]);
- if ($span == 0) {
- $html.= '
There is no submission data for this resource
';
- return $html;
- }
#
my (undef,undef,undef,$mday,$month,$year,$wday,$yday,$isdst) =
localtime(&get_time_from_row($SubData->[0]));
my $day_start = &Time::Local::timelocal(0,0,0,$mday,$month,$year);
- my $start_day_of_week = $wday;
- #
- my @WeekDay = (qw/SUN MON TUE WED THU FRI SAT SUN/);
- my @Month = (qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/);
- #
- my $cumulative_answers = 0;
- #
- my @Ydata;
- my @AnsData;
- my @Xlabel;
#
+ # Configure the bins used to store the data.
my $binsize = 3600; # seconds
my $bins_per_day = 86400/$binsize;
my $bincount = 0;
my $endtime = $day_start;
#
+ # Initialize loop variables
my $max;
+ my @Ydata=(0);
+ my @AnsData=(0);
+ my @Xlabel=($WeekDay[$wday]);
+ my $cumulative_answers = 0;
+ #
foreach my $row (@$SubData) {
my $subtime = &get_time_from_row($row);
while ($subtime > $endtime && $endtime < time) {
@@ -200,8 +207,9 @@ sub analyze_times {
$AnsData[$bincount]=$AnsData[$bincount-1];
$endtime += $binsize;
if ($bincount % (86400/$binsize) == 0) {
- $Xlabel[$bincount] = $WeekDay[$wday++];
+ $wday++;
$wday %= 7;
+ $Xlabel[$bincount] = $WeekDay[$wday];
} else {
$Xlabel[$bincount] = '';
}
@@ -226,31 +234,40 @@ sub analyze_times {
$AnsData[$bincount]=$AnsData[$bincount-1];
$endtime += $binsize;
if ($bincount % (86400/$binsize) == 0) {
+ $wday ++;
+ $wday %= 7;
$Xlabel[$bincount] = $WeekDay[$wday];
} else {
$Xlabel[$bincount] = '';
}
}
-
+ my $numstudents = scalar(@$students);
+ for (my $i=0;$i<=$#AnsData;$i++) {
+ $AnsData[$i] = int(100*($AnsData[$i]/$numstudents));
+ }
my $title = 'Number of Submissions and Number Correct';
my $xlabel;
- (undef,undef,undef,$mday,$month,$year) = localtime($day_start);
- $xlabel .= 'Sunday '.join(' ',($Month[$month],$mday,1900+$year)).' - ';
- (undef,undef,undef,$mday,$month,$year) = localtime($endtime);
- $xlabel .= 'Sunday '.join(' ',($Month[$month],$mday,1900+$year));
+ (undef,undef,undef,$mday,$month,$year,$wday) = localtime($day_start);
+ $xlabel .= $FullWeekDay[$wday].' '.
+ join(' ',($Month[$month],$mday,1900+$year)).' - ';
+ (undef,undef,undef,$mday,$month,$year,$wday) = localtime($endtime);
+ $xlabel .= $FullWeekDay[$wday].' '.
+ join(' ',($Month[$month],$mday,1900+$year));
$html .= &Apache::loncommon::DrawXYYGraph($title,
$xlabel,
- 'Number of Submissions',
+ 'Submissions vs Time',
$plotcolors,
\@Xlabel,
\@Ydata,
0,$max,
\@AnsData,
- 0,scalar(@$students),
+ 0,100,
(xskip => $bins_per_day,
x_ticks => $bins_per_day,
x_tick_offset => $bins_per_day,
- width => 50+2*$bincount)
+ width => 50+2*$bincount,
+ y1_label=>'Number of Submissions per hour',
+ y2_label=>'Percent of Students answering Correctly')
);
$html .= ' ';
return $html;
@@ -259,7 +276,7 @@ sub analyze_times {
sub successful_submission {
my ($row) = @_;
if (ref($row) eq 'ARRAY') {
- return $row->[1];
+ return $row->[&Apache::loncoursedata::RT_awarded()];
}
return undef;
return 0;
@@ -268,7 +285,7 @@ sub successful_submission {
sub get_time_from_row {
my ($row) = @_;
if (ref($row) eq 'ARRAY') {
- return $row->[3];
+ return $row->[&Apache::loncoursedata::RT_timestamp()];
}
return undef;
}
@@ -276,7 +293,7 @@ sub get_time_from_row {
sub get_tries_from_row {
my ($row) = @_;
if (ref($row) eq 'ARRAY') {
- return $row->[2];
+ return $row->[&Apache::loncoursedata::RT_tries()];
}
return undef;
}
@@ -352,14 +369,23 @@ sub ProblemSelector {
if ($ENV{'form.problemchoice'} eq $value) {
$checked = 'checked ';
}
+ my $title = $res->{'title'};
+ if (! defined($title) || $title eq '') {
+ ($title) = ($res->{'src'} =~ m:/([^/]*)$:);
+ }
+# &Apache::lonnet::logthis('title = :'.$title.':');
$seq_str .= '