--- loncom/interface/lonmsg.pm 2004/09/20 15:01:56 1.108 +++ loncom/interface/lonmsg.pm 2004/10/26 19:50:15 1.111 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.108 2004/09/20 15:01:56 www Exp $ +# $Id: lonmsg.pm,v 1.111 2004/10/26 19:50:15 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -600,10 +600,7 @@ sub movemsg { sub discourse { my $r=shift; - my %courselist=&Apache::lonnet::dump( - 'classlist', - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + my $classlist = &Apache::loncoursedata::get_classlist(); my $now=time; my %lt=&Apache::lonlocal::texthash('cfa' => 'Check for All', 'cfs' => 'Check for Section/Group', @@ -645,39 +642,36 @@ sub discourse { <input type="button" onClick="uncheckall()" value="$lt{'cfn'}" /> <p> ENDDISHEADER - my %coursepersonnel= - &Apache::lonnet::get_course_adv_roles(); + my %coursepersonnel=&Apache::lonnet::get_course_adv_roles(); + $r->print('<table>'); foreach my $role (sort keys %coursepersonnel) { - foreach (split(/\,/,$coursepersonnel{$role})) { - my ($puname,$pudom)=split(/\:/,$_); - $r->print( - '<br /><input type="checkbox" name="send_to_&&&&&&_'. - $puname.':'.$pudom.'" /> '. - &Apache::loncommon::plainname($puname, - $pudom).' ('.$_.'), <i>'.$role.'</i>'); - } + foreach (split(/\,/,$coursepersonnel{$role})) { + my ($puname,$pudom)=split(/\:/,$_); + $r->print('<tr><td><label>'. + '<input type="checkbox" name="send_to_&&&&&&_'. + $puname.':'.$pudom.'" /> '. + &Apache::loncommon::plainname($puname,$pudom). + '</label></td>'. + '<td>('.$_.'),</td><td><i>'.$role.'</i></td></tr>'); + } } - - foreach (sort keys %courselist) { - my ($end,$start)=split(/\:/,$courselist{$_}); - my $active=1; - if (($end) && ($now>$end)) { $active=0; } - if ($active) { - my ($sname,$sdom)=split(/\:/,$_); - my %reply=&Apache::lonnet::get('environment', - ['firstname','middlename','lastname','generation'], - $sdom,$sname); - my $section=&Apache::lonnet::usection - ($sdom,$sname,$ENV{'request.course.id'}); - $r->print( - '<br><input type=checkbox name="send_to_&&&'.$section.'&&&_'.$_.'"> '. - $reply{'firstname'}.' '. - $reply{'middlename'}.' '. - $reply{'lastname'}.' '. - $reply{'generation'}. - ' ('.$_.') '.$section); - } + $r->print('</table><table>'); + while (my ($student,$info) = each(%$classlist)) { + my ($sname,$sdom,$status,$fullname,$section) = + (@{$info}[&Apache::loncoursedata::CL_SNAME(), + &Apache::loncoursedata::CL_SDOM(), + &Apache::loncoursedata::CL_STATUS(), + &Apache::loncoursedata::CL_FULLNAME(), + &Apache::loncoursedata::CL_SECTION()]); + next if ($status ne 'Active'); + my $key = 'send_to_&&&'.$section.'&&&'.$student; + if (! defined($fullname) || $fullname eq '') { $fullname = $sname; } + $r->print('<tr><td><label>'. + qq{<input type="checkbox" name="$key">}.(' 'x2). + $fullname.'</td><td>'.$sname.'@'.$sdom.'</td><td>'.$section. + '</td></tr>'); } + $r->print('</table>'); } # ==================================================== Display Critical Message @@ -976,6 +970,7 @@ sub compout { $dismsg=~s/\f/\n/g; $dismsg=~s/\n+/\n\> /g; } + my $citation=&displayresource(%content); if ($ENV{'form.recdom'}) { $defdom=$ENV{'form.recdom'}; } $r->print( '<form action="/adm/email" name="compemail" method="post"'. @@ -1016,7 +1011,8 @@ $latexHelp </textarea></p><br /> $dispcrit <input type="submit" name="send" value="$func $lt{'ma'}" /> -<input type="submit" name="cancel" value="$lt{'ca'}" /> +<input type="submit" name="cancel" value="$lt{'ca'}" /><hr /> +$citation ENDCOMP } else { # $broadcast is 'upload' $r->print(<<ENDUPLOAD); @@ -1640,10 +1636,44 @@ sub displaymessage { '<br /><b>'.&mt('Time').':</b> '.$content{'time'}. '<p><pre>'. &Apache::lontexconvert::msgtexconverted($content{'message'},1). - '</pre><hr />'.$content{'citation'}.'</p>'); + '</pre><hr />'.&displayresource(%content).'</p>'); return; } +# =========================================================== Show the citation + +sub displayresource { + my %content=@_; +# +# If the recipient is in the same course that the message was sent from and +# has sufficient privileges, show "all details," else show citation +# + if (($ENV{'request.course.id'} eq $content{'courseid'}) + && (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) { + my $symb=&Apache::lonnet::symbread($content{'baseurl'}); +# Could not get a symb, give up + unless ($symb) { return $content{'citation'}; } +# Have a symb, can render + return '<h2>'.&mt('Current attempts of student (if applicable)').'</h2>'. + &Apache::loncommon::get_previous_attempt($symb, + $content{'sendername'}, + $content{'senderdomain'}, + $content{'courseid'}). + '<hr /><h2>'.&mt('Current screen output (if applicable)').'</h2>'. + &Apache::loncommon::get_student_view($symb, + $content{'sendername'}, + $content{'senderdomain'}, + $content{'courseid'}). + '<h2>'.&mt('Correct Answer(s) (if applicable)').'</h2>'. + &Apache::loncommon::get_student_answers($symb, + $content{'sendername'}, + $content{'senderdomain'}, + $content{'courseid'}); + } else { + return $content{'citation'}; + } +} + # ================================================================== The Header sub header {