version 1.168, 2006/05/05 21:35:31
|
version 1.189, 2008/11/17 14:16:55
|
Line 30
|
Line 30
|
|
|
=head1 NAME |
=head1 NAME |
|
|
loncoursedata |
Apache::loncoursedata |
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|
Line 38 Set of functions that download and proce
|
Line 38 Set of functions that download and proce
|
|
|
=head1 PACKAGES USED |
=head1 PACKAGES USED |
|
|
Apache::Constants qw(:common :http) |
Apache::lonnet |
Apache::lonnet() |
Apache::longroup |
Apache::lonhtmlcommon |
Time::HiRes |
HTML::TokeParser |
Apache::lonmysql |
GDBM_File |
LONCAPA |
|
Digest::MD5 |
|
|
=cut |
=cut |
|
|
package Apache::loncoursedata; |
package Apache::loncoursedata; |
|
|
use strict; |
use strict; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonhtmlcommon; |
use Apache::longroup(); |
use Time::HiRes; |
use Time::HiRes(); |
use Apache::lonmysql; |
use Apache::lonmysql(); |
use HTML::TokeParser; |
use LONCAPA; |
use GDBM_File; |
use Digest::MD5(); |
|
|
=pod |
=pod |
|
|
Line 63 use GDBM_File;
|
Line 64 use GDBM_File;
|
This section contains all the functions that get data from other servers |
This section contains all the functions that get data from other servers |
and/or itself. |
and/or itself. |
|
|
=cut |
|
|
|
################################################ |
|
################################################ |
|
|
|
=pod |
|
|
|
=item &make_into_hash($values); |
=item &make_into_hash($values); |
|
|
Returns a reference to a hash as described by $values. $values is |
Returns a reference to a hash as described by $values. $values is |
assumed to be the result of |
assumed to be the result of |
join(':',map {&Apache::lonnet::escape($_)} %orighash); |
join(':',map {&escape($_)} %orighash); |
|
|
This is a helper function for get_current_state. |
This is a helper function for get_current_state. |
|
|
Line 84 This is a helper function for get_curren
|
Line 78 This is a helper function for get_curren
|
################################################ |
################################################ |
sub make_into_hash { |
sub make_into_hash { |
my $values = shift; |
my $values = shift; |
my %tmp = map { &Apache::lonnet::unescape($_); } |
my %tmp = map { &unescape($_); } split(':',$values); |
split(':',$values); |
|
return \%tmp; |
return \%tmp; |
} |
} |
|
|
Line 367 sub init_dbs {
|
Line 360 sub init_dbs {
|
{ name => 'section', |
{ name => 'section', |
type => 'VARCHAR(100) BINARY', |
type => 'VARCHAR(100) BINARY', |
restrictions => 'NOT NULL'}, |
restrictions => 'NOT NULL'}, |
{ name => 'status', |
{ name => 'start', |
type => 'VARCHAR(15) BINARY', |
type => 'INT', |
|
restrictions => 'NOT NULL'}, |
|
{ name => 'end', |
|
type => 'INT', |
restrictions => 'NOT NULL'}, |
restrictions => 'NOT NULL'}, |
{ name => 'classification', |
{ name => 'classification', |
type => 'VARCHAR(100) BINARY', }, |
type => 'VARCHAR(100) BINARY', }, |
Line 380 sub init_dbs {
|
Line 376 sub init_dbs {
|
'PRIMARY KEY' => ['student_id'], |
'PRIMARY KEY' => ['student_id'], |
'KEY' => [{ columns => ['student (100)', |
'KEY' => [{ columns => ['student (100)', |
'section (100)', |
'section (100)', |
'status (15)',]},], |
'start', |
|
'end']},], |
}; |
}; |
# |
# |
my $groupnames_table_def = { |
my $groupnames_table_def = { |
Line 904 sub populate_student_table {
|
Line 901 sub populate_student_table {
|
&init_dbs($courseid,0); |
&init_dbs($courseid,0); |
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
my $request = 'INSERT IGNORE INTO '.$student_table. |
my $request = 'INSERT IGNORE INTO '.$student_table. |
"(student,section,status) VALUES "; |
"(student,section,start,end) VALUES "; |
my $cdom = $env{'course.'.$courseid.'.domain'}; |
my $cdom = $env{'course.'.$courseid.'.domain'}; |
my $cnum = $env{'course.'.$courseid.'.num'}; |
my $cnum = $env{'course.'.$courseid.'.num'}; |
my $classlist = &get_classlist($cdom,$cnum); |
my $classlist = &get_classlist($cdom,$cnum); |
my $student_count=0; |
my $student_count=0; |
while (my ($student,$data) = each %$classlist) { |
while (my ($student,$data) = each %$classlist) { |
my ($section,$status) = ($data->[&CL_SECTION()], |
my ($section,$start,$end) = ($data->[&CL_SECTION()], |
$data->[&CL_STATUS()]); |
$data->[&CL_START()], |
|
$data->[&CL_END()]); |
if ($section eq '' || $section =~ /^\s*$/) { |
if ($section eq '' || $section =~ /^\s*$/) { |
$section = 'none'; |
$section = 'none'; |
} |
} |
$request .= "('".$student."','".$section."','".$status."'),"; |
if (!defined($start)) { $start = 0; } |
|
if (!defined($end)) { $end = 0; } |
|
$request .= "('".$student."','".$section."','".$start."','".$end."'),"; |
$student_count++; |
$student_count++; |
} |
} |
return if ($student_count == 0); |
return if ($student_count == 0); |
Line 923 sub populate_student_table {
|
Line 923 sub populate_student_table {
|
$dbh->do($request); |
$dbh->do($request); |
if ($dbh->err()) { |
if ($dbh->err()) { |
&Apache::lonnet::logthis("error ".$dbh->errstr(). |
&Apache::lonnet::logthis("error ".$dbh->errstr(). |
" occured executing \n". |
" occurred executing \n". |
$request); |
$request); |
} |
} |
return; |
return; |
Line 965 sub populate_groupnames_table {
|
Line 965 sub populate_groupnames_table {
|
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
my $cdom = $env{'course.'.$courseid.'.domain'}; |
my $cdom = $env{'course.'.$courseid.'.domain'}; |
my $cnum = $env{'course.'.$courseid.'.num'}; |
my $cnum = $env{'course.'.$courseid.'.num'}; |
my %curr_groups; |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
my $numgrps = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum); |
return if (!%curr_groups); |
return if (!$numgrps); |
|
my $request = 'INSERT IGNORE INTO '.$groupnames_table. |
my $request = 'INSERT IGNORE INTO '.$groupnames_table. |
'(groupname) VALUES '; |
'(groupname) VALUES '; |
foreach my $groupname (sort(keys(%curr_groups)),'none') { |
foreach my $groupname (sort(keys(%curr_groups)),'none') { |
Line 977 sub populate_groupnames_table {
|
Line 976 sub populate_groupnames_table {
|
$dbh->do($request); |
$dbh->do($request); |
if ($dbh->err()) { |
if ($dbh->err()) { |
&Apache::lonnet::logthis("error ".$dbh->errstr(). |
&Apache::lonnet::logthis("error ".$dbh->errstr(). |
" occured executing \n". |
" occurred executing \n". |
$request); |
$request); |
} |
} |
return; |
return; |
Line 1025 sub populate_students_groups_table {
|
Line 1024 sub populate_students_groups_table {
|
"(student_id,group_id) VALUES "; |
"(student_id,group_id) VALUES "; |
my $cdom = $env{'course.'.$courseid.'.domain'}; |
my $cdom = $env{'course.'.$courseid.'.domain'}; |
my $cnum = $env{'course.'.$courseid.'.num'}; |
my $cnum = $env{'course.'.$courseid.'.num'}; |
my $classlist = &get_classlist($cdom,$cnum); |
my ($classlist,$keylist) = &get_classlist($cdom,$cnum); |
my ($classgroups,$studentgroups) = &get_group_memberships($classlist, |
my ($classgroups,$studentgroups) = &get_group_memberships($classlist, |
|
$keylist, |
$cdom,$cnum); |
$cdom,$cnum); |
my $record_count = 0; |
my $record_count = 0; |
foreach my $student (sort(keys(%{$classgroups}))) { |
foreach my $student (sort(keys(%{$classgroups}))) { |
Line 1046 sub populate_students_groups_table {
|
Line 1046 sub populate_students_groups_table {
|
$dbh->do($request); |
$dbh->do($request); |
if ($dbh->err()) { |
if ($dbh->err()) { |
&Apache::lonnet::logthis("error ".$dbh->errstr(). |
&Apache::lonnet::logthis("error ".$dbh->errstr(). |
" occured executing \n". |
" occurred executing \n". |
$request); |
$request); |
} |
} |
return; |
return; |
Line 1105 Input: $sname, $sdom, $courseid
|
Line 1105 Input: $sname, $sdom, $courseid
|
|
|
Output: $returnstatus |
Output: $returnstatus |
|
|
$returnstatus is a string describing any errors that occured. 'okay' is the |
$returnstatus is a string describing any errors that occurred. 'okay' is the |
default. |
default. |
|
|
This subroutine loads a students data using lonnet::dump and inserts |
This subroutine loads a students data using lonnet::dump and inserts |
Line 1119 a description of the error.
|
Line 1119 a description of the error.
|
|
|
Once the "fulldump" tables are updated, the tables used for chart and |
Once the "fulldump" tables are updated, the tables used for chart and |
spreadsheet (which hold only the current state of the student on their |
spreadsheet (which hold only the current state of the student on their |
homework, not historical data) are updated. If all updates have occured |
homework, not historical data) are updated. If all updates have occurred |
successfully, $student_table is updated to reflect the time of the update. |
successfully, $student_table is updated to reflect the time of the update. |
|
|
Notice we do not insert the data and immediately query it. This means it |
Notice we do not insert the data and immediately query it. This means it |
Line 1137 sub update_full_student_data {
|
Line 1137 sub update_full_student_data {
|
&setup_table_names($courseid); |
&setup_table_names($courseid); |
# |
# |
my $student_id = &get_student_id($sname,$sdom); |
my $student_id = &get_student_id($sname,$sdom); |
my @group_ids = &get_students_groupids($student_id); |
|
my $student = $sname.':'.$sdom; |
my $student = $sname.':'.$sdom; |
# |
# |
my $returnstatus = 'okay'; |
my $returnstatus = 'okay'; |
Line 1169 sub update_full_student_data {
|
Line 1168 sub update_full_student_data {
|
while (my ($key,$value) = each(%studentdata)) { |
while (my ($key,$value) = each(%studentdata)) { |
next if ($key =~ /^(\d+):(resource$|subnum$|keys:)/); |
next if ($key =~ /^(\d+):(resource$|subnum$|keys:)/); |
my ($transaction,$symb,$parameter) = split(':',$key); |
my ($transaction,$symb,$parameter) = split(':',$key); |
|
$symb = &unescape($symb); |
|
$parameter = &unescape($parameter); |
my $symb_id = &get_symb_id($symb); |
my $symb_id = &get_symb_id($symb); |
if ($parameter eq 'timestamp') { |
if ($parameter eq 'timestamp') { |
# We can deal with 'timestamp' right away |
# We can deal with 'timestamp' right away |
Line 1308 sub update_full_student_data {
|
Line 1309 sub update_full_student_data {
|
chop($store_command); |
chop($store_command); |
$dbh->do($store_command); |
$dbh->do($store_command); |
if ($dbh->err) { |
if ($dbh->err) { |
$returnstatus = 'error storing part data'; |
$returnstatus = 'error saving part data'; |
&Apache::lonnet::logthis('insert error '.$dbh->errstr()); |
&Apache::lonnet::logthis('insert error '.$dbh->errstr()); |
&Apache::lonnet::logthis("While attempting\n".$store_command); |
&Apache::lonnet::logthis("While attempting\n".$store_command); |
} |
} |
Line 1348 sub update_full_student_data {
|
Line 1349 sub update_full_student_data {
|
chop($store_command); |
chop($store_command); |
$dbh->do($store_command); |
$dbh->do($store_command); |
if ($dbh->err) { |
if ($dbh->err) { |
$returnstatus = 'error storing response data'; |
$returnstatus = 'error saving response data'; |
&Apache::lonnet::logthis('insert error '.$dbh->errstr()); |
&Apache::lonnet::logthis('insert error '.$dbh->errstr()); |
&Apache::lonnet::logthis("While attempting\n".$store_command); |
&Apache::lonnet::logthis("While attempting\n".$store_command); |
} |
} |
Line 1360 sub update_full_student_data {
|
Line 1361 sub update_full_student_data {
|
($sname,$sdom,$courseid, |
($sname,$sdom,$courseid, |
&Apache::lonnet::convert_dump_to_currentdump(\%studentdata)); |
&Apache::lonnet::convert_dump_to_currentdump(\%studentdata)); |
if ($returnstatus eq 'okay' && $status ne 'okay') { |
if ($returnstatus eq 'okay' && $status ne 'okay') { |
$returnstatus = 'error storing current data:'.$status; |
$returnstatus = 'error saving current data:'.$status; |
} elsif ($status ne 'okay') { |
} elsif ($status ne 'okay') { |
$returnstatus .= ' error storing current data:'.$status; |
$returnstatus .= ' error saving current data:'.$status; |
} |
} |
## |
## |
## Update the students time...... |
## Update the students time...... |
Line 1390 Input: $sname, $sdom, $courseid
|
Line 1391 Input: $sname, $sdom, $courseid
|
|
|
Output: $returnstatus, \%student_data |
Output: $returnstatus, \%student_data |
|
|
$returnstatus is a string describing any errors that occured. 'okay' is the |
$returnstatus is a string describing any errors that occurred. 'okay' is the |
default. |
default. |
\%student_data is the data returned by a call to lonnet::currentdump. |
\%student_data is the data returned by a call to lonnet::currentdump. |
|
|
Line 1420 sub update_student_data {
|
Line 1421 sub update_student_data {
|
&setup_table_names($courseid); |
&setup_table_names($courseid); |
# |
# |
my $student_id = &get_student_id($sname,$sdom); |
my $student_id = &get_student_id($sname,$sdom); |
my @group_ids = &get_students_groupids($student_id); |
|
my $student = $sname.':'.$sdom; |
my $student = $sname.':'.$sdom; |
# |
# |
my $returnstatus = 'okay'; |
my $returnstatus = 'okay'; |
# |
# |
# Download students data |
# Download students data |
my $time_of_retrieval = time; |
my $time_of_retrieval = time; |
my @tmp = &Apache::lonnet::currentdump($courseid,$sdom,$sname); |
my %student_data = &Apache::lonnet::currentdump($courseid,$sdom,$sname); |
if ((scalar(@tmp) > 0) && ($tmp[0] =~ /^error:/)) { |
if (&Apache::lonnet::error(%student_data)) { |
&Apache::lonnet::logthis('error getting data for '. |
&Apache::lonnet::logthis('error getting data for '. |
$sname.':'.$sdom.' in course '.$courseid. |
$sname.':'.$sdom.' in course '.$courseid. |
':'.$tmp[0]); |
':'.(%student_data)[0]); |
$returnstatus = 'error getting data'; |
$returnstatus =(%student_data)[0] ; |
return ($returnstatus,undef); |
return ($returnstatus,undef); |
} |
} |
if (scalar(@tmp) < 1) { |
if (scalar(keys(%student_data)) < 1) { |
return ('no data',undef); |
return ('no data',undef); |
} |
} |
my %student_data = @tmp; |
|
my @Results = &store_student_data($sname,$sdom,$courseid,\%student_data); |
my @Results = &store_student_data($sname,$sdom,$courseid,\%student_data); |
# |
# |
# Set the students update time |
# Set the students update time |
Line 1472 sub store_student_data {
|
Line 1471 sub store_student_data {
|
my ($sname,$sdom,$courseid,$student_data) = @_; |
my ($sname,$sdom,$courseid,$student_data) = @_; |
# |
# |
my $student_id = &get_student_id($sname,$sdom); |
my $student_id = &get_student_id($sname,$sdom); |
my @group_ids = &get_students_groupids($student_id); |
|
my $student = $sname.':'.$sdom; |
my $student = $sname.':'.$sdom; |
# |
# |
my $returnstatus = 'okay'; |
my $returnstatus = 'okay'; |
Line 1664 sub ensure_current_data {
|
Line 1662 sub ensure_current_data {
|
# |
# |
# Get the update time for the user |
# Get the update time for the user |
my $updatetime = 0; |
my $updatetime = 0; |
|
my $getuserdir = 1; |
my $modifiedtime = &Apache::lonnet::GetFileTimestamp |
my $modifiedtime = &Apache::lonnet::GetFileTimestamp |
($sdom,$sname,$courseid.'.db', |
($sdom,$sname,$courseid.'.db',$getuserdir); |
$Apache::lonnet::perlvar{'lonUsersDir'}); |
|
# |
# |
|
if ($modifiedtime == -1) { |
|
return ('no data',undef); |
|
} |
|
|
my $student_id = &get_student_id($sname,$sdom); |
my $student_id = &get_student_id($sname,$sdom); |
my @group_ids = &get_students_groupids($student_id); |
|
my @Result = &Apache::lonmysql::get_rows($student_table, |
my @Result = &Apache::lonmysql::get_rows($student_table, |
"student_id ='$student_id'"); |
"student_id ='$student_id'"); |
my $data = undef; |
my $data = undef; |
if (@Result) { |
if (@Result) { |
$updatetime = $Result[0]->[5]; # Ack! This is dumb! |
$updatetime = $Result[0]->[6]; # Ack! This is dumb! |
} |
} |
if ($modifiedtime > $updatetime) { |
if ($modifiedtime > $updatetime) { |
($status,$data) = &update_student_data($sname,$sdom,$courseid); |
($status,$data) = &update_student_data($sname,$sdom,$courseid); |
Line 1713 sub ensure_current_full_data {
|
Line 1714 sub ensure_current_full_data {
|
&ensure_tables_are_set_up($courseid); |
&ensure_tables_are_set_up($courseid); |
# |
# |
# Get the update time for the user |
# Get the update time for the user |
|
my $getuserdir = 1; |
my $modifiedtime = &Apache::lonnet::GetFileTimestamp |
my $modifiedtime = &Apache::lonnet::GetFileTimestamp |
($sdom,$sname,$courseid.'.db', |
($sdom,$sname,$courseid.'.db',$getuserdir); |
$Apache::lonnet::perlvar{'lonUsersDir'}); |
|
# |
# |
my $student_id = &get_student_id($sname,$sdom); |
my $student_id = &get_student_id($sname,$sdom); |
my @group_ids = &get_students_groupids($student_id); |
|
my @Result = &Apache::lonmysql::get_rows($student_table, |
my @Result = &Apache::lonmysql::get_rows($student_table, |
"student_id ='$student_id'"); |
"student_id ='$student_id'"); |
my $updatetime; |
my $updatetime; |
if (@Result && ref($Result[0]) eq 'ARRAY') { |
if (@Result && ref($Result[0]) eq 'ARRAY') { |
$updatetime = $Result[0]->[6]; |
$updatetime = $Result[0]->[7]; |
} |
} |
if (! defined($updatetime) || $modifiedtime > $updatetime) { |
if (! defined($updatetime) || $modifiedtime > $updatetime) { |
$status = &update_full_student_data($sname,$sdom,$courseid); |
$status = &update_full_student_data($sname,$sdom,$courseid); |
Line 1913 sub get_current_state {
|
Line 1913 sub get_current_state {
|
} else { |
} else { |
if ($status ne 'okay' && $status ne '') { |
if ($status ne 'okay' && $status ne '') { |
&Apache::lonnet::logthis('status = '.$status); |
&Apache::lonnet::logthis('status = '.$status); |
return (); |
return ('error: '.$status,undef); |
} |
} |
my $returnhash = &get_student_data_from_performance_cache($sname,$sdom, |
my $returnhash = &get_student_data_from_performance_cache($sname,$sdom, |
$symb,$courseid); |
$symb,$courseid); |
Line 1998 sub get_problem_statistics {
|
Line 1998 sub get_problem_statistics {
|
&setup_table_names($courseid); |
&setup_table_names($courseid); |
my $symb_id = &get_symb_id($symb); |
my $symb_id = &get_symb_id($symb); |
my $part_id = &get_part_id($part); |
my $part_id = &get_part_id($part); |
my $stats_table = $courseid.'_problem_stats'; |
my $stats_table = &temp_table_name($courseid,'problem_stats'); |
# |
# |
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
return undef if (! defined($dbh)); |
return undef if (! defined($dbh)); |
Line 2022 sub get_problem_statistics {
|
Line 2022 sub get_problem_statistics {
|
$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 |
# Limit the students included to those specified |
if (defined($Sections) && lc($Sections->[0]) ne 'all') { |
my ($section_limits,$enrollment_limits)= |
$request .= ' AND ('. |
&limit_by_section_and_status($Sections,$status,'b'); |
join(' OR ', map { "b.section='".$_."'" } @$Sections |
|
).')'; |
|
} |
|
if (defined($status) && lc($status) ne 'any') { |
|
$request .= " AND b.status='".$status."'"; |
|
} |
|
# |
# |
# Limit by starttime and endtime |
# Limit by starttime and endtime |
my $time_requirements = undef; |
my $time_requirements = undef; |
Line 2044 sub get_problem_statistics {
|
Line 2038 sub get_problem_statistics {
|
if (defined($time_requirements)) { |
if (defined($time_requirements)) { |
$request .= ' AND '.$time_requirements; |
$request .= ' AND '.$time_requirements; |
} |
} |
|
if (defined($section_limits)) { |
|
$request .= ' AND '.$section_limits; |
|
} |
|
if (defined($enrollment_limits)) { |
|
$request .= ' AND '.$enrollment_limits; |
|
} |
# Limit by group, as required |
# Limit by group, as required |
if (defined($group_limits)) { |
if (defined($group_limits)) { |
$request .= ' AND '.$group_limits; |
$request .= ' AND '.$group_limits; |
Line 2202 sub populate_weight_table {
|
Line 2202 sub populate_weight_table {
|
$dbh->do($request); |
$dbh->do($request); |
if ($dbh->err()) { |
if ($dbh->err()) { |
&Apache::lonnet::logthis("error ".$dbh->errstr(). |
&Apache::lonnet::logthis("error ".$dbh->errstr(). |
" occured executing \n". |
" occurred executing \n". |
$request); |
$request); |
} |
} |
return; |
return; |
Line 2270 sub limit_by_section_and_status {
|
Line 2270 sub limit_by_section_and_status {
|
} |
} |
my $enrollment_requirements=undef; |
my $enrollment_requirements=undef; |
if (defined($enrollment) && $enrollment ne 'Any') { |
if (defined($enrollment) && $enrollment ne 'Any') { |
$enrollment_requirements = $tablename.".status='".$enrollment."'"; |
my $now = time(); |
|
if ( $enrollment eq 'Future' ) { |
|
$enrollment_requirements = |
|
"( $tablename.start > $now AND ". |
|
"( $tablename.end = 0 OR $tablename.end > $now))"; |
|
} elsif ( $enrollment eq 'Active' ) { |
|
$enrollment_requirements = |
|
"(( $tablename.start = 0 OR $tablename.start < $now ) AND ". |
|
" ( $tablename.end = 0 OR $tablename.end > $now ))"; |
|
} elsif ( $enrollment eq 'Expired' ) { |
|
$enrollment_requirements = |
|
"(( $tablename.start < $now ) AND ". |
|
" ( $tablename.end < $now ))"; |
|
} |
} |
} |
return ($student_requirements,$enrollment_requirements); |
return ($student_requirements,$enrollment_requirements); |
} |
} |
Line 2498 sub score_stats {
|
Line 2511 sub score_stats {
|
my $time_limits = &limit_by_start_end_time($starttime,$endtime,'a'); |
my $time_limits = &limit_by_start_end_time($starttime,$endtime,'a'); |
my @Symbids = map { &get_symb_id($_); } @{$symbs}; |
my @Symbids = map { &get_symb_id($_); } @{$symbs}; |
# |
# |
my $stats_table = $courseid.'_problem_stats'; |
my $stats_table = &temp_table_name($courseid,'problem_stats'); |
my $symb_restriction = join(' OR ',map {'a.symb_id='.$_;} @Symbids); |
my $symb_restriction = join(' OR ',map {'a.symb_id='.$_;} @Symbids); |
my $request = 'DROP TABLE '.$stats_table; |
my $request = 'DROP TABLE '.$stats_table; |
$dbh->do($request); |
$dbh->do($request); |
Line 2577 sub count_stats {
|
Line 2590 sub count_stats {
|
my $time_limits = &limit_by_start_end_time($starttime,$endtime,'a'); |
my $time_limits = &limit_by_start_end_time($starttime,$endtime,'a'); |
my @Symbids = map { &get_symb_id($_); } @{$symbs}; |
my @Symbids = map { &get_symb_id($_); } @{$symbs}; |
# |
# |
my $stats_table = $courseid.'_problem_stats'; |
my $stats_table = &temp_table_name($courseid,'problem_stats'); |
my $symb_restriction = join(' OR ',map {'a.symb_id='.$_;} @Symbids); |
my $symb_restriction = join(' OR ',map {'a.symb_id='.$_;} @Symbids); |
my $request = 'DROP TABLE '.$stats_table; |
my $request = 'DROP TABLE '.$stats_table; |
$dbh->do($request); |
$dbh->do($request); |
Line 2726 sub get_response_data {
|
Line 2739 sub get_response_data {
|
if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) { |
if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) { |
# Clear the \'s from around the submission |
# Clear the \'s from around the submission |
for (my $i =0;$i<scalar(@$dataset);$i++) { |
for (my $i =0;$i<scalar(@$dataset);$i++) { |
$dataset->[$i]->[3] =~ s/(\'$|^\')//g; |
$dataset->[$i]->[&RD_submission()] =~ s/(\'$|^\')//g; |
} |
} |
return $dataset; |
return $dataset; |
} |
} |
Line 2754 sub get_response_data_by_student {
|
Line 2767 sub get_response_data_by_student {
|
# |
# |
my $student_id = &get_student_id($student->{'username'}, |
my $student_id = &get_student_id($student->{'username'}, |
$student->{'domain'}); |
$student->{'domain'}); |
my @group_ids = &get_students_groupids($student_id); |
|
# |
# |
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
return undef if (! defined($dbh)); |
return undef if (! defined($dbh)); |
Line 2788 sub get_response_data_by_student {
|
Line 2800 sub get_response_data_by_student {
|
if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) { |
if (ref($dataset) eq 'ARRAY' && scalar(@$dataset)>0) { |
# Clear the \'s from around the submission |
# Clear the \'s from around the submission |
for (my $i =0;$i<scalar(@$dataset);$i++) { |
for (my $i =0;$i<scalar(@$dataset);$i++) { |
$dataset->[$i]->[2] =~ s/(\'$|^\')//g; |
$dataset->[$i]->[&RDs_submission] =~ s/(\'$|^\')//g; |
} |
} |
return $dataset; |
return $dataset; |
} |
} |
Line 2876 sub get_student_scores {
|
Line 2888 sub get_student_scores {
|
&setup_table_names($courseid); |
&setup_table_names($courseid); |
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
return (undef) if (! defined($dbh)); |
return (undef) if (! defined($dbh)); |
my $tmptable = $courseid.'_temp_'.time; |
my $tmptable = &temp_table_name($courseid,'temp_'.time); |
my $request = 'DROP TABLE IF EXISTS '.$tmptable; |
my $request = 'DROP TABLE IF EXISTS '.$tmptable; |
# &Apache::lonnet::logthis('request = '.$/.$request); |
# &Apache::lonnet::logthis('request = '.$/.$request); |
$dbh->do($request); |
$dbh->do($request); |
Line 2988 sub setup_table_names {
|
Line 3000 sub setup_table_names {
|
} |
} |
# |
# |
# Set up database names |
# Set up database names |
my $base_id = $courseid; |
my $base_id = 'md5_'.&Digest::MD5::md5_hex($courseid); |
$symb_table = $base_id.'_'.'symb'; |
$symb_table = $base_id.'_'.'symb'; |
$part_table = $base_id.'_'.'part'; |
$part_table = $base_id.'_'.'part'; |
$student_table = $base_id.'_'.'student'; |
$student_table = $base_id.'_'.'student'; |
Line 3017 sub setup_table_names {
|
Line 3029 sub setup_table_names {
|
return; |
return; |
} |
} |
|
|
|
sub temp_table_name { |
|
my ($courseid,$affix) = @_; |
|
my $base_id = 'md5_'.&Digest::MD5::md5_hex($courseid); |
|
return $base_id.'_'.$affix; |
|
} |
|
|
################################################ |
################################################ |
################################################ |
################################################ |
|
|
Line 3074 sub CL_FULLNAME { return 6; }
|
Line 3092 sub CL_FULLNAME { return 6; }
|
sub CL_STATUS { return 7; } |
sub CL_STATUS { return 7; } |
sub CL_TYPE { return 8; } |
sub CL_TYPE { return 8; } |
sub CL_LOCKEDTYPE { return 9; } |
sub CL_LOCKEDTYPE { return 9; } |
|
sub CL_GROUP { return 10; } |
|
sub CL_PERMANENTEMAIL { return 11; } |
|
sub CL_ROLE { return 12; } |
|
sub CL_EXTENT { return 13; } |
|
sub CL_PHOTO { return 14; } |
|
sub CL_THUMBNAIL { return 15; } |
|
|
sub get_classlist { |
sub get_classlist { |
my ($cdom,$cnum) = @_; |
my ($cdom,$cnum) = @_; |
Line 3130 sub get_classlist {
|
Line 3154 sub get_classlist {
|
if(((!$end) || $now < $end) && ((!$start) || ($now > $start))) { |
if(((!$end) || $now < $end) && ((!$start) || ($now > $start))) { |
$status='Active'; |
$status='Active'; |
} |
} |
|
if(($now < $start) && ((!$end) || $now < $end )) { |
|
$status='Future'; |
|
} |
$classlist{$student} = |
$classlist{$student} = |
[$sdom,$sname,$end,$start,$id,$section,$fullname,$status,$type,$lockedtype]; |
[$sdom,$sname,$end,$start,$id,$section,$fullname,$status,$type,$lockedtype]; |
} |
} |
Line 3142 sub get_classlist {
|
Line 3169 sub get_classlist {
|
} |
} |
|
|
sub get_group_memberships { |
sub get_group_memberships { |
my ($classlist,$cdom,$cnum) = @_; |
my ($classlist,$keylist,$cdom,$cnum) = @_; |
|
|
|
return ({},{}) if (!ref($classlist) || !ref($keylist)); |
|
|
my $cid = $cdom.'_'.$cnum; |
my $cid = $cdom.'_'.$cnum; |
if (!defined($cdom) || !defined($cnum)) { |
if (!defined($cdom) || !defined($cnum)) { |
$cid = $env{'request.course.id'}; |
$cid = $env{'request.course.id'}; |
Line 3152 sub get_group_memberships {
|
Line 3182 sub get_group_memberships {
|
my (%classgroups,%studentgroups); |
my (%classgroups,%studentgroups); |
my $now = time; |
my $now = time; |
my $access_end = $env{'course.'.$cid.'.default_enrollment_end_date'}; |
my $access_end = $env{'course.'.$cid.'.default_enrollment_end_date'}; |
my (%curr_groups,%groupmemberhash); |
my %curr_groups =&Apache::longroup::coursegroups($cdom,$cnum); |
my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom, |
if (%curr_groups) { |
$cnum); |
my $grpindex = &CL_GROUP(); |
if ($numgroups) { |
my %groupmemberhash = |
%groupmemberhash = &Apache::lonnet::get_group_membership($cdom,$cnum); |
&Apache::lonnet::get_group_membership($cdom,$cnum); |
foreach my $student (keys(%{$classlist})) { |
foreach my $student (keys(%{$classlist})) { |
%{$classgroups{$student}} = (); |
%{$classgroups{$student}} = (); |
my $hasgroup = 0; |
my $hasgroup = 0; |
Line 3196 sub get_group_memberships {
|
Line 3226 sub get_group_memberships {
|
} |
} |
if (!$hasgroup) { |
if (!$hasgroup) { |
$studentgroups{'none'} ++; |
$studentgroups{'none'} ++; |
|
} else { |
|
$classlist->{$student}->[$grpindex] = join(',', |
|
sort(keys(%{$classgroups{$student}{'active'}}))); |
} |
} |
} |
} |
} |
} |