# The LearningOnline Network with CAPA # Index Course # # $Id: lonindexcourse.pm,v 1.4 2024/02/12 04:04:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # ############################################################################### ############################################################################### package Apache::lonindexcourse; use strict; use Apache::Constants qw(:common :http); use Apache::lonnet; use GDBM_File; use Apache::loncommon(); use Apache::lonmeta; use Apache::lonhtmlcommon; use Apache::lonlocal; use LONCAPA::lonmetadata(); use HTML::Entities(); use Apache::lonnavmaps; use Apache::lonnavdisplay(); use Apache::lonindexer(); use LONCAPA; # Variables For course search my %alreadyseen; my %hash; my %indexhash=(); my %indextitles=(); sub make_symb { my ($id)=@_; my ($mapid,$resid)=split(/\./,$id); my $map=$hash{'map_id_'.$mapid}; my $res=$hash{'src_'.$id}; my $symb=&Apache::lonnet::encode_symb($map,$resid,$res); return $symb; } sub course_index { my $r=shift; $r->rflush(); # ======================================================= Go through the course my $c=$r->connection; %indexhash=(); %indextitles=(); %alreadyseen=(); if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", &GDBM_READER(),0640)) { foreach my $key (sort(keys(%hash))) { last if ($c->aborted()); if ($key =~ /^src\_(.+)$/) { my $rid = $1; unless ($env{'request.role.adv'}) { next if ($hash{'randomout_'.$rid} || $hash{'deeplinkout_'.$rid}); if (!$env{'request.deeplink.login'} && $hash{'deeplinkonly_'.$rid}) { my ($value) = map { &unescape($_); } split(/:/,$hash{'deeplinkonly_'.$rid}); my ($state,$others,$listed) = split(/,/,$value); next if (($state eq 'only') && (($listed eq 'absent') || ($listed eq 'grades'))); } } my $symb=&make_symb($rid); my %newwords=&checkonthis($r,$rid,$hash{$key},0,&Apache::lonnet::gettitle($symb), $symb); } } untie(%hash); } # Output $r->print(&Apache::loncommon::start_data_table()); my $currentchar=''; foreach my $lword (sort(keys(%indexhash))) { unless ($lword=~/\w/) { next; } if ($lword=~/^\d+$/) { next; } my $firstchar=substr($lword,0,1); if ($currentchar ne $firstchar) { $r->print(&Apache::loncommon::start_data_table_header_row(). '