';
+ '';
}
sub problem_edit_footer {
return ' |
'.
-
- &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields()).
"\n\n".&Apache::loncommon::end_page();
}
@@ -435,12 +573,14 @@ sub problem_web_to_edit_header {
my $show_all_foils_text =
($Apache::lonhomework::parsing_a_task) ?
- &mt(' Show All Instances')
- : &mt(' Show All Foils');
+ &mt('Show All Instances')
+ : &mt('Show All Foils');
- my $show_all= '';
+ $show_all.= ' /> '.$show_all_foils_text
+ .'';
@@ -466,7 +606,11 @@ sub problem_web_to_edit_header {
".&option('exam' ,'problemtype').&mt("Exam Problem")."
".&option('problem','problemtype').&mt("Homework Problem")."
".&option('survey' ,'problemtype').&mt("Survey Question")."
+ ".&option('surveycred' ,'problemtype').&mt("Survey Question (with credit)")."
+ ".&option('anonsurvey' ,'problemtype').&mt("Anonymous Survey Question")."
+ ".&option('anonsurveycred' ,'problemtype').&mt("Anonymous Survey Question (with credit)")."
".&option('practice' ,'problemtype').&mt("Practice Problem")."
+ ".&option('randomizetry' ,'problemtype').&mt("New Randomization Each Try")."
$show_all
@@ -513,11 +657,11 @@ $show_all
-
+
- ';
@@ -537,7 +681,7 @@ $show_all
$result.='
-
+
';
$result.='';
$result .= '';
$result.='
-
+
'.&Apache::lonxml::message_location().'
';
return $result;
@@ -624,9 +768,7 @@ sub finalize_storage {
$result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,
$symb,$courseid,$domain,$name);
&Apache::lonxml::debug('Store return message:'.$result);
- if ($env{'request.role'} =~/^st/) {
- &store_aggregates($symb,$courseid);
- }
+ &store_aggregates($symb,$courseid);
}
} else {
&Apache::lonxml::debug('Nothing to store');
@@ -646,7 +788,7 @@ item store_aggregates()
sub store_aggregates {
my ($symb,$courseid) = @_;
- my %aggregate;
+ my (%aggregate,%anoncounter,%randtrycounter);
my @parts;
my $cdomain = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cname = $env{'course.'.$env{'request.course.id'}.'.num'};
@@ -656,28 +798,60 @@ sub store_aggregates {
}
}
foreach my $part (@parts) {
- if ($Apache::lonhomework::results{'resource.'.$part.'.award'}
- eq 'APPROX_ANS' ||
- $Apache::lonhomework::results{'resource.'.$part.'.award'}
- eq 'EXACT_ANS') {
- $aggregate{$symb."\0".$part."\0correct"} = 1;
+ if ($env{'request.role'} =~/^st/) {
+ if ($Apache::lonhomework::results{'resource.'.$part.'.award'}
+ eq 'APPROX_ANS' ||
+ $Apache::lonhomework::results{'resource.'.$part.'.award'}
+ eq 'EXACT_ANS') {
+ $aggregate{$symb."\0".$part."\0correct"} = 1;
+ }
+ if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) {
+ $aggregate{$symb."\0".$part."\0users"} = 1;
+ } else {
+ my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]);
+ if ($last_reset) {
+ if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) {
+ $aggregate{$symb."\0".$part."\0users"} = 1;
+ }
+ }
+ }
+ $aggregate{$symb."\0".$part."\0attempts"} = 1;
}
- if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) {
- $aggregate{$symb."\0".$part."\0users"} = 1;
- } else {
- my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]);
- if ($last_reset) {
- if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) {
- $aggregate{$symb."\0".$part."\0users"} = 1;
+ if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') ||
+ ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred') ||
+ ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry')) {
+ if ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry') {
+ $randtrycounter{$symb."\0".$part} = 1;
+ } else {
+ $anoncounter{$symb."\0".$part} = 1;
+ }
+ my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}};
+ if ($needsrelease) {
+ my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
+ if ($curr_required eq '') {
+ &Apache::lonnet::update_released_required($needsrelease);
+ } else {
+ my ($currmajor,$currminor) = split(/\./,$curr_required);
+ my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
+ if (($currmajor < $needsmajor) || ($currmajor == $needsmajor && $currminor < $needsminor)) {
+ &Apache::lonnet::update_released_required($needsrelease);
+ }
}
}
}
- $aggregate{$symb."\0".$part."\0attempts"} = 1;
}
if (keys (%aggregate) > 0) {
&Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,
$cdomain,$cname);
}
+ if (keys(%anoncounter) > 0) {
+ &Apache::lonnet::cput('nohist_anonsurveys',\%anoncounter,
+ $cdomain,$cname);
+ }
+ if (keys(%randtrycounter) > 0) {
+ &Apache::lonnet::cput('nohist_randomizetry',\%randtrycounter,
+ $cdomain,$cname);
+ }
}
sub checkout_msg {
@@ -758,6 +932,7 @@ sub init_problem_globals {
&Apache::lonhomework::reset_show_problem_status();
$Apache::lonhomework::ignore_response_errors=1;
}
+ @Apache::functionplotresponse::callscripts=();
@Apache::inputtags::responselist = ();
@Apache::inputtags::importlist = ();
@Apache::inputtags::previous=();
@@ -785,6 +960,7 @@ sub reset_problem_globals {
undef($Apache::lonhomework::type);
undef($Apache::lonhomework::scantronmode);
undef($Apache::lonhomework::ignore_response_errors);
+ undef(@Apache::functionplotresponse::callscripts);
&Apache::lonhomework::reset_show_problem_status();
}
@@ -885,27 +1061,22 @@ sub start_problem {
if ($target eq 'tex' and $env{'request.symb'} =~ m/\.page_/) {$result='';}
- if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }
+ if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval,$target); }
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
$target eq 'tex') {
- #handle exam checkout
- if ($Apache::lonhomework::type eq 'exam') {
- my $token=
- $Apache::lonhomework::history{"resource.0.outtoken"};
- if (($env{'form.doescheckout'}) && (!$token)) {
- $token=&Apache::lonxml::maketoken();
- $Apache::lonhomework::history{"resource.0.outtoken"}=
- $token;
- }
- $result.=&Apache::lonxml::printtokenheader($target,$token);
- }
if ($env{'form.markaccess'}) {
my @interval=&Apache::lonnet::EXT("resource.0.interval");
&Apache::lonnet::set_first_access($interval[1]);
}
+
+ ($status,$accessmsg,my $slot_name,my $slot) =
+ &Apache::lonhomework::check_slot_access('0','problem');
+ push (@Apache::inputtags::status,$status);
+
#handle rand seed in construction space
- my $rndseed=&setup_rndseed($safeeval);
+ my $rndseed=&setup_rndseed($safeeval,$target);
my ($symb)=&Apache::lonnet::whichuser();
+
if ($env{'request.state'} ne "construct" &&
($symb eq '' || $Apache::lonhomework::type eq 'practice')) {
$form_tag_start.='';
}
if ($env{'request.role.adv'}) {
- $form_tag_start.=
- ' '
+ .''.&mt(' Show All Foils').
- '';
+ $form_tag_start.= ' /> '
+ .&mt('Show All Foils')
+ .'';
}
if ($Apache::lonhomework::type eq 'practice') {
$form_tag_start.=&practice_problem_header();
}
$form_tag_start.=' ';
- }
-
- ($status,$accessmsg,my $slot_name,my $slot) =
- &Apache::lonhomework::check_slot_access('0','problem');
- push (@Apache::inputtags::status,$status);
+ } elsif (($env{'request.state'} ne "construct") &&
+ ($Apache::lonhomework::type eq 'randomizetry') &&
+ ($status eq 'CAN_ANSWER')) {
+ my $reqtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.randomizeontries");
+ my $problemstatus = &get_problem_status($Apache::inputtags::part);
+ $form_tag_start.=&randomizetry_problem_header($problemstatus,$reqtries);
+ }
my $expression='$external::datestatus="'.$status.'";';
$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
@@ -1015,7 +1189,16 @@ sub start_problem {
$result .= ''."\n";
}
+ foreach my $field ('trial','questiontype') {
+ if ($env{"form.grade_$field"} ne '') {
+ $result .= ''."\n";
+ }
+ }
}
+ if ($env{'form.grade_imsexport'}) {
+ $result = '';
+ }
} elsif ($target eq 'tex') {
$result .= 'INSERTTEXFRONTMATTERHERE';
@@ -1119,7 +1302,9 @@ sub end_problem {
'\textit{'.$duedate_text.'} '.$toc_line;
} else {
$frontmatter.= $begin_doc.$toc_line;
- if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';}
+ if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) {
+ $frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
+ }
}
} else {
$frontmatter .= '\vskip 1mm\textit{'.$duedate_text.'} \\\\\\\\'.$startminipage;
@@ -1127,7 +1312,9 @@ sub end_problem {
} else {
if (not $env{'request.symb'} =~ m/\.page_/) {
$frontmatter .= $begin_doc.$toc_line;
- if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';}
+ if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) {
+ $frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
+ }
} else {
$frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage;
}
@@ -1150,7 +1337,8 @@ sub end_problem {
}
} elsif ( ($target eq 'web' || $target eq 'tex') &&
$Apache::inputtags::part eq '0' &&
- $status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED') {
+ $status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED'
+ && !$env{'form.grade_imsexport'}) {
# if part is zero, no s existed, so we need show the current
# grading status
my $gradestatus = &Apache::inputtags::gradestatus($Apache::inputtags::part,$target);
@@ -1160,10 +1348,10 @@ sub end_problem {
(($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
($target eq 'answer') || ($target eq 'tex')
) {
- if ($target ne 'tex' &&
- $env{'form.answer_output_mode'} ne 'tex') {
+ if (($target ne 'tex') &&
+ ($env{'form.answer_output_mode'} ne 'tex') &&
+ (!$env{'form.grade_imsexport'})) {
$result.="";
- $result.= &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields());
}
if ($target eq 'web') {
$result.= &Apache::loncommon::end_page({'discussion' => 1});
@@ -1184,6 +1372,9 @@ sub end_problem {
}
}
}
+ if ($target eq 'web') {
+ $result.=&Apache::functionplotresponse::init_script();
+ }
if ($target eq 'grade') {
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
&finalize_storage();
@@ -1241,7 +1432,7 @@ sub start_library {
($result,$form_tag_start)=
&page_start($target,$token,$tagstack,$parstack,$parser,$safeeval,
$name);
- my $rndseed=&setup_rndseed($safeeval);
+ my $rndseed=&setup_rndseed($safeeval,$target);
$result.=" \n $form_tag_start".
'';
$result.=&problem_web_to_edit_header($rndseed);
@@ -1480,7 +1671,7 @@ sub start_instructorcomment {
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
- $result=($env{'request.role'}=~/^(in|cc|au|ca|li)/);
+ $result=($env{'request.role'}=~/^(in|cc|co|au|ca|li)/);
if ( (! $result) or ($env{'form.instructor_comments'} eq 'hide')) {
my $skip=&Apache::lonxml::get_all_text("/instructorcomment",
$parser,$style);
@@ -1685,6 +1876,49 @@ sub ordered_show_check {
return $in_order_show;
}
+
+sub start_startpartmarker {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my $result='';
+ if ($target eq 'edit') {
+ $result=&Apache::edit::tag_start($target,$token);
+ $result.=&mt('Marker for the start of a part. Place end marker below to wrap in-between tags into a new part.').' |
';
+ $result.=&Apache::edit::end_table();
+
+ }
+ return $result;
+}
+
+sub end_startpartmarker {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my @result;
+ if ($target eq 'edit') { $result[1]='no'; }
+ return @result;
+}
+
+sub start_endpartmarker {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my $result='';
+ if ($target eq 'edit') {
+ $result=&Apache::edit::tag_start($target,$token);
+ $result.=&mt('Marker for the end of a part. Place start marker above to wrap in-between tags into a new part.').'';
+ $result.=&Apache::edit::end_table();
+
+ }
+ return $result;
+}
+
+sub end_endpartmarker {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my @result;
+ if ($target eq 'edit') { $result[1]='no'; }
+ return @result;
+}
+
+
+
+
+
sub start_part {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
if (!$Apache::lonxml::metamode) {
@@ -1769,9 +2003,31 @@ sub start_part {
'.disableexampointprint'}) eq 'yes') {
$allow_print_points=0;
}
- if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
+ if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) {
+ $result .= '\vskip 10mm\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
+
+ }
} elsif ($target eq 'web') {
- $result.='".&mt('Text Block')." | "
.''.&mt('Delete?').' '
.&Apache::edit::deletelist($target,$token)
- .' | ';
- unless ($env{'environment.wysiwygeditor'} eq 'on') {
- $result .= ''
- .&Apache::lonhtmlcommon::dragmath_button($areaid,1)
- .' | '
- .''
- .&Apache::edit::insertlist($target,$token)
- .' | ';
- }
- $result.='' .
- &Apache::loncommon::helpLatexCheatsheet().
+ .' | '
+ .''
+ .&Apache::lonhtmlcommon::dragmath_button($areaid,1)
+ .' | '
+ .''
+ .&Apache::edit::insertlist($target,$token)
+ .' | '
+ .'' .
+ &Apache::loncommon::helpLatexCheatsheet().
&Apache::edit::end_row().
&Apache::edit::start_spanning_row()."\n".
&Apache::edit::editfield($token->[1],$text,"",80,8,1);
@@ -2051,15 +2310,17 @@ sub start_simpleeditbutton {
my $url=$env{'request.noversionuri'};
$url=~s/\?.*$//;
my ($symb) = &Apache::lonnet::whichuser();
-# Warning make more sense and is more important on edit screen
+# Warning makes more sense and is more important on edit screen
# $result=' '
# .&mt('Note: it can take up to 10 minutes for changes to take effect for all users.')
# .&Apache::loncommon::help_open_topic('Caching')
# .' ';
- $result.=&Apache::lontemplate::start_functionslist()
- .&Apache::lontemplate::item_functionslist(
- ''.&mt('Edit').'')
- .&Apache::lontemplate::end_functionslist();
+ $result.=&Apache::loncommon::head_subbox(
+ &Apache::lonhtmlcommon::start_funclist()
+ .&Apache::lonhtmlcommon::add_item_funclist(
+ ''
+ .&mt('Edit').'')
+ .&Apache::lonhtmlcommon::end_funclist());
}
return $result;
@@ -2075,6 +2336,63 @@ sub practice_problem_header {
'';
}
+sub randomizetry_problem_header {
+ my ($problemstatus,$reqtries) = @_;
+ my ($header,$text);
+ if ($reqtries > 1) {
+ $header = &mt('New Problem Variation After Every [quant,_1,Try,Tries]',$reqtries);
+ if (($problemstatus eq 'no') ||
+ ($problemstatus eq 'no_feedback_ever')) {
+ $text = &mt('A new variation will be generated after every [quant,_1,try,tries], until the tries limit is reached.',$reqtries);
+ } else {
+ $text = &mt('A new variation will be generated after every [quant,_1,try,tries], until correct or tries limit is reached.',$reqtries);
+ }
+ } else {
+ $header = &mt('New Problem Variation Each Try');
+ if (($problemstatus eq 'no') ||
+ ($problemstatus eq 'no_feedback_ever')) {
+ $text = &mt('A new variation will be generated after each try until the tries limit is reached.');
+
+ } else {
+ $text = &mt('A new variation will be generated after each try until correct or tries limit is reached.');
+ }
+ }
+ return ''.$header.''.
+ ''.$text.' ';
+}
+
+sub randomizetry_part_header {
+ my ($problemstatus,$reqtries,$num) = @_;
+ my ($header,$text);
+ if ($reqtries eq 'none') {
+ $header = &mt('No Question Variation');
+ $text = &mt('For this question there will no new variation after a try.');
+ } elsif ($reqtries > 1) {
+ $header = &mt('New Question Variation After Every [quant,_1,Try,Tries]',$reqtries);
+ if (($problemstatus eq 'no') ||
+ ($problemstatus eq 'no_feedback_ever')) {
+ $text = &mt('For this question a new variation will be generated after every [quant,_1,try,tries], until the tries limit is reached.',$reqtries);
+ } else {
+ $text = &mt('For this question a new variation will be generated after every [quant,_1,try,tries], until correct or tries limit is reached.',$reqtries);
+ }
+ } else {
+ $header = &mt('New Question Variation For Each Try');
+ if (($problemstatus eq 'no') ||
+ ($problemstatus eq 'no_feedback_ever')) {
+ $text = &mt('For this question a new variation will be generated after each try until the tries limit is reached.');
+ } else {
+ $text = &mt('For this question a new variation will be generated after each try until correct or tries limit is reached.');
+ }
+ }
+ my $output;
+ if ($num > 1) {
+ $output .= ' ';
+ }
+ $output .= ''.$header.''.
+ ''.$text.'
';
+ return $output;
+}
+
1;
__END__
|