version 1.200, 2016/08/14 16:13:21
|
version 1.203, 2018/03/11 12:44:22
|
Line 1423 sub ensure_current_sections {
|
Line 1423 sub ensure_current_sections {
|
$updatetime = $tableinfo{'Update_time'}; |
$updatetime = $tableinfo{'Update_time'}; |
} |
} |
if ((!defined($updatetime)) || ($modifiedtime > $updatetime)) { |
if ((!defined($updatetime)) || ($modifiedtime > $updatetime)) { |
if (&Apache::lonmysql::drop_table($student_table)) { |
&update_student_table($cdom,$cnum); |
if (&init_dbs($courseid)) { |
} |
return "error creating $student_table\n"; |
return; |
} else { |
} |
&populate_student_table($courseid); |
|
|
sub update_student_table { |
|
my ($cdom,$cnum) = @_; |
|
return unless (($cdom ne '') && ($cnum ne '')); |
|
my (%roster,%sqldata); |
|
my $classlist = &get_classlist($cdom,$cnum); |
|
while (my ($student,$data) = each (%$classlist)) { |
|
my ($section,$start,$end) = ($data->[&CL_SECTION()], |
|
$data->[&CL_START()], |
|
$data->[&CL_END()]); |
|
if ($section eq '' || $section =~ /^\s*$/) { |
|
$section = 'none'; |
|
} |
|
if ($start eq '') { $start = 0; } |
|
if ($end eq '') { $end = 0; } |
|
$roster{$student}{'section'} = $section; |
|
$roster{$student}{'start'} = $start; |
|
$roster{$student}{'end'} = $end; |
|
} |
|
my $dbh = &Apache::lonmysql::get_dbh(); |
|
my $statement = "SELECT student_id,student,section,start,end FROM $student_table"; |
|
my $sth = $dbh->prepare($statement); |
|
$sth->execute(); |
|
if ($sth->err()) { |
|
&Apache::lonnet::logthis("Unable to execute MySQL request:"); |
|
&Apache::lonnet::logthis("\n".$statement."\n"); |
|
&Apache::lonnet::logthis("error is:".$sth->errstr()); |
|
return undef; |
|
} |
|
foreach my $row (@{$sth->fetchall_arrayref}) { |
|
my ($id,$student,$section,$start,$end) = (@$row); |
|
if (ref($roster{$student}) eq 'HASH') { |
|
if (($roster{$student}{'section'} ne $section) || |
|
($roster{$student}{'start'} ne $start) || |
|
($roster{$student}{'end'} ne $end)) { |
|
$sqldata{$id} = { |
|
section => $roster{$student}{'section'}, |
|
start => $roster{$student}{'start'}, |
|
end => $roster{$student}{'end'}, |
|
}; |
} |
} |
} |
} |
} |
} |
|
$sth->finish(); |
|
if (keys(%sqldata)) { |
|
foreach my $id (sort { $a <=> $b } keys(%sqldata)) { |
|
my $request = "UPDATE $student_table SET section='$sqldata{$id}{section}'". |
|
", start='$sqldata{$id}{start}'". |
|
", end='$sqldata{$id}{end}' WHERE student_id='$id'"; |
|
$dbh->do($request); |
|
} |
|
} |
return; |
return; |
} |
} |
|
|
Line 1727 sub populate_weight_table {
|
Line 1775 sub populate_weight_table {
|
my @resources; |
my @resources; |
foreach my $seq (@sequences) { |
foreach my $seq (@sequences) { |
push(@resources,$navmap->retrieveResources($seq, |
push(@resources,$navmap->retrieveResources($seq, |
sub {shift->is_problem();}, |
sub {shift->is_gradable();}, |
0,0,0)); |
0,0,0)); |
} |
} |
if (! scalar(@resources)) { |
if (! scalar(@resources)) { |
Line 1885 sub rank_students_by_scores_on_resources
|
Line 1933 sub rank_students_by_scores_on_resources
|
$limits =~ s/( AND )$//; # Remove extra conjunction |
$limits =~ s/( AND )$//; # Remove extra conjunction |
$request .= "WHERE $limits"; |
$request .= "WHERE $limits"; |
} |
} |
$request .= " $award_clause GROUP BY a.student_id ORDER BY score"; |
$request .= " $award_clause GROUP BY a.student_id ORDER BY score, b.student"; |
#&Apache::lonnet::logthis('request = '.$/.$request); |
#&Apache::lonnet::logthis('request = '.$/.$request); |
my $sth = $dbh->prepare($request) or die "Can't prepare $request"; |
my $sth = $dbh->prepare($request) or die "Can't prepare $request"; |
$sth->execute(); |
$sth->execute(); |