print(&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row()
+ .''
+ .&mt('Part').' '.$part
+ );
+ if (scalar(@{ $overall{$part.'.answer'} }) > 1) {
+ $request->print(' '.&mt('Answer [_1]',$i+1));
+ }
+ $request->print(' | '
+ .&Apache::loncommon::end_data_table_header_row()
+ );
+ my %frequency;
+ foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'}[$i] })) {
+ $frequency{join("\0",@{ $answer })}++;
+ }
+ $request->print(&Apache::loncommon::start_data_table_header_row()
+ .''.&mt('Answer').' | '
+ .''.&mt('Frequency').' '
+ .'('.&mt('click for example').') | '
+ .&Apache::loncommon::end_data_table_header_row()
+ );
+ foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) {
+ $request->print(&Apache::loncommon::start_data_table_row()
+ .''
+ .join(' | ',split("\0",$answer))
+ .' | '
+ .''
+ .''.$frequency{$answer}.''
+ .' | '
+ .&Apache::loncommon::end_data_table_row()
+ );
+ }
+ $request->print(&Apache::loncommon::end_data_table());
+ }
+ } else {
+ $request->print(''
+ .&mt('Response [_1] is not analyzable at this time.',$part)
+ .'
'
+ );
+ }
+ }
+ if (scalar(keys(%allparts)) == 0 ) {
+ $request->print(''
+ .&mt('Found no analyzable responses in this problem.'
+ .' Currently only Numerical, Formula and String response styles are supported.')
+ .'
'
+ );
+ }
+ &Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state);
+ &analyze_footer($request);
+ &Apache::lonhomework::showhash(%overall);
+ return $result;
+}
+
+{
+ my $show_problem_status;
+ sub reset_show_problem_status {
+ undef($show_problem_status);
+ }
+
+ sub set_show_problem_status {
+ my ($new_status) = @_;
+ $show_problem_status = lc($new_status);
+ }
+
+ sub hide_problem_status {
+ return ($show_problem_status eq 'no'
+ || $show_problem_status eq 'no_feedback_ever');
+ }
+
+ sub show_problem_status {
+ return ($show_problem_status eq 'yes'
+ || $show_problem_status eq 'answer'
+ || $show_problem_status eq '');
+ }
+
+ sub show_some_problem_status {
+ return ($show_problem_status eq 'no');
+ }
+
+ sub show_no_problem_status {
+ return ($show_problem_status eq 'no_feedback_ever');
+ }
+
+ sub show_answer_problem_status {
+ return ($show_problem_status eq 'answer');
+ }
+}
+
+sub editxmlmode {
+ my ($request,$file) = @_;
+ my $result;
+ my $problem=&Apache::lonnet::getfile($file);
+ if ($problem eq -1) {
+ &Apache::lonxml::error(
+ ''
+ .&mt('Unable to find [_1]',
+ ''.$file.'')
+ .'
');
+
+ $problem='';
+ }
+ if (($env{'form.problemmode'} eq 'saveeditxml') ||
+ ($env{'form.problemmode'} eq 'saveviewxml') ||
+ ($env{'form.problemmode'} eq 'undoxml')) {
+ my $error=&handle_save_or_undo($request,\$problem,
+ \$env{'form.editxmltext'});
+ if (!$error) { $problem=&Apache::lonnet::getfile($file); }
+ }
+ &Apache::lonhomework::showhashsubset(\%env,'^form');
+ if ($env{'form.problemmode'} eq 'saveviewxml') {
+ &Apache::lonhomework::showhashsubset(\%env,'^form');
+ $env{'form.problemmode'}='view';
+ &renderpage($request,$file);
+ } else {
+ my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
+ if ($cols > 80) { $cols = 80; }
+ if ($cols < 70) { $cols = 70; }
+ if ($rows < 20) { $rows = 20; }
+ my $js =
+ &Apache::edit::js_change_detection().
+ &Apache::loncommon::resize_textarea_js().
+ &Apache::structuretags::setmode_javascript().
+ &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
+
+ # Breadcrumbs
+ my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
+ 'text' => 'Authoring Space'},
+ {'href' => '',
+ 'text' => 'Problem Editing'}];
+
+ my $start_page =
+ &Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js,
+ {'no_auto_mt_title' => 1,
+ 'only_body' => 0,
+ 'add_entries' => {
+ 'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')],
+ 'onload' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')],
+ },
+ 'bread_crumbs' => $brcrum,
+ });
+
+ $result=$start_page
+ .&Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader());
+ $result.=&renderpage($request,$file,['no_output_web'],1).
+ '';
+
+ my $resource = $env{'request.ambiguous'};
+ unless($env{'environment.nocodemirror'}){
+ $result .= '
+
+ ",
+ mode: CodeMirror.getMode(config, "perl"),
+ delimStyle: "tag",
+ }
+ );
+ });
+ var cm = CodeMirror.fromTextArea(document.getElementById("LC_editxmltext"),
+ {
+ mode: "mixedmode",
+ lineWrapping: true,
+ lineNumbers: true,
+ tabSize: 4,
+ indentUnit: 4,
+
+ autoCloseTags: true,
+ autoCloseBrackets: true,
+ height: "auto",
+ styleActiveLine: true,
+
+ extraKeys: {
+ "Tab": "indentMore",
+ "Shift-Tab": "indentLess",
+ }
+ });
+ restoreScrollPosition("'.$resource.'");
+ ';
+ }
+
+ $result .= &Apache::loncommon::end_page();
+ &Apache::lonxml::add_messages(\$result);
+ $request->print($result);
+ }
+ return '';
+}
+
+#
+# Render the page in whatever target desired.
+#
+sub renderpage {
+ my ($request,$file,$targets,$return_string,$donebuttonmsg,$viewasuser,$symb) = @_;
+
+ my @targets = @{$targets || [&get_target()]};
+ &Apache::lonhomework::showhashsubset(\%env,'form.');
+ &Apache::lonxml::debug("Running targets ".join(':',@targets));
+
+ my $overall_result;
+ foreach my $target (@targets) {
+ # FIXME need to do something intelligent when a problem goes
+ # from viewable to not viewable due to map conditions
+ #&setuppermissions();
+ #if ( $Apache::lonhomework::browse ne '2'
+ # && $Apache::lonhomework::browse ne 'F' ) {
+ # $request->print(" You most likely shouldn't see me.");
+ #}
+ #my $t0 = [&gettimeofday()];
+ my $output=1;
+ if ($target eq 'no_output_web') {
+ $target = 'web'; $output=0;
+ }
+ my $problem=&Apache::lonnet::getfile($file);
+ my $result;
+ if ($problem eq -1) {
+ $problem='';
+ my $filename=(split('/',$file))[-1];
+ my $error =
+ ''
+ .&mt('Unable to find [_1]',
+ ''.$filename.'')
+ ."
";
+ $result.=
+ &Apache::loncommon::simple_error_page($request,'Not available',
+ $error,{'no_auto_mt_msg' => 1});
+ return;
+ }
+
+ my %mystyle;
+ if ($target eq 'analyze') { %Apache::lonhomework::analyze=(); }
+ if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); }
+ if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');}
+
+ if (($target eq 'web') && ($viewasuser ne '') && ($symb ne '')) {
+ $env{'request.user_in_effect'} = $viewasuser;
+ }
+
+ &Apache::lonxml::debug("Should be parsing now");
+ $result .= &Apache::lonxml::xmlparse($request, $target, $problem,
+ &setup_vars($target),%mystyle);
+ &finished_parsing();
+ if (!$output) { $result = ''; }
+ #$request->print("Result follows:");
+ if ($target eq 'modified') {
+ &handle_save_or_undo($request,\$problem,\$result);
+ } else {
+ if ($target eq 'analyze') {
+ $result=&Apache::lonnet::hashref2str(\%Apache::lonhomework::analyze);
+ undef(%Apache::lonhomework::analyze);
+ } elsif ($target eq 'web') {
+ if ($donebuttonmsg) {
+ $result =~ s{}{};
+ $result.= &Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($donebuttonmsg,1))."\n