Annotation of loncom/interface/lonchart.pm, revision 1.39

1.1       www         1: # The LearningOnline Network with CAPA
1.25      minaeibi    2: # (Publication Handler
                      3: #
1.39    ! stredwic    4: # $Id: lonchart.pm,v 1.38 2002/05/09 17:06:09 www Exp $
1.25      minaeibi    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.1       www        28: # Homework Performance Chart
                     29: #
                     30: # (Navigate Maps Handler
                     31: #
                     32: # (Page Handler
                     33: #
                     34: # (TeX Content Handler
1.27      minaeibi   35: # YEAR=2000
1.1       www        36: # 05/29/00,05/30 Gerd Kortemeyer)
                     37: # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23,
                     38: # 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer)
1.27      minaeibi   39: # YEAR=2001
1.14      minaeibi   40: # 3/1/1,6/1,17/1,29/1,30/1,31/1 Gerd Kortemeyer)
1.5       minaeibi   41: # 7/10/01 Behrouz Minaei
1.6       www        42: # 9/8 Gerd Kortemeyer
1.27      minaeibi   43: # 10/1, 10/19, 11/17, 11/22, 11/24, 11/28 12/18 Behrouz Minaei
                     44: # YEAR=2002
1.33      minaeibi   45: # 2/1, 2/6, 2/19, 2/28 Behrouz Minaei
1.26      minaeibi   46: #
                     47: ###
1.1       www        48: 
                     49: package Apache::lonchart;
                     50: 
                     51: use strict;
                     52: use Apache::Constants qw(:common :http);
                     53: use Apache::lonnet();
1.28      albertel   54: use Apache::loncommon();
1.1       www        55: use HTML::TokeParser;
                     56: use GDBM_File;
                     57: 
                     58: # -------------------------------------------------------------- Module Globals
                     59: my %hash;
1.30      minaeibi   60: my %CachData;
1.1       www        61: my @cols;
                     62: my @rowlabels;
                     63: my @students;
1.30      minaeibi   64: my @PreCol;
                     65: my $r;
1.33      minaeibi   66:  
1.1       www        67: # ------------------------------------------------------------- Find out status
                     68: 
1.5       minaeibi   69: sub ExtractStudentData {
                     70:     my ($index,$coid)=@_;
                     71:     my ($sname,$sdom) = split( /\:/, $students[$index] );
1.39    ! stredwic   72:     my %result=&Apache::lonnet::dump($coid,$sdom,$sname);
1.5       minaeibi   73:     my $ResId;
                     74:     my $Code;
                     75:     my $Tries;
                     76:     my $Wrongs;
1.7       minaeibi   77:     my %TempHash;
1.5       minaeibi   78:     my $Version;
1.10      minaeibi   79:     my $ProbNo;
1.26      minaeibi   80:     my $ProbSolved;
                     81:     my $ProbTotal;
1.22      minaeibi   82:     my $LatestVersion;                     
1.5       minaeibi   83:     my $Str=substr($students[$index].
                     84:             '                                                        ',0,14).' ! '.
                     85:             substr($rowlabels[$index].
                     86:             '                                                        ',0,45).' ! ';
1.39    ! stredwic   87: 
        !            88:     $ProbNo = 0;
        !            89:     $ProbTotal = 0;
        !            90:     $ProbSolved = 0;
        !            91:     my $IterationNo = 0;
        !            92:     foreach $ResId (@cols) {
        !            93: 	if ($IterationNo == 0) {$IterationNo++; next;}
        !            94: 	if (!$ResId) { 
        !            95: 	    my $PrNo = sprintf( "%3d", $ProbNo );
        !            96: 	    $Str .= ' '.'<font color="#007700">'.$PrNo.'</font> ';
        !            97: 	    $ProbSolved += $ProbNo;
        !            98: 	    $ProbNo=0;
        !            99: 	    next; 
        !           100: 	}
        !           101: 	$ResId=~/(\d+)\.(\d+)/;
        !           102: 	my $meta=$hash{'src_'.$ResId};
        !           103: 	my $PartNo = 0;
        !           104: 	undef %TempHash;
        !           105: 	foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) {
        !           106: 	    if ($_=~/^stores\_(\d+)\_tries$/) {
        !           107: 		my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
        !           108: 		if ( $TempHash{"$Part"} eq '' ) { 
        !           109: 		    $TempHash{"$Part"} = $Part;
        !           110: 		    $TempHash{$PartNo}=$Part;
        !           111: 		    $TempHash{"$Part.Code"} = ' ';  
        !           112: 		    $PartNo++;
        !           113: 		}
1.10      minaeibi  114: 	    }
1.39    ! stredwic  115: 	}
1.11      minaeibi  116: 
1.39    ! stredwic  117: 	my $Prob = &Apache::lonnet::symbclean(
        !           118: 		       &Apache::lonnet::declutter($hash{'map_id_'.$1} ).
1.5       minaeibi  119:                        '___'.$2.'___'.
1.38      www       120:                        &Apache::lonnet::declutter( $hash{'src_'.$ResId} ));
1.39    ! stredwic  121: 	$Code=' ';
        !           122: 	$Tries = 0;
        !           123: 	$LatestVersion = $result{"version:$Prob"};
        !           124: 
        !           125: 	if ( $LatestVersion ) {
        !           126: 	    for ( my $Version=1; $Version<=$LatestVersion; $Version++ ) {
        !           127: 		my $vkeys = $result{"$Version:keys:$Prob"};
        !           128: 		my @keys = split(/\:/,$vkeys);		  
        !           129: 
        !           130: 		foreach my $Key (@keys) {		  
        !           131: 		    if (($Key=~/\.(\w+)\.solved$/) && ($Key!~/^\d+\:/)) {
        !           132: 			my $Part = $1;
        !           133: 			$Tries = $result{"$Version:$Prob:resource.$Part.tries"};
        !           134: 			$TempHash{"$Part.Tries"}=($Tries) ? $Tries : 0;
        !           135: 			my $Val = $result{"$Version:$Prob:resource.$Part.solved"};
        !           136: 			if ($Val eq 'correct_by_student'){$Code='*';} 
        !           137: 			elsif ($Val eq 'correct_by_override'){$Code = '+';}
        !           138: 			elsif ($Val eq 'incorrect_attempted'){$Code = '.';} 
        !           139: 			elsif ($Val eq 'incorrect_by_override'){$Code = '-';}
        !           140: 			elsif ($Val eq 'excused'){$Code = 'x';}
        !           141: 			elsif ($Val eq 'ungraded_attempted'){$Code = '#';}
        !           142: 			else {$Code = ' ';}
        !           143: 
        !           144: 			$TempHash{"$Part.Code"} = $Code;
        !           145: 		    }
        !           146: 		}
        !           147: 	    }
1.38      www       148: # Actually append problem to output (all parts)
1.39    ! stredwic  149: 	    $Str.='<a href="/adm/grades?symb='.
1.38      www       150:                 &Apache::lonnet::escape($Prob).
                    151:                 '&student='.$sname.'&domain='.$sdom.'&command=submission">'; 
1.39    ! stredwic  152: 	    for ( my $n = 0; $n < $PartNo; $n++ ) {		  
        !           153: 		my $part = $TempHash{$n};
        !           154: 		my $Code = $TempHash{"$part.Code"};
        !           155: 		if ( $Code eq '*') {
        !           156: 		    $ProbNo++;
        !           157: 		    if (($TempHash{"$part.Tries"}<10) ||
        !           158: 			($TempHash{"$part.Tries"} eq '')) {
        !           159: 			$TempHash{"$part.Code"}=$TempHash{"$part.Tries"};
        !           160: 		    }
1.26      minaeibi  161: 		}
1.39    ! stredwic  162: 		elsif ( $Code eq '+' ) {$ProbNo++;}
        !           163: 		$Str .= $TempHash{"$part.Code"};
        !           164: 		if ( $Code ne 'x' ) {$ProbTotal++;}
        !           165: 	    }
        !           166: 	    $Str.='</a>';
        !           167: 	} else {
        !           168: 	    for(my $n=0; $n<$PartNo; $n++) {
        !           169: 		$Str.=' ';
        !           170: 		$ProbTotal++;
1.26      minaeibi  171: 	    }
1.39    ! stredwic  172: 	}
1.1       www       173:     }
1.39    ! stredwic  174: 
1.26      minaeibi  175:     my $PrTot = sprintf( "%5d", $ProbTotal );
                    176:     my $PrSvd = sprintf( "%5d", $ProbSolved );
                    177:     $Str .= ' '.'<font color="#000088">'.$PrSvd.'  /'.$PrTot.'</font> ';
1.11      minaeibi  178: 
1.10      minaeibi  179:     return $Str ;
1.1       www       180: }
                    181: 
1.5       minaeibi  182: 
1.1       www       183: # ------------------------------------------------------------ Build page table
                    184: 
                    185: sub tracetable {
                    186:     my ($rid,$beenhere)=@_;
                    187:     unless ($beenhere=~/\&$rid\&/) {
                    188:        $beenhere.=$rid.'&';  
1.7       minaeibi  189: # new ... updating the map according to sequence and page
1.1       www       190:        if (defined($hash{'is_map_'.$rid})) {
1.7       minaeibi  191: 	   my $cmap=$hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}};
                    192:            if ( $cmap eq 'sequence' || $cmap eq 'page' ) { 
1.1       www       193:                $cols[$#cols+1]=0; 
                    194:            }
                    195:            if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
                    196:                (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {
                    197:               my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
                    198: 
                    199:                 &tracetable($hash{'map_start_'.$hash{'src_'.$rid}},
                    200:                 '&'.$frid.'&');
                    201: 
                    202:               if ($hash{'src_'.$frid}) {
                    203:                  if ($hash{'src_'.$frid}=~
                    204:                                  /\.(problem|exam|quiz|assess|survey|form)$/) {
                    205: 		     $cols[$#cols+1]=$frid;
                    206:                  }
                    207: 	      }
                    208: 
                    209: 	   }
                    210:        } else {
                    211:           if ($hash{'src_'.$rid}) {
                    212:              if ($hash{'src_'.$rid}=~
                    213:                                  /\.(problem|exam|quiz|assess|survey|form)$/) {
                    214: 	         $cols[$#cols+1]=$rid;
                    215:              }
                    216:           }
                    217:        }
                    218:        if (defined($hash{'to_'.$rid})) {
1.31      minaeibi  219:           foreach (split(/\,/,$hash{'to_'.$rid})){
1.1       www       220:               &tracetable($hash{'goesto_'.$_},$beenhere);
1.31      minaeibi  221:           }
1.1       www       222:        }
                    223:     }
                    224: }
1.33      minaeibi  225: 
                    226: sub usection {
1.36      minaeibi  227:     my ($udom,$unam,$courseid,$ActiveFlag)=@_;
1.33      minaeibi  228:     $courseid=~s/\_/\//g;
                    229:     $courseid=~s/^(\w)/\/$1/;
1.39    ! stredwic  230: 
        !           231:     my %result=&Apache::lonnet::dump('roles',$udom,$unam);
        !           232:     foreach my $key (keys (%result)) {
        !           233: 	my $value = $result{$key};
1.33      minaeibi  234:         if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
                    235:             my $section=$1;
                    236:             if ($key eq $courseid.'_st') { $section=''; }
1.39    ! stredwic  237: 	    my ($dummy,$end,$start)=split(/\_/,$value);
1.36      minaeibi  238: 	    if ( $ActiveFlag ne 'Any' ) {
                    239: 		my $now=time;
                    240: 		my $notactive=0;
                    241: 		if ($start) {
                    242: 		    if ($now<$start) { $notactive=1; }
                    243: 		}
                    244: 		if ($end) {
                    245: 		    if ($now>$end) { $notactive=1; }
                    246: 		}
                    247: 		if ((($ActiveFlag eq 'Expired') && $notactive == 1) || 
                    248:                     (($ActiveFlag eq 'Active') && $notactive == 0 ) ) {
                    249: 		    return $section;
                    250: 		}
                    251: 		else { return '-1'; } 
                    252: 	    }
1.33      minaeibi  253: 	    return $section;
                    254:         }
1.34      minaeibi  255:     }
1.36      minaeibi  256:     return '-1';
1.33      minaeibi  257: }
                    258: 
1.30      minaeibi  259: sub BuildChart {
                    260: # ----------------------- Get first and last resource, see if there is anything
                    261:     my $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};
                    262:     my $lastres=$hash{'map_finish_/res/'.$ENV{'request.course.uri'}};
                    263:     if (($firstres) && ($lastres)) {
                    264: # ----------------------------------------------------------------- Render page
                    265: 	my $cid=$ENV{'request.course.id'};
                    266:         my $chome=$ENV{'course.'.$cid.'.home'};
                    267:         my ($cdom,$cnum)=split(/\_/,$cid);
                    268: # ---------------------------------------------- Read class list and row labels
1.39    ! stredwic  269: 	my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
1.30      minaeibi  270: 	my $now=time;
1.39    ! stredwic  271: 	foreach my $name (keys (%classlist)) {
        !           272: 	    my $value=$classlist{$name};
        !           273: 	    my ($end,$start)=split(/\:/,$value);
        !           274: 	    my $active=1;
        !           275: 	    my $Status=$ENV{'form.status'};
        !           276: 	    $Status = ($Status) ? $Status : 'Active';
        !           277: 	    if ( ( ($end) && $now > $end ) && 
        !           278: 		 ( ($Status eq 'Active') ) ) { $active=0; }
        !           279: 	    if ( ($Status eq 'Expired') && 
        !           280: 		 ($end == 0 || $now < $end) ) { $active=0; }
        !           281: 	    if ($active) {
        !           282: 		my $thisindex=$#students+1;
        !           283: 		$students[$thisindex]=$name;
        !           284: 		my ($sname,$sdom)=split(/\:/,$name);
        !           285: 		$PreCol[$thisindex]=$sname.':';
        !           286: 		my $ssec=&usection($sdom,$sname,$cid,$Status);
        !           287: 		if ($ssec==-1) {
        !           288: 		    $rowlabels[$thisindex]=
        !           289: 			'Data not available: '.$name;
        !           290: 		} else {
        !           291: 		    my %reply=&Apache::lonnet::idrget($sdom,$sname);
        !           292: 		    my $reply=&Apache::lonnet::get('environment',
        !           293: 			['lastname','generation','firstname','middlename'],
        !           294: 			$sdom,$sname);
        !           295: 		    #$ssec=(int($ssec)) ? int($ssec) : $ssec;
        !           296: 		    my $sec=sprintf('%3s',$ssec);
        !           297: 		    $rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';
        !           298: 		    $PreCol[$thisindex] .= $reply.':'.$sec;
        !           299: 		    my $i=0;
        !           300: 		    foreach (split(/\&/,$reply)) {
        !           301: 			$i++;
        !           302: 			if ( $_ ne '') {
        !           303: 			    $rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';
        !           304: 			}
        !           305: 			if ($i == 2) {
        !           306: 			    chop($rowlabels[$thisindex]);
        !           307: 			    $rowlabels[$thisindex].=', ';
1.31      minaeibi  308: 			}
1.30      minaeibi  309: 		    }
                    310: 		}
1.31      minaeibi  311: 	    }
1.30      minaeibi  312: 	}
                    313: 
                    314: 	my $allstudents=$#students+1;
                    315: 	$r->print('<h3>'.$allstudents.' students</h3>');
                    316: 	&CreateForm();
                    317: 	$r->rflush();
1.24      minaeibi  318: 
1.30      minaeibi  319: # --------------- Find all assessments and put them into some linear-like order
                    320: 	&tracetable($firstres,'&'.$lastres.'&');
                    321: # ----------------------------------------------------------------- Start table
1.1       www       322: 
1.30      minaeibi  323:         $r->print('<p><pre>');
                    324:  	my $index;
                    325:         for ($index=0;$index<=$#students;$index++) {
                    326: 	    my $Str=&ExtractStudentData($index,$cid);
                    327: 	    $r->print($Str.'<br>');
                    328:             $r->rflush();
                    329: 	    $CachData{$PreCol[$index]}=$Str;
                    330:         }
                    331:         $r->print('</pre>');
                    332:     } else {
                    333: 	$r->print('<h3>Undefined course sequence</h3>');
                    334:     }
                    335: }
1.1       www       336: 
1.30      minaeibi  337: sub CreateForm {
1.33      minaeibi  338:     my $OpSel1='';
                    339:     my $OpSel2='';
1.36      minaeibi  340:     my $OpSel3='';
                    341:     my $Status = $ENV{'form.status'};
                    342:     if ( $Status eq 'Any' ) { $OpSel3='selected'; }
                    343:     elsif ($Status eq 'Expired' ) { $OpSel2 = 'selected'; }
1.33      minaeibi  344:     else { $OpSel1 = 'selected'; }
                    345: 
1.30      minaeibi  346:     my $Ptr = '<form name=stat method=post action="/adm/chart" >'."\n";
                    347:     $Ptr .= '<b> Sort by: &nbsp; </b>'."\n";
                    348:     $Ptr .= '&nbsp;&nbsp;&nbsp;';
1.33      minaeibi  349:     $Ptr .= '<input type=submit name=sort value="User Name" />'."\n";
1.30      minaeibi  350:     $Ptr .= '&nbsp;&nbsp;&nbsp;';
                    351:     $Ptr .= '<input type=submit name=sort value="Last Name" />'."\n";
                    352:     $Ptr .= '&nbsp;&nbsp;&nbsp;';
                    353:     $Ptr .= '<input type=submit name=sort value="Section"/>'."\n";
1.33      minaeibi  354:     $Ptr .= '<br><br>';
1.36      minaeibi  355:     $Ptr .= '<b> Student Status: &nbsp; </b>'."\n".
                    356:             '<select name="status">'. 
                    357:             '<option '.$OpSel1.' >Active</option>'."\n".
                    358:             '<option '.$OpSel2.' >Expired</option>'."\n".
                    359: 	    '<option '.$OpSel3.' >Any</option> </select> '."\n";
1.33      minaeibi  360:     $Ptr .= '&nbsp;&nbsp;&nbsp;';
1.30      minaeibi  361:     $Ptr .= '<input type=submit name=sort value="Recalculate Chart"/>'."\n";
                    362:     $Ptr .= '</form>'."\n";
                    363:     $r->print( $Ptr );
                    364: }
1.1       www       365: 
1.30      minaeibi  366: sub CacheChart {
1.35      albertel  367:     my %list = ();
1.30      minaeibi  368:     my $count=0;
                    369: 
                    370:     my $Pos = $ENV{'form.sort'};
                    371:     if ( $Pos eq 'Last Name' ) {$Pos=1;}
                    372:     elsif ( $Pos eq 'Section' ) {$Pos=2;}
                    373:     else {$Pos=0;}
                    374: 
                    375:     foreach my $key( keys %CachData) { 
                    376: 	my @Temp=split(/\:/,$key);
                    377: 	my $Use = $Temp[$Pos];
1.35      albertel  378: 	$list{$Use.$key}=$key;
1.30      minaeibi  379: 	$count++;
                    380:     }
1.1       www       381: 
1.35      albertel  382:     my @order = sort(keys(%list));
1.1       www       383: 
1.30      minaeibi  384:     $r->print('<h3>'.$count.' students</h3>');
                    385:     &CreateForm();
                    386:     $r->rflush();
                    387:     
                    388:     $r->print('<p><pre>');
                    389:     for ( my $n; $n < $count; $n++) {
1.35      albertel  390: 	$r->print($CachData{$list{$order[$n]}}.'<br>');
1.30      minaeibi  391:     }	
                    392:     $r->print('</pre>');
                    393: }
1.1       www       394: 
1.30      minaeibi  395: sub Start {
                    396:     undef %hash;
                    397:     undef %CachData;
                    398:     undef @students;
                    399:     undef @cols;
                    400:     undef @rowlabels;
                    401:     undef @PreCol;
                    402: 
                    403:     $r->print('<html><head><title>'.
                    404:               'LON-CAPA Assessment Chart</title></head>');
                    405:     $r->print('<body bgcolor="#FFFFFF">'.
                    406:               '<script>window.focus();</script>'.
                    407:               '<img align=right src=/adm/lonIcons/lonlogos.gif>'.
                    408:               '<h1>Assessment Chart</h1>');
1.1       www       409: # ---------------------------------------------------------------- Course title
1.30      minaeibi  410:     $r->print('<h1>'.$ENV{'course.'.$ENV{'request.course.id'}.
                    411:               '.description'}.'</h1><h3>'.localtime().
                    412:               "</h3><p><pre>1..9: correct by student in 1..9 tries\n".
                    413:               "   *: correct by student in more than 9 tries\n".
                    414: 	      "   +: correct by override\n".
                    415:               "   -: incorrect by override\n".
                    416: 	      "   .: incorrect attempted\n".
                    417: 	      "   #: ungraded attempted\n".
                    418:               "    : not attempted\n".
                    419: 	      "   x: excused</pre><p>"); 
1.1       www       420: # ------------------------------- This is going to take a while, produce output
1.30      minaeibi  421:     $r->rflush();
1.1       www       422: 
1.30      minaeibi  423:     my $cid=$ENV{'request.course.id'};
                    424:     my $ChartDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
                    425:                   "_$ENV{'user.domain'}_$cid\_chart.db";
                    426: 
                    427:     if ((-e "$ChartDB") && ($ENV{'form.sort'} ne 'Recalculate Chart')) {
                    428: 	if (tie(%CachData,'GDBM_File',"$ChartDB",&GDBM_READER,0640)) {
                    429: 	    &CacheChart();
                    430: 	}
                    431: 	else {
                    432: 	    $r->print("Unable to tie hash to db file");
                    433: 	}
                    434:     }
                    435:     else {
                    436: 	if (tie(%CachData,'GDBM_File',$ChartDB,&GDBM_WRCREAT,0640)) {
                    437: 	    foreach (keys %CachData) {delete $CachData{$_};}
                    438: 	    &BuildChart();
                    439: 	}
                    440: 	else {
                    441: 	    $r->print("Unable to tie hash to db file");
                    442: 	}
1.1       www       443:     }
1.30      minaeibi  444:     untie(%CachData);
                    445: }
1.1       www       446: 
1.30      minaeibi  447: # ================================================================ Main Handler
1.1       www       448: 
1.30      minaeibi  449: sub handler {
                    450:     $r=shift;
                    451:     if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
                    452: # ------------------------------------------- Set document type for header only
                    453: 	if ($r->header_only) {
                    454: 	    if ($ENV{'browser.mathml'}) {
                    455: 		$r->content_type('text/xml');
                    456: 	    } else {
                    457: 		$r->content_type('text/html');
                    458: 	    }
                    459: 	    &Apache::loncommon::no_cache($r);
                    460: 	    $r->send_http_header;
                    461: 	    return OK;
                    462: 	}
1.1       www       463: 
1.30      minaeibi  464: 	my $requrl=$r->uri;
                    465: # ----------------------------------------------------------------- Tie db file
                    466: 	if ($ENV{'request.course.fn'}) {
                    467: 	    my $fn=$ENV{'request.course.fn'};
                    468: 	    if (-e "$fn.db") {
                    469: 		if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER,0640)) {
                    470: # ------------------------------------------------------------------- Hash tied
                    471: # ---------------------------------------------------------------- Send headers
                    472: 		    $r->content_type('text/html');
                    473: 		    $r->send_http_header;
                    474: 		    &Start();
                    475: 		    $r->print('</body></html>');                 
1.1       www       476: # ------------------------------------------------------------- End render page
1.30      minaeibi  477: 		} else {
                    478: 		    $r->content_type('text/html');
                    479: 		    $r->send_http_header;
                    480: 		    $r->print('<html><body>Coursemap undefined.</body></html>');
                    481: 		}
1.1       www       482: # ------------------------------------------------------------------ Untie hash
1.30      minaeibi  483: 		unless (untie(%hash)) {
                    484: 		    &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                    485: 			     "Could not untie coursemap $fn (browse).</font>"); 
                    486: 		}
1.1       www       487: 
                    488: # -------------------------------------------------------------------- All done
1.30      minaeibi  489: 		return OK;
1.1       www       490: # ----------------------------------------------- Errors, hash could no be tied
1.30      minaeibi  491: 	    }
                    492: 	} else {
                    493: 	    $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
                    494: 	    return HTTP_NOT_ACCEPTABLE; 
                    495: 	}
                    496:     } else {
                    497: 	$ENV{'user.error.msg'}=
1.1       www       498:         $r->uri.":vgr:0:0:Cannot view grades for complete course";
1.30      minaeibi  499: 	return HTTP_NOT_ACCEPTABLE; 
                    500:     }
1.1       www       501: }
                    502: 1;
                    503: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>