[$i]->[2] =~ s/(\'$|^\')//g;
+ }
+ return $dataset;
+ }
+ return undef; # error occurred
+}
+
+sub RT_student_id { return 0; }
+sub RT_awarded { return 1; }
+sub RT_tries { return 2; }
+sub RT_timestamp { return 3; }
+
+sub get_response_time_data {
+ my ($students,$symb,$part,$courseid) = @_;
+ return undef if (! defined($symb) ||
+ ! defined($part));
+ $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+ #
+ &setup_table_names($courseid);
+ my $symb_id = &get_symb_id($symb);
+ my $part_id = &get_part_id($part);
+ #
+ my $dbh = &Apache::lonmysql::get_dbh();
+ return undef if (! defined($dbh));
+ my $request = 'SELECT '.
+ 'a.student_id, a.awarded, a.tries, b.timestamp '.
+ 'FROM '.$fulldump_part_table.' AS a '.
+ 'NATURAL LEFT JOIN '.$fulldump_timestamp_table.' AS b '.
+# 'ON a.symb_id=b.symb_id AND a.student_id=b.student_id AND '.
+# 'a.transaction = b.transaction '.
+ 'WHERE '.
+ 'a.symb_id='.$symb_id.' AND a.part_id='.$part_id;
+ if (defined($students)) {
+ $request .= ' AND ('.
+ join(' OR ', map {'a.student_id='.
+ &get_student_id($_->{'username'},
+ $_->{'domain'})
+ } @$students
+ ).')';
+ }
+ $request .= ' ORDER BY b.timestamp';
+# &Apache::lonnet::logthis("request =\n".$request);
+ my $sth = $dbh->prepare($request);
+ $sth->execute();
+ if ($dbh->err) {
+ &Apache::lonnet::logthis('error = '.$dbh->errstr());
+ return undef;
+ }
+ my $dataset = $sth->fetchall_arrayref();
+ if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) {
+ return $dataset;
+ }
+
+}
+
+################################################
+################################################
+
+=pod
+
+=item &get_student_scores($Sections,$Symbs,$enrollment,$courseid)
+
+=cut
+
+################################################
+################################################
+sub get_student_scores {
+ my ($Sections,$Symbs,$enrollment,$courseid,$starttime,$endtime) = @_;
+ $courseid = $ENV{'request.course.id'} if (! defined($courseid));
+ &setup_table_names($courseid);
+ my $dbh = &Apache::lonmysql::get_dbh();
+ return (undef) if (! defined($dbh));
+ my $tmptable = $courseid.'_temp_'.time;
+ #
+ my $symb_requirements;
+ if (defined($Symbs) && @$Symbs) {
+ $symb_requirements = '('.
+ join(' OR ', map{ "(a.symb_id='".&get_symb_id($_->{'symb'}).
+ "' AND a.part_id='".&get_part_id($_->{'part'}).
+ "')"
+ } @$Symbs).')';
+ }
+ #
+ my $student_requirements;
+ if ( (defined($Sections) && $Sections->[0] ne 'all')) {
+ $student_requirements = '('.
+ join(' OR ', map { "b.section='".$_."'" } @$Sections
+ ).')';
+ }
+ #
+ my $enrollment_requirements=undef;
+ if (defined($enrollment) && $enrollment ne 'Any') {
+ $enrollment_requirements = "b.status='".$enrollment."'";
+ }
+ #
+ 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."'";
+ }
+ ##
+ ##
+ my $request = 'CREATE TEMPORARY TABLE IF NOT EXISTS '.$tmptable.
+ ' SELECT a.student_id,SUM(a.awarded) AS score FROM '.
+ $performance_table.' AS a ';
+ if (defined($student_requirements) || defined($enrollment_requirements)) {
+ $request .= ' NATURAL LEFT JOIN '.$student_table.' AS b ';
+ }
+ if (defined($symb_requirements) ||
+ defined($student_requirements) ||
+ defined($enrollment_requirements) ) {
+ $request .= ' WHERE ';
+ }
+ if (defined($symb_requirements)) {
+ $request .= $symb_requirements.' AND ';
+ }
+ if (defined($student_requirements)) {
+ $request .= $student_requirements.' AND ';
+ }
+ if (defined($enrollment_requirements)) {
+ $request .= $enrollment_requirements.' AND ';
+ }
+ if (defined($time_requirements)) {
+ $request .= $time_requirements.' AND ';
+ }
+ $request =~ s/ AND $//; # Strip of the trailing ' AND '.
+ $request .= ' GROUP BY a.student_id';
+# &Apache::lonnet::logthis("request = \n".$request);
+ my $sth = $dbh->prepare($request);
+ $sth->execute();
+ if ($dbh->err) {
+ &Apache::lonnet::logthis('error = '.$dbh->errstr());
+ return undef;
+ }
+ $request = 'SELECT score,COUNT(*) FROM '.$tmptable.' GROUP BY score';
+# &Apache::lonnet::logthis("request = \n".$request);
+ $sth = $dbh->prepare($request);
+ $sth->execute();
+ if ($dbh->err) {
+ &Apache::lonnet::logthis('error = '.$dbh->errstr());
+ return undef;
+ }
+ my $dataset = $sth->fetchall_arrayref();
+ return $dataset;
+}
+
+################################################
+################################################
+
+=pod
+
+=item &setup_table_names()
+
+input: course id
+
+output: none
+
+Cleans up the package variables for local caching.
+
+=cut
+
+################################################
+################################################
+sub setup_table_names {
+ my ($courseid) = @_;
+ if (! defined($courseid)) {
+ $courseid = $ENV{'request.course.id'};
+ }
+ #
+ if (! defined($current_course) || $current_course ne $courseid) {
+ # Clear out variables
+ $have_read_part_table = 0;
+ undef(%ids_by_part);
+ undef(%parts_by_id);
+ $have_read_symb_table = 0;
+ undef(%ids_by_symb);
+ undef(%symbs_by_id);
+ $have_read_student_table = 0;
+ undef(%ids_by_student);
+ undef(%students_by_id);
+ #
+ $current_course = $courseid;
+ }
+ #
+ # Set up database names
+ my $base_id = $courseid;
+ $symb_table = $base_id.'_'.'symb';
+ $part_table = $base_id.'_'.'part';
+ $student_table = $base_id.'_'.'student';
+ $performance_table = $base_id.'_'.'performance';
+ $parameters_table = $base_id.'_'.'parameters';
+ $fulldump_part_table = $base_id.'_'.'partdata';
+ $fulldump_response_table = $base_id.'_'.'responsedata';
+ $fulldump_timestamp_table = $base_id.'_'.'timestampdata';
+ $weight_table = $base_id.'_'.'weight';
+ #
+ @Tables = (
+ $symb_table,
+ $part_table,
+ $student_table,
+ $performance_table,
+ $parameters_table,
+ $fulldump_part_table,
+ $fulldump_response_table,
+ $fulldump_timestamp_table,
+ $weight_table,
+ );
+ return;
+}
+
+################################################
+################################################
+
+=pod
+
+=back
+
+=item End of Local Data Caching Subroutines
+
+=cut
+
+################################################
+################################################
+
+} # End scope of table identifiers
+
################################################
################################################
@@ -2468,7 +2879,7 @@ $ENV{'course.'.$cid.'.domain'}, and $ENV
Returns a reference to a hash which contains:
keys '$sname:$sdom'
- values [$sdom,$sname,$end,$start,$id,$section,$fullname,$status]
+ values [$sdom,$sname,$end,$start,$id,$section,$fullname,$status,$type]
The constant values CL_SDOM, CL_SNAME, CL_END, etc. can be used
as indices into the returned list to future-proof clients against
@@ -2487,6 +2898,7 @@ sub CL_ID { return 4; }
sub CL_SECTION { return 5; }
sub CL_FULLNAME { return 6; }
sub CL_STATUS { return 7; }
+sub CL_TYPE { return 8; }
sub get_classlist {
my ($cid,$cdom,$cnum) = @_;
@@ -2497,12 +2909,15 @@ sub get_classlist {
#
my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
while (my ($student,$info) = each(%classlist)) {
- return undef if ($student =~ /^(con_lost|error|no_such_host)/i);
+ if ($student =~ /^(con_lost|error|no_such_host)/i) {
+ &Apache::lonnet::logthis('get_classlist error for '.$cid.':'.$student);
+ return undef;
+ }
my ($sname,$sdom) = split(/:/,$student);
my @Values = split(/:/,$info);
- my ($end,$start,$id,$section,$fullname);
+ my ($end,$start,$id,$section,$fullname,$type);
if (@Values > 2) {
- ($end,$start,$id,$section,$fullname) = @Values;
+ ($end,$start,$id,$section,$fullname,$type) = @Values;
} else { # We have to get the data ourselves
($end,$start) = @Values;
$section = &Apache::lonnet::getsection($sdom,$sname,$cid);
@@ -2539,11 +2954,11 @@ sub get_classlist {
$status='Active';
}
$classlist{$student} =
- [$sdom,$sname,$end,$start,$id,$section,$fullname,$status];
+ [$sdom,$sname,$end,$start,$id,$section,$fullname,$status,$type];
}
if (wantarray()) {
return (\%classlist,['domain','username','end','start','id',
- 'section','fullname','status']);
+ 'section','fullname','status','type']);
} else {
return \%classlist;
}
500 Internal Server Error
Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator at
root@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.
More information about this error may be available
in the server error log.