version 1.3, 2004/08/19 21:07:35
|
version 1.4, 2004/08/23 15:03:15
|
Line 71 sub get_all_data {
|
Line 71 sub get_all_data {
|
my $activity_table = $prefix.'activity'; |
my $activity_table = $prefix.'activity'; |
# |
# |
$query = qq{ |
$query = qq{ |
select B.resource,A.time,C.student,D.action,E.machine,A.action_values |
SELECT B.resource,A.time,C.student,D.action,E.machine,A.action_values |
FROM $activity_table AS A |
FROM $activity_table AS A |
LEFT JOIN $res_table AS B ON B.res_id=A.res_id |
LEFT JOIN $res_table AS B ON B.res_id=A.res_id |
LEFT JOIN $student_table AS C ON C.student_id=A.student_id |
LEFT JOIN $student_table AS C ON C.student_id=A.student_id |
LEFT JOIN $action_table AS D ON D.action_id=A.action_id |
LEFT JOIN $action_table AS D ON D.action_id=A.action_id |
LEFT JOIN $machine_table AS E ON E.machine_id=A.machine_id |
LEFT JOIN $machine_table AS E ON E.machine_id=A.machine_id |
LIMIT 500 |
WHERE A.student_id>10 |
|
ORDER BY A.time ASC |
|
LIMIT 5000 |
}; |
}; |
$query =~ s|$/||g; |
$query =~ s|$/||g; |
# &Apache::lonnet::logthis($query); |
&Apache::lonnet::logthis($query); |
## |
## |
## Send it along |
## Send it along |
my $reply=&Apache::lonnet::metadata_query($query,undef,undef,[$home]); |
my $reply=&Apache::lonnet::metadata_query($query,undef,undef,[$home]); |
Line 100 sub get_all_data {
|
Line 102 sub get_all_data {
|
my $maxtime = 500; |
my $maxtime = 500; |
my $starttime = time; |
my $starttime = time; |
while (! -e $endfile && (time-$starttime < $maxtime)) { |
while (! -e $endfile && (time-$starttime < $maxtime)) { |
sleep(1); |
|
&Apache::lonhtmlcommon::Update_PrgWin |
&Apache::lonhtmlcommon::Update_PrgWin |
($r,$prog_state,&mt('Waiting for results')); |
($r,$prog_state,&mt('Waiting up to [_1] seconds for results', |
|
$starttime+$maxtime-time)); |
|
sleep(1); |
} |
} |
if (! -e $endfile) { |
if (! -e $endfile) { |
$r->print('<h2>'. |
$r->print('<h2>'. |
Line 112 sub get_all_data {
|
Line 115 sub get_all_data {
|
} |
} |
&Apache::lonhtmlcommon::Update_PrgWin |
&Apache::lonhtmlcommon::Update_PrgWin |
($r,$prog_state,&mt('Parsing results')); |
($r,$prog_state,&mt('Parsing results')); |
|
&output_results($r,$results_file,$navmap); |
|
&Apache::lonhtmlcommon::Update_PrgWin |
|
($r,$prog_state,&mt('Finished!')); |
|
return; |
|
} |
|
|
|
sub output_results { |
|
my ($r,$results_file,$navmap) = @_; |
if (! open(ACTIVITYDATA,$results_file)) { |
if (! open(ACTIVITYDATA,$results_file)) { |
$r->print('<h2>'. |
$r->print('<h2>'.&mt('Unable to read results file.').'</h2>'. |
&mt('Unable to read results file. This is a serious error and has been logged. You should contact your system administrator to resolve this issue. If you are the system administrator, I feel sorry for you.'). |
'<p>'. |
'</h2>'); |
&mt('This is a serious error and has been logged. '. |
|
'You should contact your system administrator '. |
|
'to resolve this issue.'). |
|
'</p>'); |
return; |
return; |
} |
} |
my $tableheader = |
my $tableheader = |
Line 127 sub get_all_data {
|
Line 141 sub get_all_data {
|
'<th>'.&mt('Originating Server').'</th>'. |
'<th>'.&mt('Originating Server').'</th>'. |
'<th>'.&mt('Data').'</th>'. |
'<th>'.&mt('Data').'</th>'. |
'</tr>'.$/; |
'</tr>'.$/; |
my $count =0; |
my $count = 0; |
$r->print($tableheader); |
$r->print($tableheader); |
$r->rflush(); |
$r->rflush(); |
while (my $line = <ACTIVITYDATA>) { |
while (my $line = <ACTIVITYDATA>) { |
Line 140 sub get_all_data {
|
Line 154 sub get_all_data {
|
my ($symb,$timestamp,$student,$action,$machine,$values) = |
my ($symb,$timestamp,$student,$action,$machine,$values) = |
map { &Apache::lonnet::unescape($_); } split(',',$line,6); |
map { &Apache::lonnet::unescape($_); } split(',',$line,6); |
my ($title,$src); |
my ($title,$src); |
if ($symb =~ m:^/(res|adm)/:) { |
if ($symb =~ m:^/adm/:) { |
$title = $symb; |
$title = $symb; |
$src = $symb; |
$src = $symb; |
|
} elsif ($symb eq '/prtspool/') { |
|
$title = "Printout"; |
|
$src = undef; |
} else { |
} else { |
# We may need to add 'uploaded/' to the symb |
my $nav_res = $navmap->getBySymb($symb); |
# |
if (defined($nav_res)) { |
# Hey, guess what - navmaps->getBySymb |
$title = $nav_res->title(); |
# does not work with uploaded resources/new style courses/something |
$src = $nav_res->src(); |
# The fact that our symbs do not have uploaded/ prepended to them |
} else { |
# then they (most often but not always) should, is likely to be |
$title = 'unable to retrieve title'; |
# a puzzle too. |
$src = '/dev/null'; |
#&Apache::lonnet::logthis('trackstudent:symb = '.$symb); |
} |
# my $nav_res = $navmap->getBySymb($symb); |
|
$title = 'resource title goes here'; # $nav_res->title(); |
|
$src = '/dev/null'; # $nav_res->src(); |
|
} |
} |
$r->print('<tr>'. |
my $class = ''; |
'<td>'.'<a href="'.$src.'">'.$title.'</a>'.'</td>'. |
# |
|
if ($symb eq '/printout/') { |
|
$class = 'print'; |
|
$title = 'retrieve printout'; |
|
} elsif ($symb =~ m|^/adm/([^/]+)|) { |
|
$class = $1; |
|
} elsif ($symb =~ m|^/adm/|) { |
|
$class = 'adm'; |
|
} |
|
if ($title eq 'unable to retrieve title') { |
|
$title =~ s/ /\ /g; |
|
$class = 'warning'; |
|
} |
|
if (! defined($title) || $title eq '') { |
|
$title = 'untitled'; |
|
$class = 'warning'; |
|
} |
|
$r->print('<tr class="'.$class.'">'. |
|
'<td><a href="'.$src.'">'.$title.'</a>'.'</td>'. |
'<td><nobr>'.$timestamp.'</nobr></td>'. |
'<td><nobr>'.$timestamp.'</nobr></td>'. |
'<td>'.$student.'</td>'. |
'<td>'.$student.'</td>'. |
'<td>'.$action.'</td>'. |
'<td>'.$action.'</td>'. |
'<td>'.$machine.'</td>'. |
'<td>'.$machine.'</td>'. |
'<td>'.$values.'</td>'.'</tr>'.$/); |
'<td>'.($class?$symb:'').'</td>'.'</tr>'.$/); |
|
# '<td>'.$symb.'</td>'.'</tr>'.$/); |
} |
} |
$r->print('</table>'.$/); |
$r->print('</table>'.$/); |
close(ACTIVITYDATA); |
close(ACTIVITYDATA); |
&Apache::lonhtmlcommon::Update_PrgWin |
|
($r,$prog_state,&mt('Finished!')); |
|
return; |
return; |
} |
} |
|
|
Line 190 sub request_data_update {
|
Line 221 sub request_data_update {
|
################################################################### |
################################################################### |
################################################################### |
################################################################### |
|
|
|
sub styles { |
|
return <<END; |
|
<STYLE TYPE="text/css"> |
|
tr.warning { background-color: red; } |
|
tr.chat { background-color: yellow; } |
|
tr.chatfetch { background-color: yellow; } |
|
tr.navmaps { background-color: \#777777; } |
|
tr.roles { background-color: \#999999; } |
|
tr.flip { background-color: \#BBBBBB; } |
|
tr.adm { background-color: green; } |
|
tr.print { background-color: blue; } |
|
tr.printout { background-color: blue; } |
|
</STYLE> |
|
END |
|
} |
|
|
################################################################### |
################################################################### |
################################################################### |
################################################################### |
Line 241 sub handler {
|
Line 287 sub handler {
|
bug=>'instructor interface'}); |
bug=>'instructor interface'}); |
# |
# |
# Give the LON-CAPA page header |
# Give the LON-CAPA page header |
$r->print('<html><head><title>'. |
$r->print('<html><head>'.&styles.'<title>'. |
&mt('Student Activity'). |
&mt('Student Activity'). |
"</title></head>\n". |
"</title></head>\n". |
&Apache::loncommon::bodytag('Student Activity'). |
&Apache::loncommon::bodytag('Student Activity'). |
Line 267 sub handler {
|
Line 313 sub handler {
|
if (ref($result) eq 'HASH') { |
if (ref($result) eq 'HASH') { |
$result = join(' ',map { $_.'=>'.$result->{$_}; } keys(%$result)); |
$result = join(' ',map { $_.'=>'.$result->{$_}; } keys(%$result)); |
} |
} |
$r->print('<h2>'.$result.'</h2>'); |
&Apache::lonnet::logthis('result from request_data_update: '.$result); |
# |
# |
if (! exists($ENV{'form.selected_student'})) { |
if (! exists($ENV{'form.selected_student'})) { |
# Choose a student |
# For now, just show all the data, in the future allow selection of |
$r->print('If you worked here you would be done by now'); |
# a student |
|
&get_all_data($r,\%prog_state,$navmap); |
} else { |
} else { |
# Show a students activity |
# For now, just show all the data instead of limiting it to one student |
$r->print('I would like to have something to show you but I do not.'); |
&get_all_data($r,\%prog_state,$navmap); |
} |
} |
# |
# |
&get_all_data($r,\%prog_state,$navmap); |
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Done')); |
|
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
# &Apache::lonhtmlcommon::Update_PrgWin |
|
# ($r,\%prog_state,&mt('Done')); |
|
|
|
# |
# |
$r->print("</form>\n"); |
$r->print("</form>\n"); |
$r->print("</body>\n</html>\n"); |
$r->print("</body>\n</html>\n"); |