--- loncom/homework/structuretags.pm 2003/04/03 17:44:12 1.161
+++ loncom/homework/structuretags.pm 2003/05/27 18:58:51 1.178
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.161 2003/04/03 17:44:12 albertel Exp $
+# $Id: structuretags.pm,v 1.178 2003/05/27 18:58:51 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,7 +38,7 @@ use Apache::File();
use Apache::lonmenu;
BEGIN {
- &Apache::lonxml::register('Apache::structuretags',('block','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','startouttext','endouttext'));
+ &Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','startouttext','endouttext'));
}
sub start_web {
@@ -104,10 +104,11 @@ sub page_start {
}
$body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1);
if ($target eq 'web' && $ENV{'request.state'} ne 'construct') {
- my ($symb)=&Apache::lonxml::whichuser();
- if ($symb eq '') {
+ my ($symb,undef,undef,undef,$publicuser)=
+ &Apache::lonxml::whichuser();
+ if ($symb eq '' && !$publicuser) {
my $help = &Apache::loncommon::help_open_topic("Ambiguous_Reference");
- $help="Browsing or ambiguous reference, submissions ignored $help ";
+ $help="Browsing resource, all submissions are temporary. ";
$body_tag_start.=$help;
}
}
@@ -135,10 +136,23 @@ sub get_resource_name {
sub setup_rndseed {
my ($safeeval)=@_;
my $rndseed;
- if ($ENV{'request.state'} eq "construct") {
+ my ($symb)=&Apache::lonxml::whichuser();
+ if ($ENV{'request.state'} eq "construct" || $symb eq '') {
$rndseed=$ENV{'form.rndseed'};
if (!$rndseed) {
+ $rndseed=$Apache::lonhomework::history{'rndseed'};
+ if (!$rndseed) {
+ $rndseed=time;
+ $ENV{'form.rndseed'}=$rndseed;
+ }
+ }
+ if ($ENV{'form.resetdata'} eq 'New Problem Variation' ||
+ $ENV{'form.newrandomization'} eq 'New Randomization') {
$rndseed=time;
+ if ($rndseed eq $ENV{'form.rndseed'}) {
+ srand($rndseed);
+ $rndseed=int(rand(1000000000));
+ }
$ENV{'form.rndseed'}=$rndseed;
}
&Apache::lonxml::debug("Setting rndseed to $rndseed");
@@ -168,26 +182,32 @@ sub problem_web_to_edit_header {
my $result.='
- Random Seed:
-
+
+
+
Show All Foils
';
my $numtoanalyze=$ENV{'form.numtoanalyze'};
- if (!$numtoanalyze) { $numtoanalyze=100; }
- $result.= '
+ if (!$numtoanalyze) { $numtoanalyze=20; }
+ $result.= ' for
';
+ $numtoanalyze.'" size="5" /> versions of this problem.'.
+ &Apache::loncommon::help_open_topic("Analyze_Problem",
+ '',undef,undef,300).
+ '';
return $result;
}
sub initialize_storage {
%Apache::lonhomework::results=();
+ %Apache::lonhomework::history=();
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
- if ($ENV{'request.state'} eq 'construct') {
+ if ($ENV{'request.state'} eq 'construct' || $symb eq '') {
%Apache::lonhomework::history=
&Apache::lonnet::tmprestore($ENV{'request.uri'},'',$domain,$name);
my ($temp)=keys %Apache::lonhomework::history ;
@@ -210,7 +230,8 @@ sub finalize_storage {
my ($temp) = keys %Apache::lonhomework::results;
if ( $temp ne '' ) {
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
- if ($ENV{'request.state'} eq 'construct') {
+ if ($ENV{'request.state'} eq 'construct' || $symb eq '') {
+ $Apache::lonhomework::results{'rndseed'}=$ENV{'form.rndseed'};
$result=&Apache::lonnet::tmpstore(\%Apache::lonhomework::results,
$ENV{'request.uri'},'',$domain,$name);
&Apache::lonxml::debug('Construct Store return message:'.$result);
@@ -253,13 +274,22 @@ sub start_problem {
}
#initialize globals
$Apache::inputtags::part='0';
+ @Apache::inputtags::partlist=('0');
@Apache::inputtags::responselist = ();
+ @Apache::inputtags::importlist = ();
@Apache::inputtags::previous=();
@Apache::inputtags::previous_version=();
$Apache::structuretags::printanswer='No';
@Apache::structuretags::whileconds=();
@Apache::structuretags::whilebody=();
@Apache::structuretags::whileline=();
+ $Apache::lonhomework::scantronmode=0;
+ $Apache::lonhomework::problemstatus=
+ &Apache::lonnet::EXT('resource.0.problemstatus');
+
+ if (defined($ENV{'scantron.maxquest'})) {
+ $Apache::lonhomework::scantronmode=1;
+ }
if ($target ne 'analyze') {
&initialize_storage();
@@ -269,7 +299,7 @@ sub start_problem {
$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
&Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:");
}
- if ($Apache::lonhomework::type eq '') {
+ if ($Apache::lonhomework::type eq '' ) {
my $uri=$ENV{'request.uri'};
if ($uri=~/\.(\w+)$/) {
$Apache::lonhomework::type=$1;
@@ -308,6 +338,15 @@ sub start_problem {
#handle rand seed in construction space
my $rndseed=&setup_rndseed($safeeval);
+ my ($symb)=&Apache::lonxml::whichuser();
+ if ($ENV{'request.state'} ne "construct" && $symb eq '') {
+ $form_tag_start.=''.
+ ''.
+ '';
+ }
($status,$accessmsg) = &Apache::lonhomework::check_access('0');
push (@Apache::inputtags::status,$status);
my $expression='$external::datestatus="'.$status.'";';
@@ -364,6 +403,10 @@ sub start_problem {
"$name\n$body_tag_start\n";
}
} elsif ($target eq 'tex') {
+ my $startminipage = '';
+ if ($ENV{'form.problem_split'} ne 'yes') {
+ $startminipage = '\begin{minipage}{\textwidth}';
+ }
my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);
if ($name eq '') {
$name=&Apache::lonnet::EXT('resource.title');
@@ -398,9 +441,9 @@ sub start_problem {
print $temp_file "$duedate\n";
if (not $ENV{'request.symb'} =~ m/\.page_/) {
if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {
- $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource
"'.$name_of_resourse.'"
located in '.$ENV{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent\textit{Due date: '.$duedate.'} \vskip 1 mm\noindent \begin{minipage}{\textwidth}';
+ $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource
"'.$name_of_resourse.'"
located in '.$ENV{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent\textit{Due date: '.$duedate.'} \vskip 1 mm\noindent '.$startminipage;
} else {
- $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource
"'.$name_of_resourse.'"
located in '.$ENV{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm \noindent\begin{minipage}{\textwidth}';
+ $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource
"'.$name_of_resourse.'"
located in '.$ENV{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm \noindent'.$startminipage;
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
}
} else {
@@ -408,7 +451,7 @@ sub start_problem {
}
} else {
if (not $ENV{'request.symb'} =~ m/\.page_/) {
- $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource
"'.$name_of_resourse.'"
located in '.$ENV{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm\noindent\begin{minipage}{\textwidth}';
+ $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource
"'.$name_of_resourse.'"
located in '.$ENV{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm\noindent'.$startminipage;
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
} else {
$result .= '\vskip 1mm \\\\\\\\';
@@ -453,7 +496,8 @@ sub end_problem {
($target eq 'answer') || ($target eq 'tex')
) {
if ($status eq 'CAN_ANSWER') {
- if ($target ne 'tex') {
+ if ($target ne 'tex' &&
+ $ENV{'form.answer_output_mode'} ne 'tex') {
$result.="