--- loncom/interface/lonprintout.pm 2002/09/04 03:59:20 1.53 +++ loncom/interface/lonprintout.pm 2002/09/05 15:51:07 1.54 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.53 2002/09/04 03:59:20 albertel Exp $ +# $Id: lonprintout.pm,v 1.54 2002/09/05 15:51:07 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,11 +43,13 @@ use strict; use Apache::Constants qw(:common :http); use Apache::lonxml; use Apache::lonnet; +use Apache::loncommon; use Apache::inputtags; +use Apache::loncoursedata; +use Apache::grades; use Apache::edit; use Apache::File(); use POSIX qw(strftime); -use Apache::loncoursedata; sub headerform { @@ -83,7 +85,7 @@ ENDMENUOUT2 } if ($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) { $r->print(< Print assignment for students in class
+ Print assignment (all problems from the primary sequence) for group of students
ENDMENUOUT6 } my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'}); @@ -135,23 +137,27 @@ sub additional_class_menu { ENDMENUOUT1 my $c = $r->connection; my %cache; - my $courseID=$ENV{'request.course.id'}; - my $classlist=&Apache::loncoursedata::DownloadClasslist($courseID, - $cache{'ClasslistTimestamp'}, - $c); - foreach (keys(%$classlist)) { - if(/^(con_lost|error|no_such_host)/i) { - untie(%cache); - return "Error getting student data."; - } + my $courseID = $ENV{'request.course.id'}; + my $classlist = &Apache::loncoursedata::DownloadClasslist($courseID,$cache{'ClasslistTimestamp'},$c); + &Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c); + my @all_students = split(':::',$cache{'NamesOfStudents'}); + my @active_students = (); + foreach my $student (@all_students) { + if ($cache{$student.':Status'} eq 'Active') { + push @active_students,$student; + } } - my $classlistaa = ''; - foreach my $st (keys(%$classlist)) { - $classlistaa .= ' SSS '.$st.' => '.$$classlist{$st}.' FFF '."\r\n"; + my $what_to_print = ''; + my $i = 0; + foreach my $student (@active_students) { + $what_to_print .= ''; +# $what_to_print .= ''; + $i++; } - + $what_to_print .= '
'.$cache{$student.':fullname'}.'
'.$cache{$student.':fullname'}.'
'; $r->print(< + $what_to_print
+ ENDMENUOUT2 @@ -160,10 +166,16 @@ ENDMENUOUT2 sub additional_print_menu { my $r = shift; + my $what_to_print = ''; + for (my $i=0; $i<$ENV{'form.numberofstudents'};$i++) { + $what_to_print .= ''; + } $r->print(< + Enter width of the page:
@@ -309,6 +321,48 @@ ENDPART } $result = &additional_cleanup($result); } elsif ($choice eq 'All class print') { + #-- prints assignments for whole class or for selected students + my (@students,@st_output) = ((),()); + for (my $i=0; $i<$ENV{'form.numberofstudents'};$i++) { + if ($ENV{'form.whomtoprint'.$i}=~/:/) { + push @students,$ENV{'form.whomtoprint'.$i}; + } + } + #where is the primary sequence containing current resource (the same for all students)? + my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'}); + $symbolic =~ m/([^_]+)_/; + my $primary_sequence = '/res/'.$1; + #opens and analyses the primary sequence file, produces the array of resources + my $sequence_file=&Apache::lonnet::filelocation("",$primary_sequence); + my $sequencefilecontents=&Apache::lonnet::getfile($sequence_file); + my @master_seq = &content_map($sequencefilecontents); + #loop over students + foreach my $person (@students) { + my $current_output = ''; + my ($username,$userdomain) = split /:/,$person; + my $fullname = &Apache::grades::get_fullname($username,$userdomain); + #goes through all resources, checks if they are available for current student, and produces output + foreach my $curres (@master_seq) { + $curres =~ s/^"//; + $curres =~ s/"$//; + if ($curres=~/\w+/) { + my $symb = &Apache::lonnet::symbread($curres); + my ($map,$id,$res_url) = split(/___/,$symb); + if (&Apache::lonnet::allowed('bre',$res_url)) { + my $rendered = &Apache::loncommon::get_student_view($symb,$username,$userdomain, + $ENV{'request.course.id'},'tex'); + $current_output .= $rendered; + } + } + } + $current_output =~ s/\\begin{document}/\\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$fullname}}\\hskip 1\.4in } \\vskip 5 mm /; + $result .= $current_output; + } + + $result = &additional_cleanup($result); + + +