--- loncom/interface/statistics/lonsubmissiontimeanalysis.pm 2003/10/29 15:22:04 1.1 +++ loncom/interface/statistics/lonsubmissiontimeanalysis.pm 2003/10/29 18:59:46 1.2 @@ -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.2 2003/10/29 18:59:46 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -149,6 +149,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 +170,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 +197,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,6 +224,8 @@ 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] = ''; @@ -234,13 +234,15 @@ sub analyze_times { 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', + 'Number of Submissions per hour', $plotcolors, \@Xlabel, \@Ydata,