version 1.215, 2003/10/09 21:49:24
|
version 1.226, 2003/11/21 20:21:20
|
Line 171 sub setup_rndseed {
|
Line 171 sub setup_rndseed {
|
if (defined($rndseed) && $rndseed ne int($rndseed)) { |
if (defined($rndseed) && $rndseed ne int($rndseed)) { |
$rndseed=join(',',&Math::Random::random_seed_from_phrase($rndseed)); |
$rndseed=join(',',&Math::Random::random_seed_from_phrase($rndseed)); |
} |
} |
&Apache::lonxml::debug("Setting rndseed to $rndseed"); |
if ($safeeval) { |
&Apache::run::run('$external::randomseed='.$rndseed.';',$safeeval); |
&Apache::lonxml::debug("Setting rndseed to $rndseed"); |
|
&Apache::run::run('$external::randomseed='.$rndseed.';',$safeeval); |
|
} |
} |
} |
return $rndseed; |
return $rndseed; |
} |
} |
Line 400 sub start_problem {
|
Line 402 sub start_problem {
|
if (( $status eq 'CLOSED' ) || |
if (( $status eq 'CLOSED' ) || |
( $status eq 'UNCHECKEDOUT') || |
( $status eq 'UNCHECKEDOUT') || |
( $status eq 'BANNED') || |
( $status eq 'BANNED') || |
( $status eq 'UNAVAILABLE')) { |
( $status eq 'UNAVAILABLE') || |
|
( $status eq 'INVALID_ACCESS')) { |
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser); |
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser); |
if ( $target eq "web" ) { |
if ( $target eq "web" ) { |
$result.= $head_tag_start.'</head>'; |
$result.= $head_tag_start.'</head>'; |
Line 410 sub start_problem {
|
Line 413 sub start_problem {
|
} else { |
} else { |
$result.='<h1>'.&mt('Not open to be viewed').'</h1>'; |
$result.='<h1>'.&mt('Not open to be viewed').'</h1>'; |
} |
} |
if ($status eq 'CLOSED') { |
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') { |
$msg.='The problem '.$accessmsg; |
$msg.='The problem '.$accessmsg; |
} elsif ($status eq 'UNCHECKEDOUT') { |
} elsif ($status eq 'UNCHECKEDOUT') { |
$msg.=&checkout_msg; |
$msg.=&checkout_msg; |
Line 442 sub start_problem {
|
Line 445 sub start_problem {
|
} |
} |
} |
} |
} elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' |
} elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' |
|| $status eq 'CLOSED' || $status eq 'UNAVALAILABLE') { |
|| $status eq 'CLOSED' || $status eq 'UNAVALAILABLE' || |
|
$status eq 'INVALID_ACCESS') { |
$result.=$head_tag_start. |
$result.=$head_tag_start. |
"<title>$name</title></head>\n$body_tag_start\n"; |
"<title>$name</title></head>\n$body_tag_start\n"; |
} |
} |
Line 453 sub start_problem {
|
Line 457 sub start_problem {
|
} |
} |
my $id = $Apache::inputtags::part; |
my $id = $Apache::inputtags::part; |
my $weight = &Apache::lonnet::EXT("resource.$id.weight"); |
my $weight = &Apache::lonnet::EXT("resource.$id.weight"); |
my $allkeys=&Apache::lonnet::metadata($ENV{'request.uri'},'keys'); |
my $packages=&Apache::lonnet::metadata($ENV{'request.uri'},'packages'); |
my @allkeys = split /,/,$allkeys; |
my @packages = split /,/,$packages; |
my $allow_print_points = 0; |
my $allow_print_points = 0; |
foreach my $partial_key (@allkeys) { |
foreach my $partial_key (@packages) { |
if ($partial_key=~m/weight/) { |
if ($partial_key=~m/part_0/) { |
$allow_print_points++; |
$allow_print_points=1; |
} |
} |
} |
} |
my $duedate = &Apache::lonnet::EXT("resource.$id.duedate"); |
my $duedate = &Apache::lonnet::EXT("resource.$id.duedate"); |
Line 499 sub start_problem {
|
Line 503 sub start_problem {
|
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start. |
$result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start. |
&problem_edit_header(); |
&problem_edit_header(); |
|
$Apache::lonxml::warnings_error_header= |
|
&mt("Editor Errors - these errors might not effect the running of the problem, but they will likely cause problems with further use of the Edit mode. Please use the EditXML mode to fix these errors.")."<br />"; |
my $temp=&Apache::edit::insertlist($target,$token); |
my $temp=&Apache::edit::insertlist($target,$token); |
$result.=$temp; |
$result.=$temp; |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
Line 539 sub end_problem {
|
Line 545 sub end_problem {
|
$result.="</form></body>\n"; |
$result.="</form></body>\n"; |
} |
} |
} elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' || |
} elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' || |
$status eq 'UNCHECKEDOUT' ) { |
$status eq 'UNCHECKEDOUT' || $status eq 'INVALID_ACCESS') { |
if ($target ne 'tex' && |
if ($target ne 'tex' && |
$ENV{'form.answer_output_mode'} ne 'tex') { |
$ENV{'form.answer_output_mode'} ne 'tex') { |
$result.="</body>\n"; |
$result.="</body>\n"; |
Line 944 sub start_part {
|
Line 950 sub start_part {
|
&Apache::run::run($expression,$safeeval); |
&Apache::run::run($expression,$safeeval); |
|
|
if ($target eq 'meta') { |
if ($target eq 'meta') { |
return &Apache::response::mandatory_part_meta; |
my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval); |
|
return &Apache::response::mandatory_part_meta. |
|
&Apache::response::meta_parameter_write('display','string',$display,'Part Description'); |
} elsif ($target eq 'web' || $target eq 'grade' || |
} elsif ($target eq 'web' || $target eq 'grade' || |
$target eq 'answer' || $target eq 'tex') { |
$target eq 'answer' || $target eq 'tex') { |
if ($hidden) { |
if ($hidden) { |
Line 955 sub start_part {
|
Line 963 sub start_part {
|
my $expression='$external::datestatus="'.$status.'";'; |
my $expression='$external::datestatus="'.$status.'";'; |
$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";'; |
$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";'; |
&Apache::run::run($expression,$safeeval); |
&Apache::run::run($expression,$safeeval); |
if ( $status eq 'CLOSED' ) { |
if (( $status eq 'CLOSED' ) || |
|
( $status eq 'UNCHECKEDOUT') || |
|
( $status eq 'BANNED') || |
|
( $status eq 'UNAVAILABLE') || |
|
( $status eq 'INVALID_ACCESS')) { |
my $bodytext=&Apache::lonxml::get_all_text("/part",$parser); |
my $bodytext=&Apache::lonxml::get_all_text("/part",$parser); |
if ( $target eq "web" ) { |
if ( $target eq "web" ) { |
$result="<br />".&mt('Part is not open to be viewed. It')." $accessmsg<br />"; |
$result="<br />".&mt('Part is not open to be viewed. It')." $accessmsg<br />"; |
Line 972 sub start_part {
|
Line 984 sub start_part {
|
$result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent'; |
$result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent'; |
} |
} |
my $weight = &Apache::lonnet::EXT("resource.$id.weight"); |
my $weight = &Apache::lonnet::EXT("resource.$id.weight"); |
if ($Apache::lonhomework::type eq 'exam') { $result .= '\fbox{\textit{'.$weight.' pt}}';} |
my $allkeys=&Apache::lonnet::metadata($ENV{'request.uri'},'keys'); |
|
my @allkeys = split /,/,$allkeys; |
|
my $allow_print_points = 0; |
|
foreach my $partial_key (@allkeys) { |
|
if ($partial_key=~m/\_(\d*)\_weight/) { |
|
if ($1 ne '0') {$allow_print_points=1;} |
|
} |
|
} |
|
if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { $result .= '\fbox{\textit{'.$weight.' pt}}';} |
} |
} |
} |
} |
} |
} |
Line 980 sub start_part {
|
Line 1000 sub start_part {
|
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::text_arg('Part ID:','id',$token). |
$result.=&Apache::edit::text_arg('Part ID:','id',$token). |
&Apache::loncommon::help_open_topic("Part_Tag_Edit_Help"). |
&Apache::loncommon::help_open_topic("Part_Tag_Edit_Help"). |
|
' '. |
|
&Apache::edit::text_arg('Displayed Part Description:','display',$token). |
&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
$safeeval,'id'); |
$safeeval,'id','display'); |
if ($constructtag) { |
if ($constructtag) { |
|
#limiting ids to only letters numbers, and space |
|
$token->[2]->{'id'}=~s/[^A-Za-z0-9 ]//gs; |
$result = &Apache::edit::rebuild_tag($token); |
$result = &Apache::edit::rebuild_tag($token); |
$result.=&Apache::edit::handle_insert(); |
$result.=&Apache::edit::handle_insert(); |
} |
} |
Line 1109 sub end_startouttext {
|
Line 1133 sub end_startouttext {
|
&Apache::edit::editfield($token->[1],$text,"",80,4); |
&Apache::edit::editfield($token->[1],$text,"",80,4); |
} |
} |
if ($target eq 'modified') { |
if ($target eq 'modified') { |
$text=&Apache::lonxml::get_all_text("endouttext",$parser); |
$result='<startouttext />'.&Apache::edit::modifiedfield("endouttext",$parser); |
$result='<startouttext />'.&Apache::edit::modifiedfield(); |
|
} |
} |
if ($target eq 'tex') { |
if ($target eq 'tex') { |
$result .= '\noindent '; |
$result .= '\noindent '; |
Line 1154 sub start_simpleeditbutton {
|
Line 1177 sub start_simpleeditbutton {
|
my $result=''; |
my $result=''; |
if (($target eq 'web') && |
if (($target eq 'web') && |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
my $url=$ENV{'REQUEST_URI'}; |
my $url=$ENV{'request.noversionuri'}; |
$url=~s/\?.*$//; |
$url=~s/\?.*$//; |
$result='<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>'. |
$result='<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>'. |
'<a href="'.$url.'/smpedit">'.&mt('Simple Problem Editor').'</a> - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.'). |
'<a href="'.$url.'/smpedit">'.&mt('Simple Problem Editor').'</a> - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.'). |