--- loncom/homework/structuretags.pm 2007/07/23 23:30:47 1.384
+++ loncom/homework/structuretags.pm 2007/08/14 04:29:37 1.390
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.384 2007/07/23 23:30:47 albertel Exp $
+# $Id: structuretags.pm,v 1.390 2007/08/14 04:29:37 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -202,20 +202,27 @@ function setSubmittedPart (part) {
#use Time::HiRes();
sub get_resource_name {
my ($parstack,$safeeval)=@_;
+ my $name;
if (defined($Apache::lonhomework::name)) {
- return $Apache::lonhomework::name;
- }
- my ($symb)=&Apache::lonnet::whichuser();
- my $name=&Apache::lonnet::gettitle($symb);
- if ($name eq '') {
- $name=&Apache::lonnet::EXT('resource.title');
- if ($name eq 'con_lost') { $name = ''; }
- }
- if ($name!~/\S+/) {
- $name=$env{'request.uri'};
- $name=~s-.*/([^/]+)$-$1-;
+ $name = $Apache::lonhomework::name;
+ } else {
+ my ($symb)=&Apache::lonnet::whichuser();
+ my $name=&Apache::lonnet::gettitle($symb);
+ if ($name eq '') {
+ $name=&Apache::lonnet::EXT('resource.title');
+ if ($name eq 'con_lost') { $name = ''; }
+ }
+ if ($name!~/\S+/) {
+ $name=$env{'request.uri'};
+ $name=~s-.*/([^/]+)$-$1-;
+ }
+ # The name has had html tags escaped:
+
+ $name=~s/<//gs;
+
+ $Apache::lonhomework::name=$name;
}
- $Apache::lonhomework::name=$name;
return $name;
}
@@ -319,7 +326,7 @@ sub problem_web_to_edit_header {
$result.= ' />'.$show_all_foils_text.''.
&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
'
';
- $result.=&mt('Apply style file').'
+ $result.=&mt('Apply style file: ').'
&').'" />
'.&mt('Select').'
@@ -458,7 +465,6 @@ sub finalize_storage {
}
return $result;
}
-use Data::Dumper;
# -------------------------------------------------------------store_aggregates
# Sends hash of values to be incremented in nohist_resourcetracker.db
@@ -638,7 +644,6 @@ sub start_problem {
}
if ($target ne 'analyze') {
- if ($env{'request.state'} eq 'construct') { &set_problem_state('0'); }
$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
if (($env{'request.state'} eq 'construct') &&
defined($env{'form.problemtype'})) {
@@ -659,6 +664,11 @@ sub start_problem {
$Apache::lonhomework::default_type = $Apache::lonhomework::type;
&initialize_storage();
+ if ($target ne 'analyze'
+ && $env{'request.state'} eq 'construct') {
+ &set_problem_state('0');
+ }
+
if ($target eq 'web') {
&Apache::lonxml::debug(" grading history ");
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
@@ -1081,7 +1091,7 @@ sub start_block {
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
my $code = $token->[2]->{'condition'};
- if (defined($code)) {
+ if (defined($code) && $code ne '') {
if (!$Apache::lonxml::default_homework_loaded) {
&Apache::lonxml::default_homework_load($safeeval);
}
@@ -1375,8 +1385,7 @@ sub start_part {
# duedates.
}
my $result='';
- my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
- if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
+ my $id= &Apache::lonxml::get_id($parstack,$safeeval);
$Apache::inputtags::part=$id;
push(@Apache::inputtags::partlist,$id);
@Apache::inputtags::response=();
@@ -1429,7 +1438,7 @@ sub start_part {
if ($target eq 'tex') {
if (not $env{'form.problem_split'}=~/yes/) {
if ($$tagstack[-2] eq 'td') {
- $result.='\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
+ $result.='\noindent \begin{minipage}{\textwidth}\noindent';
} else {
$result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
}