version 1.155, 2006/02/05 19:14:58
|
version 1.166, 2006/05/01 05:27:28
|
Line 49 Set of functions that download and proce
|
Line 49 Set of functions that download and proce
|
package Apache::loncoursedata; |
package Apache::loncoursedata; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
|
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonhtmlcommon; |
use Apache::lonhtmlcommon; |
use Time::HiRes; |
use Time::HiRes; |
Line 66 and/or itself.
|
Line 65 and/or itself.
|
|
|
=cut |
=cut |
|
|
sub LoadDiscussion { |
|
my ($courseID)=@_; |
|
my %Discuss=(); |
|
my %contrib=&Apache::lonnet::dump( |
|
$courseID, |
|
$env{'course.'.$courseID.'.domain'}, |
|
$env{'course.'.$courseID.'.num'}); |
|
|
|
#my %contrib=&DownloadCourseInformation($name, $courseID, 0); |
|
|
|
foreach my $temp(keys %contrib) { |
|
if ($temp=~/^version/) { |
|
my $ver=$contrib{$temp}; |
|
my ($dummy,$prb)=split(':',$temp); |
|
for (my $idx=1; $idx<=$ver; $idx++ ) { |
|
my $name=$contrib{"$idx:$prb:sendername"}; |
|
$Discuss{"$name:$prb"}=$idx; |
|
} |
|
} |
|
} |
|
|
|
return \%Discuss; |
|
} |
|
|
|
################################################ |
################################################ |
################################################ |
################################################ |
|
|
Line 229 The response table holds data (documente
|
Line 204 The response table holds data (documente
|
associated with a particular response id which is stored when a student |
associated with a particular response id which is stored when a student |
attempts a problem. The following are the columns of the table, in order: |
attempts a problem. The following are the columns of the table, in order: |
'symb_id','part_id','response_id','student_id','transaction','tries', |
'symb_id','part_id','response_id','student_id','transaction','tries', |
'awarddetail', 'response_specific' (data particular to the response |
'awarddetail', 'response_specific', 'response_specific_value', |
type), 'response_specific_value', and 'submission (the text of the students |
'response_specific_2', 'response_specific_value_2', and 'submission |
submission). The primary key is based on the first five columns listed above. |
(the text of the students submission). The primary key is based on the |
|
first five columns listed above. |
|
|
=item $fulldump_part_table |
=item $fulldump_part_table |
|
|
Line 491 sub init_dbs {
|
Line 467 sub init_dbs {
|
type => 'TINYTEXT' }, |
type => 'TINYTEXT' }, |
{ name => 'response_specific_value', |
{ name => 'response_specific_value', |
type => 'TINYTEXT' }, |
type => 'TINYTEXT' }, |
|
{ name => 'response_specific_2', |
|
type => 'TINYTEXT' }, |
|
{ name => 'response_specific_value_2', |
|
type => 'TINYTEXT' }, |
{ name => 'submission', |
{ name => 'submission', |
type => 'TEXT'}, |
type => 'TEXT'}, |
], |
], |
Line 922 sub clear_internal_caches {
|
Line 902 sub clear_internal_caches {
|
undef(%students_by_id); |
undef(%students_by_id); |
} |
} |
|
|
|
|
|
################################################ |
|
################################################ |
|
|
|
sub symb_is_for_task { |
|
my ($symb) = @_; |
|
return ($symb =~ /\.task$/); |
|
} |
|
|
################################################ |
################################################ |
################################################ |
################################################ |
|
|
Line 973 sub update_full_student_data {
|
Line 962 sub update_full_student_data {
|
# |
# |
# Download students data |
# Download students data |
my $time_of_retrieval = time; |
my $time_of_retrieval = time; |
my @tmp = &Apache::lonnet::dump($courseid,$sdom,$sname); |
my @tmp = &Apache::lonnet::dumpstore($courseid,$sdom,$sname); |
if (@tmp && $tmp[0] =~ /^error/) { |
if (@tmp && $tmp[0] =~ /^error/) { |
$returnstatus = 'error retrieving full student data'; |
$returnstatus = 'error retrieving full student data'; |
return $returnstatus; |
return $returnstatus; |
Line 1013 sub update_full_student_data {
|
Line 1002 sub update_full_student_data {
|
next; |
next; |
} elsif ($parameter eq 'version') { |
} elsif ($parameter eq 'version') { |
next; |
next; |
} elsif ($parameter =~ /^resource\.(.*)\.(tries| |
} elsif (&symb_is_for_task($symb)) { |
|
next if ($parameter !~ /^resource\.(.*)\.(award| |
|
awarded| |
|
solved| |
|
submission| |
|
portfiles| |
|
status| |
|
version| |
|
regrader)\s*$/x); |
|
my ($version_and_part_id, $field) = ($1,$2); |
|
|
|
next if ($version_and_part_id !~ /\./ |
|
&& $field ne 'regrader' && $field ne 'version'); |
|
|
|
my ($version, $part, $instance) = |
|
split(/\./,$version_and_part_id); |
|
|
|
#skip and instance dimension or criteria specific data |
|
next if (defined($instance) |
|
&& $instance ne $field |
|
&& $instance ne 'bridgetask'); |
|
|
|
if (!defined($part)) { |
|
$part = $version; |
|
} |
|
my $resp_id = &get_part_id('0'); |
|
my $part_id = &get_part_id($part); |
|
|
|
if ($field eq 'version') { |
|
# for tasks each version is an attempt at it thus |
|
# version -> tries |
|
$partdata->{$symb_id}{$part_id}{$transaction}{'tries'}= |
|
$value; |
|
# at new version time the record gets reset thus adding a |
|
# virtual response awarddetail of 'new_version' |
|
$respdata->{$symb_id}{$part_id}{$resp_id}{$transaction}{'response_specific'}='status'; |
|
$respdata->{$symb_id}{$part_id}{$resp_id}{$transaction}{'response_specific_value'}='new_version'; |
|
|
|
} elsif ($field eq 'award' || $field eq 'awarded' |
|
|| $field eq 'solved') { |
|
$partdata->{$symb_id}{$part_id}{$transaction}{$field}= |
|
$value; |
|
} elsif ($field eq 'portfiles') { |
|
# tasks only accepts portfolio submissions |
|
$value = $dbh->quote($value); |
|
$respdata->{$symb_id}{$part_id}{$resp_id}{$transaction}{'submission'}=$value; |
|
} elsif ($field eq 'status') { |
|
$respdata->{$symb_id}{$part_id}{$resp_id}{$transaction}{'response_specific'}=$field; |
|
$respdata->{$symb_id}{$part_id}{$resp_id}{$transaction}{'response_specific_value'}=$value; |
|
} elsif ($field eq 'regrader') { |
|
$respdata->{$symb_id}{$part_id}{$resp_id}{$transaction}{'response_specific_2'}=$field; |
|
$respdata->{$symb_id}{$part_id}{$resp_id}{$transaction}{'response_specific_value_2'}=$value; |
|
} |
|
} elsif ($parameter =~ /^resource\.(.*)\.(tries| |
award| |
award| |
awarded| |
awarded| |
previous| |
previous| |
Line 1111 sub update_full_student_data {
|
Line 1153 sub update_full_student_data {
|
$transaction, |
$transaction, |
$data->{'awarddetail'}, |
$data->{'awarddetail'}, |
$data->{'response_specific'}, |
$data->{'response_specific'}, |
$data->{'response_specific_value'}). |
$data->{'response_specific_value'}, |
|
$data->{'response_specific_2'}, |
|
$data->{'response_specific_value_2'}). |
"',".$submission."),"; |
"',".$submission."),"; |
$store_rows++; |
$store_rows++; |
} |
} |
Line 1290 sub store_student_data {
|
Line 1334 sub store_student_data {
|
my %stored; |
my %stored; |
while (my ($parameter,$value) = each(%$param_hash)) { |
while (my ($parameter,$value) = each(%$param_hash)) { |
next if ($parameter !~ /^resource\.(.*)\.(solved|awarded)$/); |
next if ($parameter !~ /^resource\.(.*)\.(solved|awarded)$/); |
my $part = $1; |
my $part = $1; |
|
my $which = $2; |
next if ($part =~ /\./); |
next if ($part =~ /\./); |
next if (exists($stored{$part})); |
next if (exists($stored{$part})); |
$stored{$part}++; |
$stored{$part}++; |
# |
# |
my $part_id = &get_part_id($part); |
my $part_id = &get_part_id($part); |
next if (!defined($part_id)); |
next if (!defined($part_id)); |
my $solved = $value; |
|
my $tries = $param_hash->{'resource.'.$part.'.tries'}; |
my ($solved,$awarded); |
my $awarded = $param_hash->{'resource.'.$part.'.awarded'}; |
if ($which eq 'solved') { |
|
$solved = $value; |
|
$awarded = $param_hash->{'resource.'.$part.'.awarded'}; |
|
} else { |
|
$solved = $param_hash->{'resource.'.$part.'.solved'}; |
|
$awarded = $value; |
|
} |
my $award = $param_hash->{'resource.'.$part.'.award'}; |
my $award = $param_hash->{'resource.'.$part.'.award'}; |
my $awarddetail = $param_hash->{'resource.'.$part.'.awarddetail'}; |
my $awarddetail = $param_hash->{'resource.'.$part.'.awarddetail'}; |
my $timestamp = $param_hash->{'timestamp'}; |
my $timestamp = $param_hash->{'timestamp'}; |
|
my $tries = $param_hash->{'resource.'.$part.'.tries'}; |
|
if (&symb_is_for_task($current_symb)) { |
|
$tries = $param_hash->{'resource.'.$part.'.version'}; |
|
} |
# |
# |
$solved = '' if (! defined($solved)); |
$solved = '' if (! defined($solved)); |
$tries = '' if (! defined($tries)); |
$tries = '' if (! defined($tries)); |
Line 2347 sub get_student_data {
|
Line 2402 sub get_student_data {
|
} |
} |
} |
} |
|
|
sub RD_student_id { return 0; } |
sub RD_student_id { return 0; } |
sub RD_awarddetail { return 1; } |
sub RD_awarddetail { return 1; } |
sub RD_response_eval { return 2; } |
sub RD_response_eval { return 2; } |
sub RD_submission { return 3; } |
sub RD_response_eval_2 { return 3; } |
sub RD_timestamp { return 4; } |
sub RD_submission { return 4; } |
sub RD_tries { return 5; } |
sub RD_timestamp { return 5; } |
sub RD_sname { return 6; } |
sub RD_tries { return 6; } |
|
sub RD_sname { return 7; } |
|
|
sub get_response_data { |
sub get_response_data { |
my ($Sections,$enrollment,$symb,$response,$courseid) = @_; |
my ($Sections,$enrollment,$symb,$response,$courseid) = @_; |
Line 2380 sub get_response_data {
|
Line 2436 sub get_response_data {
|
&limit_by_section_and_status($Sections,$enrollment,'d'); |
&limit_by_section_and_status($Sections,$enrollment,'d'); |
my $request = 'SELECT '. |
my $request = 'SELECT '. |
'a.student_id, a.awarddetail, a.response_specific_value, '. |
'a.student_id, a.awarddetail, a.response_specific_value, '. |
'a.submission, b.timestamp, c.tries, d.student '. |
'a.response_specific_value_2, a.submission, b.timestamp, '. |
|
'c.tries, d.student '. |
'FROM '.$fulldump_response_table.' AS a '. |
'FROM '.$fulldump_response_table.' AS a '. |
'LEFT JOIN '.$fulldump_timestamp_table.' AS b '. |
'LEFT JOIN '.$fulldump_timestamp_table.' AS b '. |
'ON a.symb_id=b.symb_id AND a.student_id=b.student_id AND '. |
'ON a.symb_id=b.symb_id AND a.student_id=b.student_id AND '. |
Line 2422 sub get_response_data {
|
Line 2479 sub get_response_data {
|
} |
} |
|
|
|
|
sub RDs_awarddetail { return 3; } |
sub RDs_awarddetail { return 3; } |
sub RDs_submission { return 2; } |
sub RDs_submission { return 2; } |
sub RDs_timestamp { return 1; } |
sub RDs_timestamp { return 1; } |
sub RDs_tries { return 0; } |
sub RDs_tries { return 0; } |
sub RDs_awarded { return 4; } |
sub RDs_awarded { return 4; } |
|
sub RDs_response_eval { return 5; } |
|
sub RDs_response_eval_2 { return 6; } |
|
sub RDs_part_award { return 7; } |
|
|
sub get_response_data_by_student { |
sub get_response_data_by_student { |
my ($student,$symb,$response,$courseid) = @_; |
my ($student,$symb,$response,$courseid) = @_; |
Line 2444 sub get_response_data_by_student {
|
Line 2504 sub get_response_data_by_student {
|
my $dbh = &Apache::lonmysql::get_dbh(); |
my $dbh = &Apache::lonmysql::get_dbh(); |
return undef if (! defined($dbh)); |
return undef if (! defined($dbh)); |
my $request = 'SELECT '. |
my $request = 'SELECT '. |
'c.tries, b.timestamp, a.submission, a.awarddetail, e.awarded '. |
'c.tries, b.timestamp, a.submission, a.awarddetail, c.awarded, '. |
|
'a.response_specific_value, a.response_specific_value_2, c.award '. |
'FROM '.$fulldump_response_table.' AS a '. |
'FROM '.$fulldump_response_table.' AS a '. |
'LEFT JOIN '.$fulldump_timestamp_table.' AS b '. |
'LEFT JOIN '.$fulldump_timestamp_table.' AS b '. |
'ON a.symb_id=b.symb_id AND a.student_id=b.student_id AND '. |
'ON a.symb_id=b.symb_id AND a.student_id=b.student_id AND '. |
Line 2813 sub get_classlist {
|
Line 2874 sub get_classlist {
|
} |
} |
} |
} |
|
|
|
sub get_group_memberships { |
|
my ($classlist,$cdom,$cnum) = @_; |
|
my $cid = $cdom.'_'.$cnum; |
|
if (!defined($cdom) || !defined($cnum)) { |
|
$cid = $env{'request.course.id'}; |
|
$cdom = $env{'course.'.$cid.'.domain'}; |
|
$cnum = $env{'course.'.$cid.'.num'}; |
|
} |
|
my (%classgroups,%studentgroups); |
|
my $now = time; |
|
my $access_end = $env{'course.'.$cid.'.default_enrollment_end_date'}; |
|
my (%curr_groups,%groupmemberhash); |
|
my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom, |
|
$cnum); |
|
if ($numgroups) { |
|
%groupmemberhash = &Apache::lonnet::get_group_membership($cdom,$cnum); |
|
foreach my $student (keys(%{$classlist})) { |
|
%{$classgroups{$student}} = (); |
|
my $hasgroup = 0; |
|
foreach my $status ('previous','future','active','aftercourse') { |
|
%{$classgroups{$student}{$status}} = (); |
|
} |
|
foreach my $group (keys(%curr_groups)) { |
|
if (defined($groupmemberhash{$group.':'.$student})) { |
|
my ($end,$start) = split(/:/,$groupmemberhash{$group.':'. |
|
$student}); |
|
if ($start == -1) { |
|
next; |
|
} else { |
|
$studentgroups{$group} ++; |
|
$hasgroup = 1; |
|
if ($end && $end < $now) { |
|
$classgroups{$student}{'previous'}{$group} = |
|
$groupmemberhash{$group.':'.$student}; |
|
if ($classlist->{$student}[&CL_STATUS()] eq 'Expired') { |
|
if ($access_end && $access_end < $now) { |
|
if ($access_end - $end < 86400) { |
|
$classgroups{$student}{'aftercourse'}{$group} = $groupmemberhash{$group.':'.$student}; |
|
} |
|
} |
|
} |
|
} elsif ($now > $start) { |
|
if (!$end || $end > $now) { |
|
$classgroups{$student}{'active'}{$group} = |
|
$groupmemberhash{$group.':'.$student}; |
|
} |
|
} else { |
|
$classgroups{$student}{'future'}{$group} = |
|
$groupmemberhash{$group.':'.$student}; |
|
} |
|
} |
|
} |
|
} |
|
if (!$hasgroup) { |
|
$studentgroups{'none'} ++; |
|
} |
|
} |
|
} |
|
return (\%classgroups,\%studentgroups); |
|
} |
|
|
|
sub get_students_groups { |
|
my ($student,$enrollment_status,$classgroups) = @_; |
|
my @studentsgroups = (); |
|
if (ref($$classgroups{$student}{'active'}) eq 'HASH') { |
|
push(@studentsgroups,keys(%{$$classgroups{$student}{'active'}})); |
|
} |
|
if ($enrollment_status eq 'Any') { |
|
foreach my $status ('previous','future') { |
|
if (ref($$classgroups{$student}{$status}) eq 'HASH') { |
|
push(@studentsgroups,keys(%{$$classgroups{$student}{$status}})); |
|
} |
|
} |
|
} else { |
|
if (ref($$classgroups{$student}{'aftercourse'}) eq 'HASH') { |
|
push(@studentsgroups,keys(%{$$classgroups{$student}{'aftercourse'}})); |
|
} |
|
} |
|
return @studentsgroups; |
|
} |
|
|
|
|
# ----- END HELPER FUNCTIONS -------------------------------------------- |
# ----- END HELPER FUNCTIONS -------------------------------------------- |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
|