--- loncom/interface/portfolio.pm 2004/11/25 23:56:19 1.58 +++ loncom/interface/portfolio.pm 2004/12/04 18:37:36 1.61 @@ -112,13 +112,6 @@ sub display_directory { #$strip holds directory/file name #$dom my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); - if ($Apache::lonhomework::results{"resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename"}eq'true'){ - &Apache::lonnet::logthis("found submitted file"); - &Apache::lonnet::logthis("resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename"); - } else { - &Apache::lonnet::logthis("$filename not found submitted file"); - &Apache::lonnet::logthis("resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename"); - } if (($filename ne '.') && ($filename ne '..')) { if ($dirptr&$testdir) { $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>'); @@ -159,6 +152,10 @@ sub display_file_select { my ($r,$current_path,$is_empty,$dir_list)=@_; my $iconpath= $r->dir_config('lonIconsURL') . "/"; my $display_out; + my $checked_files = &Apache::lonnet::files_in_path($ENV{'user.name'}, $ENV{'form.currentpath'}); + foreach my $key (keys %$checked_files) { + &Apache::lonnet::logthis("a key is $key $$checked_files{$key} is the value"); + } if ($is_empty && ($current_path ne '/')) { $display_out = '<form method="post" action="/adm/portfolio">'. '<input type="hidden" name="action" value="deletedir" />'. @@ -184,6 +181,7 @@ sub display_file_select { #$strip holds directory/file name #$dom my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); + $filename =~ s/\s+$//; if (($filename ne '.') && ($filename ne '..')) { if ($dirptr&$testdir) { $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>'); @@ -192,9 +190,14 @@ sub display_file_select { $r->print('</tr>'); } else { $r->print('<tr bgcolor="#CCCCFF">'); - $r->print('<td> - <input type="checkbox" name="selectedfile" value="'.$filename.'" > - </td>'); + $r->print('<td><input type="checkbox" name="selectedfile" value="'.$filename.'"'); + if ($$checked_files{$filename} eq 'selected') { + $r->print("CHECKED"); + &Apache::lonnet::logthis("checked"); + } else { + &Apache::lonnet::logthis("not checked $$checked_files{$filename} $filename"); + } + $r->print('></td>'); $r->print('<td><img src="'.$iconpath.'unknown.gif"></td>'); $r->print('<td><a href="'.$href_location.$filename.'">'. $filename.'</a></td>'); @@ -205,6 +208,10 @@ sub display_file_select { } } $r->print('</table> + <input type="hidden" name="continue" value="true"> + <input type="hidden" name="fieldname" value="'.$ENV{'form.fieldname'}.'"> + <input type="hidden" name="mode" value="selectfile"> + <input type="submit" name="submit" value="Select checked files, and continue selecting." /><br /> <input type="button" name="doit" onClick= "finishSelect();" value="Select checked files, and close window" /> <input type="hidden" name="currentpath" value="'.$current_path.'" /> </form>'); @@ -339,7 +346,7 @@ sub rename_confirmed { my $result= &Apache::lonnet::renameuserfile($ENV{'user.name'},$ENV{'user.domain'}, 'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.selectfile'}, - 'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.filenewname'}); + 'portfolio'.$ENV{'form.currentpath'}.$filenewname); if ($result ne 'ok') { $r->print('<font color="red"> An errror occured ('.$result. ') while trying to rename '.&display_file().' to '. @@ -349,6 +356,12 @@ sub rename_confirmed { } sub select_files { my ($r)=@_; + if ($ENV{'form.continue'} eq 'true') { + # here we update the selections for the currentpath + # eventually, have to handle removing those not checked, but . . . + my @items=&Apache::loncommon::get_env_multiple('form.selectedfile'); + &Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items); + } my $java_script =(<<ENDSMP); <script language='javascript'> function finishSelect() { @@ -370,6 +383,10 @@ ENDSMP $r->print($java_script); $r->print("<h1>Select portfolio files</h1> Check as many as you wish in response to the essay problem.<br />"); + $r->print("<strong>Files selected from other directories:</strong><br />"); + foreach (&Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'})) { + $r->print($_."<br />"); + } } sub upload { my ($r)=@_;