File:
[LON-CAPA] /
loncom /
interface /
lonindexcourse.pm
Revision
1.2:
download - view:
text,
annotated -
select for diffs
Sun Dec 25 20:41:53 2011 UTC (12 years, 7 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD,
BZ4492-merge,
BZ4492-feature_horizontal_radioresponse
Changes to improve usability for Course Contents and Content Editor.
- Separate "editor" tabs (Content Editor && Supplemental Content Editor) from
"display" tabs (Main Content, Supplemental Content, Content Search, Content Index).
- Replace "Edit Content" link on "Course Contents" page (used to jump directly
to editing specific folder) with icon, to reduce clutter.
- "Back to Overview" link on editor pages to jump directly to corresponding
location on "display" pages.
- CC and student roles have same tabs in "display" of Contents
- New URL: "/adm/supplemental" for supplemental contents when displaying
(as CC or student).
- Supplemental Course Content breadcrumbs do not need link to course as first
item.
- Functions menu in Supplemental Course Content includes "Folder Editor" link
to jump to editor.
- Do not use style: "LC_current_location" when location is a folder.
1: # The LearningOnline Network with CAPA
2: # Index Course
3: #
4: # $Id: lonindexcourse.pm,v 1.2 2011/12/25 20:41:53 raeburn Exp $
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: #
28: ###############################################################################
29: ###############################################################################
30:
31: package Apache::lonindexcourse;
32:
33: use strict;
34: use Apache::Constants qw(:common :http);
35: use Apache::lonnet;
36: use GDBM_File;
37: use Apache::loncommon();
38: use Apache::lonmeta;
39: use Apache::lonhtmlcommon;
40: use Apache::lonlocal;
41: use LONCAPA::lonmetadata();
42: use HTML::Entities();
43: use Apache::lonnavmaps;
44: use Apache::lonnavdisplay();
45: use Apache::lonindexer();
46: use LONCAPA;
47:
48: # Variables For course search
49: my %alreadyseen;
50: my %hash;
51: my %indexhash=();
52: my %indextitles=();
53:
54: sub make_symb {
55: my ($id)=@_;
56: my ($mapid,$resid)=split(/\./,$id);
57: my $map=$hash{'map_id_'.$mapid};
58: my $res=$hash{'src_'.$id};
59: my $symb=&Apache::lonnet::encode_symb($map,$resid,$res);
60: return $symb;
61: }
62:
63: sub course_index {
64: my $r=shift;
65: $r->rflush();
66: # ======================================================= Go through the course
67: my $c=$r->connection;
68: %indexhash=();
69: %indextitles=();
70: %alreadyseen=();
71: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
72: &GDBM_READER(),0640)) {
73: foreach (sort(keys(%hash))) {
74: if ($c->aborted()) { last; }
75: if (($_=~/^src\_(.+)$/)) {
76: if ($hash{'randomout_'.$1} & !$env{'request.role.adv'}) {
77: next;
78: }
79: my $symb=&make_symb($1);
80: my %newwords=&checkonthis($r,$1,$hash{$_},0,&Apache::lonnet::gettitle($symb),
81: $symb);
82: }
83: }
84: untie(%hash);
85: }
86: # Output
87: $r->print(&Apache::loncommon::start_data_table());
88: my $currentchar='';
89: foreach my $lword (sort(keys(%indexhash))) {
90: unless ($lword=~/\w/) { next; }
91: if ($lword=~/^\d+$/) { next; }
92: my $firstchar=substr($lword,0,1);
93: if ($currentchar ne $firstchar) {
94: $r->print(&Apache::loncommon::start_data_table_header_row().
95: '<th>'.$firstchar.'</th><th> </th>'.&Apache::loncommon::end_data_table_header_row());
96: $currentchar=$firstchar;
97: }
98: $r->print("\n".&Apache::loncommon::start_data_table_row()."<td>$lword</td><td>");
99: foreach my $href (split(/\,/,$indexhash{$lword})) {
100: unless ($href) { next; }
101: $r->print(' <a href="'.$href.'">'.$indextitles{$href}.'</a>');
102: }
103: $r->print("</td>".&Apache::loncommon::start_data_table_row());
104: }
105: $r->print(&Apache::loncommon::end_data_table());
106: }
107:
108: # =============================== This pulls up a resource and its dependencies
109:
110: sub checkonthis {
111: my ($r,$id,$url,$level,$title,$symb)=@_;
112: $alreadyseen{$id}=1;
113: if (&Apache::loncommon::connection_aborted($r)) { return; }
114: $r->rflush();
115:
116: my $result='';
117: if ($env{'request.role.adv'} || !$hash{'encrypted_'.$id}) {
118: $result=&Apache::lonnet::metadata($url,'subject').','.
119: &Apache::lonnet::metadata($url,'keywords');
120: }
121: $result=~s/\s+/\,/gs;
122: my $href=$url;
123: if ($hash{'encrypted_'.$id} && !$env{'request.role.adv'}) {
124: $href=&Apache::lonenc::encrypted($href)
125: .'?symb='.&Apache::lonenc::encrypted($symb);
126: } else {
127: $href.='?symb='.&escape($symb);
128: }
129: foreach my $word (split(/\,/,$result)) {
130: unless ($word) { next; }
131: $indexhash{lc($word)}.=','.$href;
132: $indextitles{$href}=($title?substr($title,0,10):'').' ...';
133: }
134:
135: $r->rflush();
136: # Check also the dependencies of this one
137: my $dependencies=
138: &Apache::lonnet::metadata($url,'dependencies');
139: foreach (split(/\,/,$dependencies)) {
140: if (($_=~/^\/res\//) && (!$alreadyseen{$id})) {
141: &checkonthis($r,$id,$_,$level+1,'');
142: }
143: }
144: }
145:
146: sub untiehash {
147: if (tied(%hash)) {
148: untie(%hash);
149: }
150: }
151:
152: sub handler {
153: my $r = shift;
154: &Apache::loncommon::content_type($r,'text/html');
155: $r->send_http_header;
156: if ($r->header_only) { return OK; }
157:
158: my $crstype = &Apache::loncommon::course_type();
159: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['phase']);
160: $r->print(&Apache::loncommon::start_page("$crstype Index"));
161: &Apache::lonhtmlcommon::clear_breadcrumbs();
162: &Apache::lonhtmlcommon::add_breadcrumb(
163: { href => '/adm/indexcourse',
164: text => "$crstype Index"});
165: $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Index"));
166: &Apache::lonnavdisplay::startContentScreen($r,'courseindex');
167: &course_index($r);
168: &Apache::lonnavdisplay::endContentScreen($r);
169: $r->print(&Apache::loncommon::end_page());
170: return OK;
171: }
172:
173: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>