[LON-CAPA-cvs] cvs: loncom /interface/statistics lonstathelpers.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Wed, 03 Mar 2004 22:57:31 -0000
matthew Wed Mar 3 17:57:31 2004 EDT
Modified files:
/loncom/interface/statistics lonstathelpers.pm
Log:
Modified &ProblemSelector to output response information for all response
types, not just option response.
Added &limit_by_time_form, &limit_by_time, and &get_time_limits which will
be used to indicate when a report should be restricted by the time of
submission. Not fully tested.
Index: loncom/interface/statistics/lonstathelpers.pm
diff -u loncom/interface/statistics/lonstathelpers.pm:1.4 loncom/interface/statistics/lonstathelpers.pm:1.5
--- loncom/interface/statistics/lonstathelpers.pm:1.4 Thu Feb 19 15:17:01 2004
+++ loncom/interface/statistics/lonstathelpers.pm Wed Mar 3 17:57:31 2004
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstathelpers.pm,v 1.4 2004/02/19 20:17:01 matthew Exp $
+# $Id: lonstathelpers.pm,v 1.5 2004/03/03 22:57:31 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -145,7 +145,7 @@
$resptype.'</td><td>'.
'<a href="'.$res->{'src'}.'">'.$title.'</a> ';
# '<a href="'.$res->{'src'}.'">'.$resptype.' '.$res->{'title'}.'</a> ';
- if ($partdata->{'option'} > 1) {
+ if (scalar(@{$partdata->{'ResponseIds'}}) > 1) {
$seq_str .= &mt('response').' '.$respid;
}
$seq_str .= "</td></tr>\n";
@@ -651,6 +651,82 @@
}
}
return %Partdata;
+}
+
+####################################################
+####################################################
+
+=pod
+
+=item &limit_by_time()
+
+=cut
+
+####################################################
+####################################################
+sub limit_by_time_form {
+ my $Starttime_form = '';
+ my $starttime = &Apache::lonhtmlcommon::get_date_from_form
+ ('limitby_startdate');
+ my $endtime = &Apache::lonhtmlcommon::get_date_from_form
+ ('limitby_enddate');
+ if (! defined($endtime)) {
+ $endtime = time;
+ }
+ if (! defined($starttime)) {
+ $starttime = $endtime - 60*60*24*7;
+ }
+ my $state;
+ if (&limit_by_time()) {
+ $state = '';
+ } else {
+ $state = 'disabled';
+ }
+ my $startdateform = &Apache::lonhtmlcommon::date_setter
+ ('Statistics','limitby_startdate',$starttime,undef,undef,$state);
+ my $enddateform = &Apache::lonhtmlcommon::date_setter
+ ('Statistics','limitby_enddate',$endtime,undef,undef,$state);
+ my $Str;
+ $Str .= '<script language="Javascript" >';
+ $Str .= 'function toggle_limitby_activity(state) {';
+ $Str .= ' if (state) {';
+ $Str .= ' limitby_startdate_enable();';
+ $Str .= ' limitby_enddate_enable();';
+ $Str .= ' } else {';
+ $Str .= ' limitby_startdate_disable();';
+ $Str .= ' limitby_enddate_disable();';
+ $Str .= ' }';
+ $Str .= '}';
+ $Str .= '</script>';
+ $Str .= '<fieldset>';
+ my $timecheckbox = '<input type="checkbox" name="limit_by_time" ';
+ if (&limit_by_time()) {
+ $timecheckbox .= ' checked ';
+ }
+ $timecheckbox .= 'OnChange="javascript:toggle_limitby_activity(this.checked);" ';
+ $timecheckbox .= ' />';
+ $Str .= '<legend>'.&mt('[_1] Limit by time',$timecheckbox).'</legend>';
+ $Str .= &mt('Start Time: [_1]',$startdateform).'<br />';
+ $Str .= &mt(' End Time: [_1]',$enddateform).'<br />';
+ $Str .= '</fieldset>';
+ return $Str;
+}
+
+sub limit_by_time {
+ if (exists($ENV{'form.limit_by_time'}) &&
+ $ENV{'form.limit_by_time'} ne '' ) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub get_time_limits {
+ my $starttime = &Apache::lonhtmlcommon::get_date_from_form
+ ('limitby_startdate');
+ my $endtime = &Apache::lonhtmlcommon::get_date_from_form
+ ('limitby_enddate');
+ return ($starttime,$endtime);
}
####################################################