Diff for /loncom/homework/lonsimpleproblemedit.pm between versions 1.3 and 1.9

version 1.3, 2003/07/09 10:05:15 version 1.9, 2003/11/08 02:56:09
Line 32  use strict; Line 32  use strict;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonnet;  use Apache::lonnet;
   use Apache::lonlocal;
   
 my %qparms;  my %qparms;
 my $prefix;  my $prefix;
Line 60  sub rawrendering { Line 61  sub rawrendering {
     $ENV{'user.name'}=time;      $ENV{'user.name'}=time;
     $ENV{'user.domain'}=time;      $ENV{'user.domain'}=time;
     my $result = &Apache::lonxml::xmlparse($request,'web', $problem);      my $result = &Apache::lonxml::xmlparse($request,'web', $problem);
       undef($Apache::lonhomework::parsing_a_problem);
     $ENV{'user.name'}=$uname;      $ENV{'user.name'}=$uname;
     $ENV{'user.domain'}=$udom;      $ENV{'user.domain'}=$udom;
     $result=~s/^.*\<body[^\>]*\>//si;      $result=~s/^.*\<body[^\>]*\>//si;
Line 69  sub rawrendering { Line 71  sub rawrendering {
   
 sub questiontext {  sub questiontext {
     my $text=$qparms{$prefix.'questiontext'};      my $text=$qparms{$prefix.'questiontext'};
       my $qt=&mt('Question Text');
     return (<<ENDQUESTION);      return (<<ENDQUESTION);
 <table bgcolor="#dddd22" cellspacing="4" cellpadding="2">  <table bgcolor="#dddd22" cellspacing="4" cellpadding="2">
 <tr><td><b>Question Text</b><br />  <tr><td><b>$qt</b><br />
 <textarea name="questiontext" cols="80" rows="8">$text</textarea>  <textarea name="questiontext" cols="80" rows="8">$text</textarea>
 </td></tr>  </td></tr>
 </table>  </table>
Line 81  ENDQUESTION Line 84  ENDQUESTION
   
 sub hint {  sub hint {
     my $text=$qparms{$prefix.'hinttext'};      my $text=$qparms{$prefix.'hinttext'};
       my $ht=&mt('Hint Text');
     return (<<ENDHINT);      return (<<ENDHINT);
 <table bgcolor="#accacc" cellspacing="4" cellpadding="2">  <table bgcolor="#accacc" cellspacing="4" cellpadding="2">
 <tr><td><b>Hint Text</b><br />  <tr><td><b>$ht</b><br />
 <textarea name="hinttext" cols="80" rows="4">$text</textarea>  <textarea name="hinttext" cols="80" rows="4">$text</textarea>
 </td></tr>  </td></tr>
 </table>  </table>
Line 116  sub foil { Line 120  sub foil {
     my $selectposition=&Apache::loncommon::select_form      my $selectposition=&Apache::loncommon::select_form
                                ($position,'position'.$number,%positions);                                 ($position,'position'.$number,%positions);
     my $text=$qparms{$prefix.'text'.$number};      my $text=$qparms{$prefix.'text'.$number};
       my %lt=&Apache::lonlocal::texthash('foil'  => 'Foil',
          'value' => 'Value',
          'pos'   => 'Position',
          'text'  => 'Text');
   
     return (<<ENDFOIL);      return (<<ENDFOIL);
 <table bgcolor="#dd55ff" cellspacing="4" cellpadding="2">  <table bgcolor="#dd55ff" cellspacing="4" cellpadding="2">
 <tr><td colspan="2"><b>Foil</b></td></tr>  <tr><td colspan="2"><b>$lt{'foil'}</b></td></tr>
 <tr><td>Value: $selectvalue</td><td>Position: $selectposition</td></tr>  <tr><td>$lt{'value'}: $selectvalue</td><td>$lt{'position'}: $selectposition</td></tr>
 <tr><td colspan="2">Text:<br />  <tr><td colspan="2">$lt{'text'}:<br />
 <textarea name="text$number" cols="80" rows="4">$text</textarea>  <textarea name="text$number" cols="80" rows="4">$text</textarea>
 </td></tr>  </td></tr>
 </table>  </table>
Line 132  sub handler { Line 141  sub handler {
     my $r = shift;      my $r = shift;
   
     if ($r->header_only) {      if ($r->header_only) {
         $r->content_type('text/html');          &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;          $r->send_http_header;
         return OK;          return OK;
     }      }
   
 # -------------------------------------------------------------------- Allowed?  # -------------------------------------------------------------------- Allowed?
     unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {      unless (&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'})) {
  return HTTP_NOT_ACCEPTABLE;    return HTTP_NOT_ACCEPTABLE; 
     }      }
 # ----------------------------------------------------------------- Send header  # ----------------------------------------------------------------- Send header
     $r->content_type('text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
 # ----------------------------------------------------- Figure out where we are  # ----------------------------------------------------- Figure out where we are
     my $uri=$r->uri;      my $uri=$r->uri;
Line 167  sub handler { Line 176  sub handler {
     }      }
             $ENV{'form.options'}="('".join("','",keys %curoptions)."')";              $ENV{'form.options'}="('".join("','",keys %curoptions)."')";
  }   }
    $ENV{'form.hiddenparts'}='!'.$ENV{'form.questiontype'};
         foreach (keys %ENV) {          foreach (keys %ENV) {
     if ($_=~/^form\.(\w+)$/) {      if ($_=~/^form\.(\w+)$/) {
                 my $parm=$1;                  my $parm=$1;
Line 210  ENDDOCUMENT Line 220  ENDDOCUMENT
         $qtype=$qparms{$prefix.'questiontype'};          $qtype=$qparms{$prefix.'questiontype'};
         unless (defined($qtype)) { $qtype='radio'; }          unless (defined($qtype)) { $qtype='radio'; }
         unless ($questiontypes{$qtype}) { $qtype='radio'; }          unless ($questiontypes{$qtype}) { $qtype='radio'; }
         $r->print('Question Type: '.&Apache::loncommon::select_form          $r->print('<b>'.&mt('Question Type').
     ': '.&Apache::loncommon::select_form
                                ($qtype,'questiontype',%questiontypes).                                 ($qtype,'questiontype',%questiontypes).
                   '<p>&nbsp;</p>');    '</b><br /><input type="submit" value="'.&mt('Store Changes').
     '" /><p>&nbsp;</p>');
 # Question Text  # Question Text
         $r->print(&questiontext());          $r->print(&questiontext());
 # Radio, Option ===  # Radio, Option ===
Line 229  ENDDOCUMENT Line 241  ENDDOCUMENT
             unless ($randomizes{$randomize}) { $randomize='yes'; }              unless ($randomizes{$randomize}) { $randomize='yes'; }
     $r->print(      $r->print(
   '<table bgcolor="#00ee44" cellspacing="4" cellpadding="2">'.    '<table bgcolor="#00ee44" cellspacing="4" cellpadding="2">'.
           '<tr><td>Max number of foils displayed: <input type="text" size="3" name="maxfoils" value="'.$maxfoils.'" />&nbsp;&nbsp;'.            '<tr><td>'.&mt('Max number of foils displayed').
   ': <input type="text" size="3" name="maxfoils" value="'.$maxfoils.'" />&nbsp;&nbsp;'.
       &Apache::loncommon::select_form        &Apache::loncommon::select_form
       ($randomize,'randomize',%randomizes).        ($randomize,'randomize',%randomizes).
   '</td></tr><tr><td bgcolor="#AAAAAA">');    '</td></tr><tr><td bgcolor="#AAAAAA">');
Line 241  ENDDOCUMENT Line 254  ENDDOCUMENT
  $r->print(   $r->print(
   '<table bgcolor="#ffcc22" cellspacing="4" cellpadding="2">'.    '<table bgcolor="#ffcc22" cellspacing="4" cellpadding="2">'.
   '<tr><td><input type="hidden" name="options" value="'.    '<tr><td><input type="hidden" name="options" value="'.
                   $options.'" />Add new option: '.                    $options.'" />'.&mt('Add new option').': '.
           '<input type="text" name="newopt" size="15" />Delete an option: '.            '<input type="text" name="newopt" size="15" />'.
             &mt('Delete an option').': '.
           &Apache::loncommon::select_form('','delopt',('' => '',%optionshash)).            &Apache::loncommon::select_form('','delopt',('' => '',%optionshash)).
           '</td></tr><tr><td>');            '</td></tr><tr><td>');
     }      }
Line 272  ENDDOCUMENT Line 286  ENDDOCUMENT
             unless ($stringtypes{$stringtype}) { $stringtype='cs'; }              unless ($stringtypes{$stringtype}) { $stringtype='cs'; }
     $r->print(      $r->print(
   '<table bgcolor="#00ee44" cellspacing="4" cellpadding="2">'.    '<table bgcolor="#00ee44" cellspacing="4" cellpadding="2">'.
           '<tr><td>Correct answer: <input type="text" size="20" name="stringanswer" value="'.$stringanswer.'" />&nbsp;&nbsp;'.            '<tr><td>'.&mt('Correct answer').': <input type="text" size="20" name="stringanswer" value="'.$stringanswer.'" />&nbsp;&nbsp;'.
       &Apache::loncommon::select_form        &Apache::loncommon::select_form
       ($stringtype,'stringtype',%stringtypes).        ($stringtype,'stringtype',%stringtypes).
   '</td></tr></table><br />');    '</td></tr></table><br />');
Line 281  ENDDOCUMENT Line 295  ENDDOCUMENT
  }   }
 # Store Button  # Store Button
  $r->print(   $r->print(
   '<input type="submit" name="storeproblem" value="Store Changes" /></form>');    '<input type="submit" value="'.&mt('Store Changes').'" /></form>');
     } else {      } else {
  $r->print('Could not identify problem.');   $r->print(&mt('Could not identify problem.'));
     }      }
     $r->print('</body></html>');      $r->print('</body></html>');
     return OK;      return OK;

Removed from v.1.3  
changed lines
  Added in v.1.9


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