[LON-CAPA-cvs] cvs: modules /gerd/harvesting lonrecommender.pm

www www at source.lon-capa.org
Wed Jul 18 21:37:06 EDT 2012


www		Thu Jul 19 01:37:06 2012 EDT

  Modified files:              
    /modules/gerd/harvesting	lonrecommender.pm 
  Log:
  Filter by type
  
  
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.26 modules/gerd/harvesting/lonrecommender.pm:1.27
--- modules/gerd/harvesting/lonrecommender.pm:1.26	Wed Jul 18 23:42:21 2012
+++ modules/gerd/harvesting/lonrecommender.pm	Thu Jul 19 01:37:06 2012
@@ -5,7 +5,7 @@
 #
 # MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
 #
-# $Id: lonrecommender.pm,v 1.26 2012/07/18 23:42:21 www Exp $
+# $Id: lonrecommender.pm,v 1.27 2012/07/19 01:37:06 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -476,7 +476,7 @@
    $r->print("\n<table border='1' bgcolor='".($editflag?'#DDDDFF':'#FFFFDD')."'>\n");
    foreach my $url (@urls) {
       if ($url) {
-         $r->print(&display_line($url,$$taxocats{'cleartext_'.$taxoids{$urlids{$url}}},$editflag));
+         $r->print(&display_line($url,$taxocats,$taxoids{$urlids{$url}},$editflag));
       }
    }
    $r->print("\n</table>\n");
@@ -488,13 +488,13 @@
 #
 
 sub display_line {
-   my ($url,$taxonomy,$editflag)=@_;
+   my ($url,$taxocats,$taxonomy,$editflag)=@_;
    return "\n<tr><td>".
           &submit_link(($editflag?'Remove':'Add'),($editflag?'rem:':'add:').$url).
           "</td><td>".
           &submit_link(&Apache::lonnet::gettitle($url),'indiv:'.$url).
           "</td><td>".
-          &showtaxo($taxonomy).
+          join(',',map {&showtaxo($$taxocats{'cleartext_'.$_})} split(/\,/,$taxonomy)).
           "</td><td>".
           &showurl($url).
           "</td></tr>\n";
@@ -686,6 +686,49 @@
    $r->print("</table>\n");
 }
 
+# =================================================================================
+
+sub filter_menu {
+    my ($filter)=@_;
+    my %problemtypes=
+       ('opt' => &mt('Option Response'),
+        'rad' => &mt('Radiobutton Response'),
+        'num' => &mt('Numerical Response'),
+        'str' => &mt('String Response'),
+        'formula' => &mt('Formula Response'),
+        'image' => &mt('Image Response'),
+        'essay' => &mt('Essay Response'),
+        'match' => &mt('Match Response'),
+        'rank' => &mt('Rank Response'),
+        'react' => &mt('Reaction Response'),
+        'organic' => &mt('Organic Response'),
+        'custom' => &mt('Custom Response'),
+        'math' => &mt('Math Response'));
+    my $allprobs=join('|',keys(%problemtypes));
+    my $output='<select name="filter">'.
+               '<option value="">'.&mt("None").'</option>'.
+               '<option value="page|'.$allprobs.'">'.&mt('Pages and Problems').'</option>'.
+               '<option value="'.$allprobs.'">'.&mt('Problems').'</option>'.
+               '<option value="img">'.&mt('Images').'</option>'.
+               '<option value="mov">'.&mt('Movies').'</option>'.
+               '<option value="snd">'.&mt('Sound').'</option>'.
+               '<option value="pdf">'.&mt('PDF').'</option>'.
+               '<option value="ps">'.&mt('PostScript').'</option>'.
+               '<option value="txt">'.&mt('Plain Text').'</option>'.
+               '<option value="task">'.&mt('Bridge Task').'</option>'.
+               '<option value="code">'.&mt('Program Code').'</option>'.
+               '<option value="tex">'.&mt('LaTeX').'</option>'.
+               '<option value="off">'.&mt('Office Document').'</option>'.
+               '<option value="chem">'.&mt('Chemical Data').'</option>'.
+               '<option value="sty">'.&mt('Style File').'</option>'.
+               '<option value="rights">'.&mt("Rights File").'</option>';
+    foreach my $type (sort(keys(%problemtypes))) {
+       $output.="\n".'<option value="$type">-- '.$problemtypes{$type}.'</option>';
+    }
+    $output.='</select>';
+    $output=~s/(value=\"\Q$filter\E\")\>/$1 selected=\"selected\"\>/s;
+    return $output;
+}
 
 # =================================================================================
 
@@ -742,7 +785,7 @@
 # ------ @selectedurls has the current basket's URLs
 
 # ------ Evaluate filter
-    my $filter='';
+    my $filter=$env{'form.filter'};
 # ------ Start the page and the form, store backetcache from londocs
     $r->print(&Apache::loncommon::start_page("Recommender"));
     $r->print('<form method="post" name="recom">');
@@ -756,12 +799,14 @@
     $r->print("<table width='100%'><tr>\n");
     $r->print("<td><input type='text' size='40' name='searchterm' value='$searchterm' />".
               &submit_link(&mt('Search'),'search')."</td>");
-    $r->print("<td rowspan='2' align='right' bgcolor='#DDDDFF'>".
+    $r->print("<td rowspan='3' align='right' bgcolor='#DDDDFF'>".
               "<font size='+1'><a href='/adm/groupsort?inhibitmenu=yes'>".&mt("Checkout")."</a></font><br /> <br />".
               &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("</tr>\n<tr>");
+    $r->print("<td>".&mt("Filter Lists").' '.&filter_menu($filter)."</td>");
     $r->print("\n</tr></table>");
 # ------ End header row
     if (($cmd eq 'showbasket') || ($cmd=~/^(add|rem)\:/)) {




More information about the LON-CAPA-cvs mailing list