[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm

raeburn raeburn at source.lon-capa.org
Sat Mar 17 16:11:26 EDT 2012


raeburn		Sat Mar 17 20:11:26 2012 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - Uploading archive files directly into a course.
    - For items to be included as files or folders, can specify title 
      to be used for item within a .sequence file.
    - Default for top level item in archive is title entered in comment field
      on itital upload page.  
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1058 loncom/interface/loncommon.pm:1.1059
--- loncom/interface/loncommon.pm:1.1058	Sun Mar 11 00:48:54 2012
+++ loncom/interface/loncommon.pm	Sat Mar 17 20:11:26 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1058 2012/03/11 00:48:54 raeburn Exp $
+# $Id: loncommon.pm,v 1.1059 2012/03/17 20:11:26 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -10005,12 +10005,12 @@
     my ($is_dir,$item,$currdir,$depth,$count) = @_;
     my ($name) = ($item =~ m{([^/]+)$});
     my %choices = &Apache::lonlocal::texthash (
-                                       'display'    => 'Add as File',
+                                       'display'    => 'Add as file',
                                        'dependency' => 'Include as dependency',
                                        'discard'    => 'Discard',
                                       );
     if ($is_dir) {
-        $choices{'display'} = &mt('Add as Folder'); 
+        $choices{'display'} = &mt('Add as folder'); 
     }
     my $output = &start_data_table_row().'<td align="right">'.$count.'</td>'."\n";
     my $offset = 0;
@@ -10023,7 +10023,7 @@
         if ($is_dir) {
             $output .= ' onclick="javascript:propagateCheck(this.form,'."'$count'".');"';
             if ($action eq 'display') {
-                $text = &mt('Add as Folder');
+                $text = &mt('Add as folder');
             }
         } else {
             $output .= ' onclick="javascript:dependencyCheck(this.form,'."$count,$offset".');"';
@@ -10037,6 +10037,10 @@
                        '<option value=""></option>'."\n".
                        '</select>'."\n".
                        '</div>';
+        } elsif ($action eq 'display') {
+            $output .= '<div id="arc_title_'.$count.'" style="display:none;">'."\n".
+                       &mt('Title:').' <input type="text" name="archive_title_'.$count.'" id="archive_title_'.$count.'" />'."\n".
+                       '</div>';
         }
         $output .= '</td>';
     }
@@ -10065,9 +10069,9 @@
                     '</p>'.
                     '<div class="LC_columnSection"><fieldset>'.
                     '<legend>'.&mt('Content actions for all').'</legend>'.
-                    '<input type="button" value="'.&mt('Display in Contents').'" '.
+                    '<input type="button" value="'.&mt('Add as folder/file').'" '.
                     'onclick="javascript:checkAll(document.'.$form.",'display'".')" />'.
-                    '  <input type="button" value="'.&mt('Include as dependency for a displayed item').'"'.
+                    '  <input type="button" value="'.&mt('Include as dependency for a displayed file').'"'.
                     ' onclick="javascript:checkAll(document.'.$form.",'dependency'".')" />'.
                     '  <input type="button" value="'.&mt('Discard').'"'.
                     ' onclick="javascript:checkAll(document.'.$form.",'discard'".')" />'.
@@ -10084,6 +10088,7 @@
 sub archive_javascript {
     my ($startcount,$numitems,$titles,$children) = @_;
     return unless ((ref($titles) eq 'HASH') && (ref($children) eq 'HASH'));
+    my $maintitle = $env{'form.comment'};
     my $scripttag = <<START;
 <script type="text/javascript">
 // <![CDATA[
@@ -10097,8 +10102,8 @@
                 if (form.elements[i].type == 'radio') {
                     form.elements[i].checked = true;
                     var nostart = i-$startcount;
-                    var offset = nostart%6;
-                    var count = (nostart-offset)/6;    
+                    var offset = nostart%7;
+                    var count = (nostart-offset)/7;    
                     dependencyCheck(form,count,offset);
                 }
             }
@@ -10108,9 +10113,9 @@
 
 function propagateCheck(form,count) {
     if (count > 0) {
-        var startelement = $startcount + ((count-1) * 6);
-        for (var j=1; j<5; j++) {
-            if (j != 3) {
+        var startelement = $startcount + ((count-1) * 7);
+        for (var j=1; j<6; j++) {
+            if ((j != 2) && (j != 4)) {
                 var item = startelement + j; 
                 if (form.elements[item].type == 'radio') {
                     if (form.elements[item].checked) {
@@ -10129,6 +10134,7 @@
 for (var i=0; i<numitems; i++) {
     parents[i] = new Array;
 }
+var maintitle = '$maintitle';
 
 START
 
@@ -10148,7 +10154,7 @@
 function containerCheck(form,count,offset) {
     if (count > 0) {
         dependencyCheck(form,count,offset);
-        var item = (offset+$startcount)+6*(count-1);
+        var item = (offset+$startcount)+7*(count-1);
         form.elements[item].checked = true;
         if(Object.prototype.toString.call(parents[count]) === '[object Array]') {
             if (parents[count].length > 0) {
@@ -10162,17 +10168,17 @@
 
 function dependencyCheck(form,count,offset) {
     if (count > 0) {
-        var chosen = (offset+$startcount)+6*(count-1);
-        var depitem = $startcount + ((count-1) * 6) + 3;
+        var chosen = (offset+$startcount)+7*(count-1);
+        var depitem = $startcount + ((count-1) * 7) + 4;
         var currtype = form.elements[depitem].type;
         if (form.elements[chosen].value == 'dependency') {
             document.getElementById('arc_depon_'+count).style.display='block'; 
             form.elements[depitem].options.length = 0;
             form.elements[depitem].options[0] = new Option('Select','',true,true);
             for (var i=1; i<count; i++) {
-                var startelement = $startcount + (i-1) * 6;
-                for (var j=1; j<5; j++) {
-                    if (j != 3) {
+                var startelement = $startcount + (i-1) * 7;
+                for (var j=1; j<6; j++) {
+                    if ((j != 2) && (j!= 4)) {
                         var item = startelement + j;
                         if (form.elements[item].type == 'radio') {
                             if (form.elements[item].checked) {
@@ -10190,12 +10196,13 @@
             form.elements[depitem].options.length = 0;
             form.elements[depitem].options[0] = new Option('Select','',true,true);
         }
+        titleCheck(form,count,offset);
     }
 }
 
 function propagateSelect(form,count,offset) {
     if (count > 0) {
-        var item = (1+offset+$startcount)+6*(count-1);
+        var item = (2+offset+$startcount)+7*(count-1);
         var picked = form.elements[item].options[form.elements[item].selectedIndex].value; 
         if (Object.prototype.toString.call(parents[count]) === '[object Array]') {
             if (parents[count].length > 0) {
@@ -10209,7 +10216,7 @@
 
 function containerSelect(form,count,offset,picked) {
     if (count > 0) {
-        var item = (offset+$startcount)+6*(count-1);
+        var item = (1+offset+$startcount)+7*(count-1);
         if (form.elements[item].type == 'radio') {
             if (form.elements[item].value == 'dependency') {
                 if (form.elements[item+1].type == 'select-one') {
@@ -10232,6 +10239,26 @@
     }
 }
 
+function titleCheck(form,count,offset) {
+    if (count > 0) {
+        var chosen = (offset+$startcount)+7*(count-1);
+        var depitem = $startcount + ((count-1) * 7) + 2;
+        var currtype = form.elements[depitem].type;
+        if (form.elements[chosen].value == 'display') {
+            document.getElementById('arc_title_'+count).style.display='block';
+            if ((count==1) && ((parents[count].length > 0) || (numitems == 1))) {
+                document.getElementById('archive_title_'+count).value=maintitle;
+            }
+        } else {
+            document.getElementById('arc_title_'+count).style.display='none';
+            if (currtype == 'text') { 
+                document.getElementById('archive_title_'+count).value='';
+            }
+        }
+    }
+    return;
+}
+
 // ]]>
 </script>
 END
@@ -10298,8 +10325,12 @@
                         }
                     }
                 } elsif ($env{'form.archive_'.$i} eq 'display') {
-                    my ($title,$url,$outer);
+                    my ($docstitle,$title,$url,$outer);
                     ($title) = ($path =~ m{/([^/]+)$});
+                    $docstitle = $env{'form.archive_title_'.$i};
+                    if ($docstitle eq '') {
+                        $docstitle = $title;
+                    }
                     $outer = 0;
                     if (ref($dirorder{$i}) eq 'ARRAY') {
                         if (@{$dirorder{$i}} > 0) {
@@ -10325,7 +10356,7 @@
                                       $folders{$i}.'.'.$containers{$i};
                             my $newidx = &LONCAPA::map::getresidx();
                             $LONCAPA::map::resources[$newidx]=
-                                $title.':'.$url.':false:normal:res';
+                                $docstitle.':'.$url.':false:normal:res';
                             push(@LONCAPA::map::order,$newidx);
                             my ($outtext,$errtext) =
                                 &LONCAPA::map::storemap('/uploaded/'.$docudom.'/'.
@@ -10350,7 +10381,7 @@
                                 $newdest{$i} = "$prefix$dir/$docstype/$mapinner{$outer}/$newidx";
                             }
                             $LONCAPA::map::resources[$newidx]=
-                                $title.':'.$url.':false:normal:res';
+                                $docstitle.':'.$url.':false:normal:res';
                             push(@LONCAPA::map::order, $newidx);
                             my ($outtext,$errtext)=
                                 &LONCAPA::map::storemap('/uploaded/'.$docudom.'/'.


More information about the LON-CAPA-cvs mailing list