Diff for /loncom/homework/lonhomework.pm between versions 1.236 and 1.242

version 1.236, 2006/02/26 20:01:17 version 1.242, 2006/04/25 15:32:40
Line 143  sub setup_vars { Line 143  sub setup_vars {
 #  return ';$external::target='.$target.';';  #  return ';$external::target='.$target.';';
 }  }
   
 sub send_header {  
     my ($request)= @_;  
     $request->print(&Apache::lontexconvert::header());  
 #  $request->print('<form name='.$env{'form.request.prefix'}.'lonhomework method="POST" action="'.$request->uri.'">');  
 }  
   
 sub createmenu {  sub createmenu {
     my ($which,$request)=@_;      my ($which,$request)=@_;
     if ($which eq 'grade') {      if ($which eq 'grade') {
Line 159  sub createmenu { Line 153  sub createmenu {
     }      }
 }  }
   
 sub send_footer {  
     my ($request)= @_;  
 #  $request->print('</form>');  
     $request->print(&Apache::lontexconvert::footer());  
 }  
   
 sub proctor_checked_in {  sub proctor_checked_in {
     my ($slot_name,$slot,$type)=@_;      my ($slot_name,$slot,$type)=@_;
     my @possible_proctors=split(",",$slot->{'proctor'});      my @possible_proctors=split(",",$slot->{'proctor'});
Line 246  sub check_slot_access { Line 234  sub check_slot_access {
     my ($status,$datemsg)=&check_access($id);      my ($status,$datemsg)=&check_access($id);
           
     my $useslots = &Apache::lonnet::EXT("resource.$id.useslots");      my $useslots = &Apache::lonnet::EXT("resource.$id.useslots");
     if ($useslots ne 'resource') {      if ($useslots ne 'resource' && $useslots ne 'sequence') {
  return ($status,$datemsg);   return ($status,$datemsg);
     }      }
   
Line 278  sub check_slot_access { Line 266  sub check_slot_access {
     my $slotstatus='NOT_IN_A_SLOT';      my $slotstatus='NOT_IN_A_SLOT';
     my ($returned_slot,$slot_name);      my ($returned_slot,$slot_name);
     foreach my $slot (@slots) {      foreach my $slot (@slots) {
    $slot =~ s/(^\s*|\s*$)//g;
  &Apache::lonxml::debug("getting $slot");   &Apache::lonxml::debug("getting $slot");
  my %slot=&Apache::lonnet::get_slot($slot);   my %slot=&Apache::lonnet::get_slot($slot);
  &Apache::lonhomework::showhash(%slot);   &Apache::lonhomework::showhash(%slot);
Line 634  sub handle_save_or_undo { Line 623  sub handle_save_or_undo {
   
 sub analyze_header {  sub analyze_header {
     my ($request) = @_;      my ($request) = @_;
     my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,      my $result =
     ($env{'environment.remote'} ne 'off'));   &Apache::loncommon::start_page('Analyzing a problem',undef);
     my $html=&Apache::lonxml::xmlbegin();  
     my $result.=$html.'      $result .= 
             <head><title>'.&mt("Analyzing a problem").'</title></head>   &Apache::lonxml::message_location().'
             '.$bodytag.&Apache::lonxml::message_location().'  
             <form name="lonhomework" method="POST" action="'.              <form name="lonhomework" method="POST" action="'.
     &HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.      &HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.
     &Apache::structuretags::remember_problem_state().'      &Apache::structuretags::remember_problem_state().'
Line 656  sub analyze_header { Line 644  sub analyze_header {
   
 sub analyze_footer {  sub analyze_footer {
     my ($request) = @_;      my ($request) = @_;
     my $result='</body></html>';      $request->print(&Apache::loncommon::end_page());
     $request->print($result);  
     $request->rflush();      $request->rflush();
 }  }
   
Line 768  sub editxmlmode { Line 755  sub editxmlmode {
  if ($cols > 80) { $cols = 80; }   if ($cols > 80) { $cols = 80; }
  if ($cols < 70) { $cols = 70; }   if ($cols < 70) { $cols = 70; }
  if ($rows < 20) { $rows = 20; }   if ($rows < 20) { $rows = 20; }
  my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,   my $start_page = 
  ($env{'environment.remote'} ne 'off'));      &Apache::loncommon::start_page("EditXML $file",
  my $html=&Apache::lonxml::xmlbegin();     &Apache::edit::js_change_detection());
  my $head="<head><title>EditXML $file</title>".  
     &Apache::edit::js_change_detection()."</head>";  
   
  $result.=$html.$head.$bodytag.   $result.=$start_page.
     &renderpage($request,$file,['no_output_web'],1).      &renderpage($request,$file,['no_output_web'],1).
     &Apache::lonxml::message_location().'      &Apache::lonxml::message_location().'
             <form '.&Apache::edit::form_change_detection().' name="lonhomework" method="POST" action="'.              <form '.&Apache::edit::form_change_detection().' name="lonhomework" method="POST" action="'.
Line 793  sub editxmlmode { Line 778  sub editxmlmode {
     &HTML::Entities::encode($problem,'<>&"').'</textarea><br />      &HTML::Entities::encode($problem,'<>&"').'</textarea><br />
             <input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes').'" />              <input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes').'" />
             <input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" />              <input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" />
             </form></body></html>';              </form>'.&Apache::loncommon::end_page();
  &Apache::lonxml::add_messages(\$result);   &Apache::lonxml::add_messages(\$result);
  $request->print($result);   $request->print($result);
     }      }
Line 925  sub newproblem { Line 910  sub newproblem {
     $errormsg='<p><font color="red">'.&mt('You did not select a template.').'</font></p>'."\n";      $errormsg='<p><font color="red">'.&mt('You did not select a template.').'</font></p>'."\n";
  }   }
  my $instructions;   my $instructions;
  my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,   my $start_page = 
  ($env{'environment.remote'} ne 'off'));      &Apache::loncommon::start_page("Create New $extension");
  if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");}   if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");}
  my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new',   my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new',
   'resource' => 'resource',    'resource' => 'resource',
Line 937  sub newproblem { Line 922  sub newproblem {
   'Create' => 'Create',    'Create' => 'Create',
   'button' => 'button');    'button' => 'button');
  $request->print(<<ENDNEWPROBLEM);   $request->print(<<ENDNEWPROBLEM);
 $bodytag  $start_page
 <h1>$lt{'create'} $extension $lt{'resource'}</h1>  <h1>$lt{'create'} $extension $lt{'resource'}</h1>
 $errormsg  $errormsg
 $lt{'requested'} <tt>$shownurl</tt> $lt{'not exist'}.  $lt{'requested'} <tt>$shownurl</tt> $lt{'not exist'}.
Line 950  ENDNEWPROBLEM Line 935  ENDNEWPROBLEM
     $request->print("<select name=\"template\">$templatelist</select>");      $request->print("<select name=\"template\">$templatelist</select>");
  }   }
  $request->print("<br /><input type=\"submit\" name=\"newfile\" value=\"".&mt('Create')." $extension\" />");   $request->print("<br /><input type=\"submit\" name=\"newfile\" value=\"".&mt('Create')." $extension\" />");
  $request->print("</form></p></body>");   $request->print("</form></p>".&Apache::loncommon::end_page());
     }      }
     return '';      return '';
 }  }
   
 sub view_or_edit_menu {  
     my ($request) = @_;  
     my $url=&HTML::Entities::encode($request->uri,'<>&"');  
     my %lt=&Apache::lonlocal::texthash( 'would' => 'Would you like to',  
       'view' => 'View',  
       'Edit' => 'edit',  
       'or' => 'or',  
       'the problem' => 'the problem');  
     $request->print(<<EDITMENU);  
 <body bgcolor="#FFFFFF">  
 <form action="$url" method="POST">  
 $lt{'would'} <input type="submit" name="problemmode" accesskey="v" value="&lt{'view'}">  
 &lt{'or'} <input type="submit" name="problemmode" accesskey="e" value="&lt{'Edit'}">  
 &lt{'the problem'}.  
 </form>  
 </body>  
 EDITMENU  
 }  
   
 sub handler {  sub handler {
     #my $t0 = [&gettimeofday()];      #my $t0 = [&gettimeofday()];
     my $request=$_[0];      my $request=$_[0];
Line 1011  sub handler { Line 977  sub handler {
     ['problemmode']);      ['problemmode']);
     if (!(defined $env{'form.problemmode'})) {      if (!(defined $env{'form.problemmode'})) {
  #first visit to problem in construction space   #first visit to problem in construction space
  #&view_or_edit_menu($request);  
  $env{'form.problemmode'}='View';   $env{'form.problemmode'}='View';
  &renderpage($request,$file);   &renderpage($request,$file);
     } elsif ($env{'form.problemmode'} eq &mt('EditXML') ||      } elsif ($env{'form.problemmode'} eq &mt('EditXML') ||
Line 1033  sub handler { Line 998  sub handler {
     }      }
     #my $td=&tv_interval($t0);      #my $td=&tv_interval($t0);
     #&Apache::lonxml::debug("Spent $td seconds processing");      #&Apache::lonxml::debug("Spent $td seconds processing");
     # &Apache::lonhomework::send_footer($request);  
     # always turn off debug messages      # always turn off debug messages
     $Apache::lonxml::debug=0;      $Apache::lonxml::debug=0;
     return OK;      return OK;

Removed from v.1.236  
changed lines
  Added in v.1.242


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>