[LON-CAPA-cvs] cvs: modules /gerd/harvesting lonrecommender.pm
www
www at source.lon-capa.org
Mon Jul 16 13:16:29 EDT 2012
www Mon Jul 16 17:16:29 2012 EDT
Modified files:
/modules/gerd/harvesting lonrecommender.pm
Log:
Taxonomy listing
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.10 modules/gerd/harvesting/lonrecommender.pm:1.11
--- modules/gerd/harvesting/lonrecommender.pm:1.10 Mon Jul 16 14:55:52 2012
+++ modules/gerd/harvesting/lonrecommender.pm Mon Jul 16 17:16:28 2012
@@ -5,7 +5,7 @@
#
# MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
#
-# $Id: lonrecommender.pm,v 1.10 2012/07/16 14:55:52 www Exp $
+# $Id: lonrecommender.pm,v 1.11 2012/07/16 17:16:28 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -431,15 +431,8 @@
sub display_list {
my ($r,$editflag,$taxocats, at urls)=@_;
my %urlids=&urlres(@urls);
- foreach my $key (keys(%urlids)) {
- $r->print($key.' -> '.$urlids{$key}."<br />\n");
- }
my %taxoids=&taxoids(values(%urlids));
- foreach my $key (keys(%taxoids)) {
- $r->print($key.' in '.$taxoids{$key}." --> ".$$taxocats{'cleartext_'.$taxoids{$key}}."<br />\n");
- }
-
- $r->print("\n<table border='1'>\n");
+ $r->print("\n<table border='1' bgcolor='".($editflag?'#DDDDFF':'#FFFFDD')."'>\n");
foreach my $url (@urls) {
$r->print(&display_line($url,$$taxocats{'cleartext_'.$taxoids{$urlids{$url}}},$editflag));
}
@@ -456,7 +449,7 @@
return "\n<tr><td>".
&submit_link(($editflag?'Remove':'Add'),($editflag?'rem_':'add_'.$url)).
"</td><td>".
- &Apache::lonnet::gettitle($url).
+ &submit_link(&Apache::lonnet::gettitle($url),'indiv:'.$url).
"</td><td>".
&showtaxo($taxonomy).
"</td><td>".
@@ -488,18 +481,34 @@
sub showtaxo {
my ($taxo)=@_;
+ unless ($taxo) { return ' ' }
my @parts=split(/\:/,$taxo);
my $output='';
my $thusfar='';
for (my $i=0; $i<=$#parts; $i++) {
$thusfar.=':'.$parts[$i];
- $output.=':'.&submit_link($parts[$i],'taxo:'.$thusfar);
+ $output.=':'.&submit_link($parts[$i],'taxo'.$thusfar);
}
$output=~s/^\://;
return $output;
}
+# =================================================================================
+# List the toplevel categories and their counts
+#
+sub list_toplevel_cats {
+ my ($taxocats)=@_;
+ my $output='';
+ foreach my $key (sort(keys(%$taxocats))) {
+ if ($key=~/^count\_(.+)$/) {
+ my $cat=$1;
+ if ($cat=~/\:/) { next; }
+ $output.=' '.&submit_link($cat.' ('.$$taxocats{$key}.')','taxo:'.$cat);
+ }
+ }
+ return $output;
+}
# =================================================================================
# A submitting link
@@ -526,7 +535,7 @@
# We have been here before
@existingbasket=split(/\,/,$env{'form.basketcache'});
} else {
-# Read the basket and evaluate
+# Read the basket and evaluate, ignoring every URL that is not classified
my ($cnum,$cdom,$folder)=split(/\,/,$basket);
my %existingres=();
if ($folder) {
@@ -553,13 +562,11 @@
}
# ------ Add the resource IDs of the selected URLs to the existing ones
my @selectedids=&urlres(@selectedurls);
- my @baseids=(@existingbasket, at selectedurls);
+ my @baseids=(@existingbasket, at selectedids);
# ------ Now @baseids has the IDs of the URLs the user selected for the folder,
# ------ prior and during this call, with possible duplicates
# ------ if same URL selected twice
-# ------ @selectedurls has the current basket
-
-
+# ------ @selectedurls has the current basket's URLs
# ------ Start the page and the form, store backetcache from londocs
@@ -569,7 +576,19 @@
$r->print('<input type="hidden" name="basketcache" value="'.$basketcache.'" />');
$r->print('<input type="hidden" name="cmd" value="" />');
# ------ Page opened
-
+# ------ Make header row
+ $r->print("<table width='100%'><tr>\n");
+ $r->print("<td><input type='text' size='40' name='searchterm' /><input type='submit' name='search' value='".
+ &mt('Search')."' /></td>");
+ if (($cmd ne 'showbasket') && ($cmd!~/^rem\:/)) {
+ $r->print("<td rowspan='2' align='right' bgcolor='#DDDDFF'>".
+ &submit_link(&mt('Your cart ([_1] item(s))',$#selectedurls+1),'showbasket').
+ "</td>");
+ }
+ $r->print("</tr>\n<tr>");
+ $r->print('<td>'.&list_toplevel_cats(\%taxonomy_categories).'</td>');
+ $r->print("\n</tr></table>");
+# ------ End header row
&display_list($r,0,\%taxonomy_categories,
('/res/bsu/physicstir3/Conceptual Questions/002 Car Path on Curve Ice Patch.problem',
'/res/purdue/liten/Biology III Cell Structure and Function/Prob_033_Transcription_Translation.problem',
@@ -579,7 +598,7 @@
'/res/msu/physicslib/msuphysicslib/05_1D_Motion/msu-prob49.problem')
);
- if ($cmd eq 'showbasket') {
+ if (($cmd eq 'showbasket') || ($cmd!~/^rem\:/)) {
} elsif ($cmd eq 'search') {
} elsif ($cmd=~/^taxo\:/) {
} elsif ($cmd=~/^dir\:/) {
More information about the LON-CAPA-cvs
mailing list