--- loncom/interface/portfolio.pm 2004/11/10 05:57:53 1.56 +++ loncom/interface/portfolio.pm 2004/12/04 19:08:42 1.62 @@ -33,8 +33,8 @@ use Apache::lonlocal; # receives a file name and path stub from username/userfiles/portfolio/ # returns an anchor tag consisting encoding filename and currentpath sub make_anchor { - my ($filename, $current_path) = @_; - my $anchor = ''.$filename.''; + my ($filename, $current_path, $current_mode, $field_name) = @_; + my $anchor = ''.$filename.''; return $anchor; } my $dirptr=16384; @@ -48,6 +48,7 @@ sub display_common { ''. ''. ''. + ''. ''. ''; $r->print($displayOut); @@ -57,22 +58,23 @@ sub display_common { ''. ''. ''. + ''. ''. ''; $r->print($displayOut); $r->print(''); my @tree = split (/\//,$current_path); - $r->print(''.&make_anchor('portfolio','/').'/'); + $r->print(''.&make_anchor('portfolio','/',$ENV{"form.mode"},$ENV{"form.fieldname"}).'/'); if (@tree > 1){ my $newCurrentPath = ''; for (my $i = 1; $i< @tree; $i++){ $newCurrentPath .= $tree[$i].'/'; - $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath).'/'); + $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $ENV{"form.mode"},$ENV{"form.fieldname"}).'/'); } } $r->print(''); &Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path); - $r->print('
'. + $r->print('
'. &Apache::lonhtmlcommon::select_recent('portfolio','currentpath', 'this.form.submit();')); $r->print("
"); @@ -110,18 +112,11 @@ 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(''); $r->print('Go to ...'); - $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/').''); + $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).''); $r->print(''); } else { $r->print(''); @@ -157,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 = '
'. ''. @@ -182,17 +181,23 @@ 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(''); $r->print('Go to ...'); - $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/').''); + $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).''); $r->print(''); } else { $r->print(''); - $r->print(' - - '); + $r->print('print("CHECKED"); + &Apache::lonnet::logthis("checked"); + } else { + &Apache::lonnet::logthis("not checked $$checked_files{$filename} $filename"); + } + $r->print('>'); $r->print(''); $r->print(''. $filename.''); @@ -203,6 +208,10 @@ sub display_file_select { } } $r->print(' + + + +
'); @@ -244,6 +253,7 @@ sub done { return ('

'.&mt('Done').'

'); } @@ -336,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(' An errror occured ('.$result. ') while trying to rename '.&display_file().' to '. @@ -346,10 +356,28 @@ 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); + } else { + if ($ENV{'form.currentpath'} eq '/') { + #empty the file for a fresh start + # &Apache::lonnet::clear_selected_files($ENV{'user.name'}); + } + } + my @files = &Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'}); + my $java_files = join ",", @files; + if ($java_files) { + $java_files.=','; + } my $java_script =(< function finishSelect() { - fileList = ""; +ENDSMP + $java_script .= 'fileList = "'.$java_files.'";'; + $java_script .= (<print($java_script); $r->print("

Select portfolio files

Check as many as you wish in response to the essay problem.
"); + $r->print("Files selected from other directories:
"); + foreach (&Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'})) { + $r->print($_."
"); + } } sub upload { my ($r)=@_;