Annotation of loncom/homework/inputtags.pm, revision 1.263
1.43 albertel 1: # The LearningOnline Network with CAPA
2: # input definitons
1.47 albertel 3: #
1.263 ! raeburn 4: # $Id: inputtags.pm,v 1.262 2010/06/05 01:38:43 www Exp $
1.47 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
1.1 albertel 27:
1.249 jms 28: =pod
29:
30: =head1 NAME
31:
32: Apache::inputtags
33:
34: =head1 SYNOPSIS
35:
36:
37:
38: This is part of the LearningOnline Network with CAPA project
39: described at http://www.lon-capa.org.
40:
41:
42: =head1 NOTABLE SUBROUTINES
43:
44: =over
45:
46: =item
47:
48: =back
49:
50: =cut
51:
1.1 albertel 52: package Apache::inputtags;
1.55 albertel 53: use HTML::Entities();
1.1 albertel 54: use strict;
1.82 www 55: use Apache::loncommon;
1.115 www 56: use Apache::lonlocal;
1.165 albertel 57: use Apache::lonnet;
1.192 www 58: use LONCAPA;
59:
1.1 albertel 60:
1.50 harris41 61: BEGIN {
1.135 albertel 62: &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
1.1 albertel 63: }
64:
1.249 jms 65: =pod
66:
67: =item initialize_inputtags()
68:
69: Initializes a set of global variables used during the parse of the problem.
70:
71: @Apache::inputtags::input - List of current input ids.
72: @Apache::inputtags::inputlist - List of all input ids seen this problem.
73: @Apache::inputtags::response - List of all current resopnse ids.
74: @Apache::inputtags::responselist - List of all response ids seen this
75: problem.
76: @Apache::inputtags::hint - List of all hint ids.
77: @Apache::inputtags::hintlist - List of all hint ids seen this problem.
78: @Apache::inputtags::previous - List describing if specific responseds
79: have been used
80: @Apache::inputtags::previous_version - Submission responses were used in.
81: $Apache::inputtags::part - Current part id (valid only in
82: <problem>)
83: 0 if not in a part.
84: @Apache::inputtags::partlist - List of part ids seen in the current
85: <problem>
86: @Apache::inputtags::status - List of problem statuses. First
87: element is the status of the <problem>
88: the remainder are for individual <part>s.
89: %Apache::inputtags::params - Hash of defined parameters for the
90: current response.
91: @Apache::inputtags::import - List of all ids for <import> thes get
92: join()ed and prepended.
93: @Apache::inputtags::importlist - List of all import ids seen.
94: $Apache::inputtags::response_with_no_part
95: - Flag set true if we have seen a response
96: that is not inside a <part>
97: %Apache::inputtags::answertxt - <*response> tags store correct
98: answer strings for display by <textline/>
99: in this hash.
100: %Apache::inputtags::submission_display
101: - <*response> tags store improved display
102: of submission strings for display by part
103: end.
104:
105: =cut
1.178 albertel 106:
1.1 albertel 107: sub initialize_inputtags {
1.135 albertel 108: @Apache::inputtags::input=();
109: @Apache::inputtags::inputlist=();
1.174 albertel 110: @Apache::inputtags::response=();
1.135 albertel 111: @Apache::inputtags::responselist=();
1.174 albertel 112: @Apache::inputtags::hint=();
1.173 albertel 113: @Apache::inputtags::hintlist=();
1.135 albertel 114: @Apache::inputtags::previous=();
115: @Apache::inputtags::previous_version=();
116: $Apache::inputtags::part='';
117: @Apache::inputtags::partlist=();
118: @Apache::inputtags::status=();
119: %Apache::inputtags::params=();
120: @Apache::inputtags::import=();
121: @Apache::inputtags::importlist=();
122: $Apache::inputtags::response_with_no_part=0;
1.144 albertel 123: %Apache::inputtags::answertxt=();
1.217 albertel 124: %Apache::inputtags::submission_display=();
1.103 albertel 125: }
126:
127: sub check_for_duplicate_ids {
128: my %check;
129: foreach my $id (@Apache::inputtags::partlist,
130: @Apache::inputtags::responselist,
1.173 albertel 131: @Apache::inputtags::hintlist,
1.103 albertel 132: @Apache::inputtags::importlist) {
133: $check{$id}++;
134: }
135: my @duplicates;
136: foreach my $id (sort(keys(%check))) {
137: if ($check{$id} > 1) {
138: push(@duplicates,$id);
139: }
140: }
141: if (@duplicates) {
142: &Apache::lonxml::error("Duplicated ids found, problem will operate incorrectly. Duplicated ids seen: ",join(', ',@duplicates));
143: }
1.1 albertel 144: }
145:
1.14 albertel 146: sub start_input {
1.135 albertel 147: my ($parstack,$safeeval)=@_;
1.228 albertel 148: my $id = &Apache::lonxml::get_id($parstack,$safeeval);
1.135 albertel 149: push (@Apache::inputtags::input,$id);
150: push (@Apache::inputtags::inputlist,$id);
151: return $id;
1.14 albertel 152: }
153:
154: sub end_input {
1.135 albertel 155: pop @Apache::inputtags::input;
156: return '';
1.14 albertel 157: }
158:
1.124 www 159: sub addchars {
160: my ($fieldid,$addchars)=@_;
161: my $output='';
162: foreach (split(/\,/,$addchars)) {
163: $output.='<a href="javascript:void(document.forms.lonhomework.'.
164: $fieldid.'.value+=\''.$_.'\')">'.$_.'</a> ';
165: }
166: return $output;
167: }
168:
1.48 albertel 169: sub start_textfield {
1.185 albertel 170: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.135 albertel 171: my $result = "";
172: my $id = &start_input($parstack,$safeeval);
173: my $resid=$Apache::inputtags::response[-1];
174: if ($target eq 'web') {
175: $Apache::lonxml::evaluate--;
1.205 albertel 176: my $partid=$Apache::inputtags::part;
177: my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"');
1.135 albertel 178: if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
179: my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
180: if ( $cols eq '') { $cols = 80; }
181: my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
1.143 www 182: if ( $rows eq '') { $rows = 16; }
1.135 albertel 183: my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
184: $result='';
185: if ($addchars) {
186: $result.=&addchars('HWVAL_'.$resid,$addchars);
187: }
1.191 albertel 188: &Apache::lonhtmlcommon::add_htmlareafields('HWVAL_'.$resid);
1.143 www 189: $result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" id="HWVAL_'.$resid.'" '.
1.135 albertel 190: "rows=\"$rows\" cols=\"$cols\">".$oldresponse;
191: if ($oldresponse ne '') {
1.143 www 192:
1.135 albertel 193: #get rid of any startup text if the user has already responded
1.185 albertel 194: &Apache::lonxml::get_all_text("/textfield",$parser,$style);
1.135 albertel 195: }
196: } else {
1.205 albertel 197: #show past answer in the essayresponse case
198: if ($oldresponse =~ /\S/
199: && &Apache::londefdef::is_inside_of($tagstack,
200: 'essayresponse') ) {
201: $result='<table class="LC_pastsubmission"><tr><td>'.
202: $oldresponse.'</td></tr></table>';
203: }
1.135 albertel 204: #get rid of any startup text
1.185 albertel 205: &Apache::lonxml::get_all_text("/textfield",$parser,$style);
1.61 albertel 206: }
1.135 albertel 207: } elsif ($target eq 'grade') {
1.185 albertel 208: my $seedtext=&Apache::lonxml::get_all_text("/textfield",$parser,
209: $style);
1.165 albertel 210: if ($seedtext eq $env{'form.HWVAL_'.$resid}) {
1.135 albertel 211: # if the seed text is still there it wasn't a real submission
1.165 albertel 212: $env{'form.HWVAL_'.$resid}='';
1.135 albertel 213: }
214: } elsif ($target eq 'edit') {
215: $result.=&Apache::edit::tag_start($target,$token);
216: $result.=&Apache::edit::text_arg('Rows:','rows',$token,4);
217: $result.=&Apache::edit::text_arg('Columns:','cols',$token,4);
218: $result.=&Apache::edit::text_arg
219: ('Click-On Texts (comma sep):','addchars',$token,10);
1.185 albertel 220: my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser,
221: $style);
1.135 albertel 222: $result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);
223: } elsif ($target eq 'modified') {
224: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
225: $safeeval,'rows','cols',
226: 'addchars');
227: if ($constructtag) {
228: $result = &Apache::edit::rebuild_tag($token);
229: } else {
230: $result=$token->[4];
231: }
232: $result.=&Apache::edit::modifiedfield("/textfield",$parser);
233: } elsif ($target eq 'tex') {
234: my $number_of_lines = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
235: my $width_of_box = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
236: if ($$tagstack[-2] eq 'essayresponse' and $Apache::lonhomework::type eq 'exam') {
237: $result = '\fbox{\fbox{\parbox{\textwidth-5mm}{';
238: for (my $i=0;$i<int $number_of_lines*2;$i++) {$result.='\strut \\\\ ';}
239: $result.='\strut \\\\\strut \\\\\strut \\\\\strut \\\\}}}';
240: } else {
241: my $TeXwidth=$width_of_box/80;
242: $result = '\vskip 1 mm \fbox{\fbox{\parbox{'.$TeXwidth.'\textwidth-5mm}{';
243: for (my $i=0;$i<int $number_of_lines*2;$i++) {$result.='\strut \\\\ ';}
244: $result.='}}}\vskip 2 mm ';
245: }
1.60 albertel 246: }
1.135 albertel 247: return $result;
1.6 albertel 248: }
249:
1.48 albertel 250: sub end_textfield {
1.135 albertel 251: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
252: my $result;
253: if ($target eq 'web') {
254: $Apache::lonxml::evaluate++;
255: if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
256: return "</textarea>";
257: }
258: } elsif ($target eq 'edit') {
259: $result=&Apache::edit::end_table();
260: }
261: &end_input;
262: return $result;
1.6 albertel 263: }
264:
1.190 albertel 265: sub exam_score_line {
1.188 albertel 266: my ($target) = @_;
1.190 albertel 267:
1.188 albertel 268: my $result;
269: if ($target eq 'tex') {
270: my $repetition = &Apache::response::repetition();
271: $result.='\begin{enumerate}';
1.190 albertel 272: if ($env{'request.state'} eq "construct" ) {$result.='\item[\strut]';}
1.188 albertel 273: foreach my $i (0..$repetition-1) {
274: $result.='\item[\textbf{'.
275: ($Apache::lonxml::counter+$i).
276: '}.]\textit{Leave blank on scoring form}\vskip 0 mm';
277: }
278: $result.= '\end{enumerate}';
1.190 albertel 279: }
280:
281: return $result;
282: }
283:
284: sub exam_box {
285: my ($target) = @_;
286: my $result;
1.188 albertel 287:
1.190 albertel 288: if ($target eq 'tex') {
289: $result .= '\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
290: $result .= &exam_score_line($target);
1.188 albertel 291: } elsif ($target eq 'web') {
292: my $id=$Apache::inputtags::response[-1];
293: $result.= '<br /><br />
294: <textarea name="HWVAL_'.$id.'" rows="4" cols="50">
295: </textarea> <br /><br />';
296: }
297: return $result;
298: }
299:
300: sub needs_exam_box {
301: my ($tagstack) = @_;
302: my @tags = ('formularesponse',
303: 'stringresponse',
304: 'reactionresponse',
305: 'organicresponse',
306: );
307:
308: foreach my $tag (@tags) {
309: if (grep(/\Q$tag\E/,@$tagstack)) {
310: return 1;
311: }
312: }
313: return 0;
314: }
315:
1.1 albertel 316: sub start_textline {
1.135 albertel 317: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
318: my $result = "";
1.210 albertel 319: my $input_id = &start_input($parstack,$safeeval);
1.135 albertel 320: if ($target eq 'web') {
321: $Apache::lonxml::evaluate--;
322: my $partid=$Apache::inputtags::part;
323: my $id=$Apache::inputtags::response[-1];
1.204 albertel 324: if (!&Apache::response::show_answer()) {
1.135 albertel 325: my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
326: my $maxlength;
327: if ($size eq '') { $size=20; } else {
1.214 albertel 328: if ($size < 20) {
329: $maxlength = ' maxlength="'.$size.'"';
330: }
1.135 albertel 331: }
1.210 albertel 332: my $oldresponse = $Apache::lonhomework::history{"resource.$partid.$id.submission"};
333: &Apache::lonxml::debug("oldresponse $oldresponse is ".ref($oldresponse));
334:
335: if (ref($oldresponse) eq 'ARRAY') {
336: $oldresponse = $oldresponse->[$#Apache::inputtags::inputlist];
337: }
338: $oldresponse = &HTML::Entities::encode($oldresponse,'<>&"');
1.241 www 339: $oldresponse =~ s/^\s+//;
340: $oldresponse =~ s/\s+$//;
341: $oldresponse =~ s/\s+/ /g;
1.135 albertel 342: if ($Apache::lonhomework::type ne 'exam') {
343: my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
344: $result='';
345: if ($addchars) {
346: $result.=&addchars('HWVAL_'.$id,$addchars);
347: }
1.157 albertel 348: my $readonly=&Apache::lonxml::get_param('readonly',$parstack,
349: $safeeval);
1.193 albertel 350: if (lc($readonly) eq 'yes'
351: || $Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
1.157 albertel 352: $readonly=' readonly="readonly" ';
1.158 albertel 353: } else {
354: $readonly='';
1.157 albertel 355: }
1.193 albertel 356: my $name = 'HWVAL_'.$id;
357: if ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
358: $name = "none";
359: }
1.214 albertel 360: $result.= '<input onkeydown="javascript:setSubmittedPart(\''.$partid.'\');" type="text" '.$readonly.' name="'.$name.'" value="'.
361: $oldresponse.'" size="'.$size.'"'.$maxlength.' />';
1.135 albertel 362: }
1.188 albertel 363: if ($Apache::lonhomework::type eq 'exam'
364: && &needs_exam_box($tagstack)) {
365: $result.=&exam_box($target);
366: }
1.135 albertel 367: } else {
368: #right or wrong don't show what was last typed in.
1.208 albertel 369: my $count = scalar(@Apache::inputtags::inputlist)-1;
370: $result='<b>'.$Apache::inputtags::answertxt{$id}[$count].'</b>';
1.144 albertel 371: #$result='';
1.135 albertel 372: }
373: } elsif ($target eq 'edit') {
374: $result=&Apache::edit::tag_start($target,$token);
375: $result.=&Apache::edit::text_arg('Size:','size',$token,'5').
1.157 albertel 376: &Apache::edit::text_arg('Click-On Texts (comma sep):',
377: 'addchars',$token,10);
378: $result.=&Apache::edit::select_arg('Readonly:','readonly',
379: ['no','yes'],$token);
380: $result.=&Apache::edit::end_row();
381: $result.=&Apache::edit::end_table();
1.135 albertel 382: } elsif ($target eq 'modified') {
1.157 albertel 383: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
384: $safeeval,'size',
385: 'addchars','readonly');
1.135 albertel 386: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
1.188 albertel 387: } elsif ($target eq 'tex'
388: && $Apache::lonhomework::type ne 'exam') {
1.135 albertel 389: my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
390: if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}
1.257 onken 391: if ($env{'form.pdfFormFields'} eq 'yes'
392: && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
1.246 onken 393: my $fieldname = $env{'request.symb'}.
394: '&part_'. $Apache::inputtags::part.
395: '&textresponse'.
396: '&HWVAL_' . $Apache::inputtags::response['-1'];
1.259 onken 397: $result='\textField{'.$fieldname.'}{'.$size.'}{12 bp}';
1.246 onken 398: } else {
399: $result='\framebox['.$size.'][s]{\tiny\strut}';
400: }
1.188 albertel 401: } elsif ($target eq 'tex'
402: && $Apache::lonhomework::type eq 'exam'
403: && &needs_exam_box($tagstack)) {
404: $result.=&exam_box($target);
1.135 albertel 405: }
406: return $result;
1.1 albertel 407: }
408:
409: sub end_textline {
1.135 albertel 410: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
411: if ($target eq 'web') { $Apache::lonxml::evaluate++; }
412: elsif ($target eq 'edit') { return ('','no'); }
1.208 albertel 413: &end_input();
1.135 albertel 414: return "";
1.9 albertel 415: }
416:
1.98 albertel 417: sub start_hiddenline {
418: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
419: my $result = "";
1.211 albertel 420: my $input_id = &start_input($parstack,$safeeval);
1.98 albertel 421: if ($target eq 'web') {
422: $Apache::lonxml::evaluate--;
423: if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
424: my $partid=$Apache::inputtags::part;
425: my $id=$Apache::inputtags::response[-1];
1.211 albertel 426: my $oldresponse = $Apache::lonhomework::history{"resource.$partid.$id.submission"};
427: if (ref($oldresponse) eq 'ARRAY') {
428: $oldresponse = $oldresponse->[$#Apache::inputtags::inputlist];
429: }
430: $oldresponse = &HTML::Entities::encode($oldresponse,'<>&"');
431:
1.98 albertel 432: if ($Apache::lonhomework::type ne 'exam') {
433: $result= '<input type="hidden" name="HWVAL_'.$id.'" value="'.
434: $oldresponse.'" />';
435: }
436: }
437: } elsif ($target eq 'edit') {
438: $result=&Apache::edit::tag_start($target,$token);
439: $result.=&Apache::edit::end_table;
440: }
1.189 albertel 441:
442: if ( ($target eq 'web' || $target eq 'tex')
443: && $Apache::lonhomework::type eq 'exam'
444: && &needs_exam_box($tagstack)) {
445: $result.=&exam_box($target);
446: }
1.98 albertel 447: return $result;
448: }
449:
450: sub end_hiddenline {
1.135 albertel 451: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
452: if ($target eq 'web') { $Apache::lonxml::evaluate++; }
453: elsif ($target eq 'edit') { return ('','no'); }
1.211 albertel 454: &end_input();
1.135 albertel 455: return "";
1.98 albertel 456: }
457:
1.249 jms 458: =pod
459:
460: =item file_selector()
461:
462: $part -> partid
463: $id -> responseid
464: $uploadefiletypes -> comma seperated list of extensions allowed or * for any
1.252 raeburn 465: $which -> 'uploadonly' -> only newly uploaded files
1.249 jms 466: 'portfolioonly' -> only allow files from portfolio
467: 'both' -> allow files from either location
468: $extratext -> additional text to go between the link and the input box
1.252 raeburn 469: $maxfilesize -> maximum cumulative filesize for submitted files (in MB).
1.249 jms 470: returns a table row <tr>
471:
472: =cut
473:
1.160 albertel 474: sub file_selector {
1.252 raeburn 475: my ($part,$id,$uploadedfiletypes,$which,$extratext,$maxfilesize)=@_;
1.160 albertel 476: if (!$uploadedfiletypes) { return ''; }
1.167 albertel 477:
478: my $jspart=$part;
479: $jspart=~s/\./_/g;
480:
1.160 albertel 481: my $result;
482:
1.162 albertel 483: $result.='<tr><td>';
1.252 raeburn 484: if (($uploadedfiletypes ne '*') || ($maxfilesize)) {
485: if ($uploadedfiletypes ne '*') {
486: $result.=
487: &mt('Allowed filetypes: [_1]','<b>'.$uploadedfiletypes.'</b>').'<br />';
488: }
489: if ($maxfilesize) {
490: $result.=&mt('Combined size of files not to exceed: [_1] MB[_2].',
491: '<b>'.$maxfilesize.'</b>').'<br />';
492: }
493: $result .= '<br />';
1.162 albertel 494: }
1.160 albertel 495: if ($which eq 'uploadonly' || $which eq 'both') {
496: $result.=&mt('Submit a file: (only one file can be uploaded)').
497: ' <br /><input type="file" size="50" name="HWFILE'.
1.167 albertel 498: $jspart.'_'.$id.'" /><br />';
1.205 albertel 499: $result .= &show_past_file_submission($part,$id);
1.160 albertel 500: }
501: if ( $which eq 'both') {
502: $result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';
503: }
504: if ($which eq 'portfolioonly' || $which eq 'both') {
1.227 albertel 505: $result.=$extratext.'<a href='."'".'javascript:void(window.open("/adm/portfolio?mode=selectfile&fieldname='.$env{'form.request.prefix'}.'HWPORT'.$jspart.'_'.$id.'","cat","height=600,width=800,scrollbars=1,resizable=1,menubar=2,location=1"))'."'".'>'.
1.160 albertel 506: &mt('Select Portfolio Files').'</a><br />'.
1.167 albertel 507: '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
1.160 albertel 508: '<br />';
1.205 albertel 509: $result .= &show_past_portfile_submission($part,$id);
1.160 albertel 510: }
511: $result.='</td></tr>';
512: return $result;
513: }
514:
1.205 albertel 515: sub show_past_file_submission {
516: my ($part,$id) = @_;
517: my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"');
518:
519: return if (!$uploadedfile);
520:
521: my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};
522: &Apache::lonxml::extlink($url);
523: &Apache::lonnet::allowuploaded('/adm/essayresponse',$url);
524: my $icon=&Apache::loncommon::icon($url);
525: my $curfile='<a href="'.$url.'"><img src="'.$icon.
526: '" border="0" />'.$uploadedfile.'</a>';
1.250 bisitz 527: return &mt('Currently submitted: [_1]','<tt>'.$curfile.'</tt>');
1.205 albertel 528:
529: }
530:
531: sub show_past_portfile_submission {
532: my ($part,$id) = @_;
533: if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}!~/[^\s]/){
534: return;
535: }
536: my (@file_list,@bad_file_list);
537: foreach my $file (split(/\s*,\s*/,&unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {
1.209 albertel 538: my (undef,undef,$domain,$user)=&Apache::lonnet::whichuser();
1.205 albertel 539: my $url="/uploaded/$domain/$user/portfolio$file";
540: my $icon=&Apache::loncommon::icon($url);
541: push(@file_list,'<a href="'.$url.'"><img src="'.$icon.
542: '" border="0" />'.$file.'</a>');
543: if (! &Apache::lonnet::stat_file($url)) {
544: &Apache::lonnet::logthis("bad file is $url");
545: push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon.
546: '" border="0" />'.$file.'</a>');
547: }
548: }
549: my $files = '<span class="LC_filename">'.
550: join('</span>, <span class="LC_filename">',@file_list).
551: '</span>';
552: my $result = &mt("Portfolio files previously selected: [_1]",$files);
553: if (@bad_file_list) {
554: my $bad_files = '<span class="LC_filename">'.
555: join('</span>, <span class="LC_filename">',@bad_file_list).
556: '</span>';
1.250 bisitz 557: $result.='<p><span class="LC_error">'
558: .&mt("These file(s) don't exist: [_1]",$bad_files)
559: .'</span></p>';
1.205 albertel 560: }
561: return $result;
562:
563: }
564:
1.179 albertel 565: sub valid_award {
566: my ($award) =@_;
1.182 albertel 567: foreach my $possibleaward ('EXTRA_ANSWER','MISSING_ANSWER', 'ERROR',
568: 'NO_RESPONSE',
1.179 albertel 569: 'TOO_LONG', 'UNIT_INVALID_INSTRUCTOR',
570: 'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE',
571: 'UNIT_FAIL', 'NO_UNIT',
572: 'UNIT_NOTNEEDED', 'WANTED_NUMERIC',
1.251 www 573: 'BAD_FORMULA', 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT',
1.179 albertel 574: 'MISORDERED_RANK', 'INVALID_FILETYPE',
1.248 raeburn 575: 'EXCESS_FILESIZE', 'DRAFT',
1.261 raeburn 576: 'SUBMITTED', 'SUBMITTED_CREDIT',
577: 'ANONYMOUS', 'ANONYMOUS_CREDIT',
578: 'ASSIGNED_SCORE', 'APPROX_ANS',
579: 'EXACT_ANS','COMMA_FAIL') {
1.179 albertel 580: if ($award eq $possibleaward) { return 1; }
581: }
582: return 0;
583: }
584:
1.207 albertel 585: {
586: my @awards = ('EXTRA_ANSWER', 'MISSING_ANSWER', 'ERROR', 'NO_RESPONSE',
587: 'TOO_LONG',
588: 'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT',
589: 'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT',
1.251 www 590: 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'INTERNAL_ERROR',
1.207 albertel 591: 'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK',
1.248 raeburn 592: 'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'DRAFT', 'SUBMITTED',
1.261 raeburn 593: 'SUBMITTED_CREDIT', 'ANONYMOUS', 'ANONYMOUS_CREDIT',
1.248 raeburn 594: 'ASSIGNED_SCORE', 'APPROX_ANS', 'EXACT_ANS');
1.207 albertel 595: my $i=0;
596: my %fwd_awards = map { ($_,$i++) } @awards;
597: my $max=scalar(@awards);
598: @awards=reverse(@awards);
1.208 albertel 599: $i=0;
1.207 albertel 600: my %rev_awards = map { ($_,$i++) } @awards;
601:
1.232 albertel 602: sub awarddetail_to_awarded {
603: my ($awarddetail) = @_;
604: if ($awarddetail eq 'EXACT_ANS'
605: || $awarddetail eq 'APPROX_ANS') {
606: return 1;
607: }
608: return 0;
609: }
610:
1.233 albertel 611: sub hide_award {
612: my ($award) = @_;
613: if (&Apache::lonhomework::show_no_problem_status()) {
614: return 1;
615: }
616: if ($award =~
1.261 raeburn 617: /^(?:EXACT_ANS|APPROX_ANS|SUBMITTED|SUBMITTED_CREDIT|ANONYMOUS|ANONYMOUS_CREDIT|ASSIGNED_SCORE|INCORRECT)/) {
1.233 albertel 618: return 1;
619: }
620: return 0;
621: }
622:
1.9 albertel 623: sub finalizeawards {
1.232 albertel 624: my ($awardref,$msgref,$nameref,$reverse,$final_scantron)=@_;
1.207 albertel 625: my $result;
1.136 albertel 626: if ($#$awardref == -1) { $result = "NO_RESPONSE"; }
1.135 albertel 627: if ($result eq '' ) {
628: my $blankcount;
1.207 albertel 629: foreach my $award (@$awardref) {
1.135 albertel 630: if ($award eq '') {
631: $result='MISSING_ANSWER';
632: $blankcount++;
633: }
634: }
1.232 albertel 635: if ($blankcount == ($#$awardref + 1)) {
636: return ('NO_RESPONSE');
637: }
1.135 albertel 638: }
1.251 www 639:
640: if ($Apache::lonxml::internal_error) { $result='INTERNAL_ERROR'; }
641:
1.232 albertel 642: if (!$final_scantron && defined($result)) { return ($result); }
1.181 albertel 643:
1.232 albertel 644: # if in scantron mode, if the award for any response is
645: # assigned score, then the part gets an assigned score
646: if ($final_scantron
647: && grep {$_ eq 'ASSIGNED_SCORE'} (@$awardref)) {
648: return ('ASSIGNED_SCORE');
649: }
650:
651: # if in scantron mode, if the award for any response is
652: # correct and there are non-correct responses,
653: # then the part gets an assigned score
654: if ($final_scantron
655: && (grep { $_ eq 'EXACT_ANS' ||
656: $_ eq 'APPROX_ANS' } (@$awardref))
657: && (grep { $_ ne 'EXACT_ANS' &&
658: $_ ne 'APPROX_ANS' } (@$awardref))) {
659: return ('ASSIGNED_SCORE');
660: }
1.181 albertel 661: # these awards are ordered from most important error through best correct
1.207 albertel 662: my $awards = (!$reverse) ? \%fwd_awards : \%rev_awards ;
663:
664: my $best = $max;
665: my $j=0;
666: my $which;
667: foreach my $award (@$awardref) {
668: if ($awards->{$award} < $best) {
669: $best = $awards->{$award};
670: $which = $j;
671: }
672: $j++;
673: }
1.232 albertel 674:
1.207 albertel 675: if (defined($which)) {
676: if (ref($nameref)) {
677: return ($$awardref[$which],$$msgref[$which],$$nameref[$which]);
678: } else {
679: return ($$awardref[$which],$$msgref[$which]);
680: }
1.135 albertel 681: }
1.136 albertel 682: return ('ERROR',undef);
1.9 albertel 683: }
1.207 albertel 684: }
1.9 albertel 685:
1.10 albertel 686: sub decideoutput {
1.169 albertel 687: my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;
1.251 www 688:
1.135 albertel 689: my $message='';
690: my $button=0;
691: my $previousmsg;
1.221 albertel 692: my $css_class='orange';
1.148 albertel 693: my $added_computer_text=0;
1.221 albertel 694: my %possible_class =
695: ( 'correct' => 'LC_answer_correct',
696: 'charged_try' => 'LC_answer_charged_try',
697: 'not_charged_try' => 'LC_answer_not_charged_try',
698: 'no_grade' => 'LC_answer_no_grade',
699: 'no_message' => 'LC_no_message',
1.135 albertel 700: );
1.169 albertel 701:
1.180 albertel 702: my $part = $Apache::inputtags::part;
1.236 raeburn 703: my $tohandgrade = &Apache::lonnet::EXT("resource.$part.handgrade");
704: my $handgrade = ('yes' eq lc($tohandgrade));
1.180 albertel 705:
706: my $computer = ($handgrade)? ''
1.203 www 707: : " ".&mt("Computer's answer now shown above.");
1.180 albertel 708: &Apache::lonxml::debug("handgrade has :$handgrade:");
709:
1.135 albertel 710: if ($previous) { $previousmsg=&mt('You have entered that answer before'); }
711:
1.194 banghart 712: if ($solved =~ /^correct/) {
1.221 albertel 713: $css_class=$possible_class{'correct'};
1.170 albertel 714: $message=&mt('You are correct.');
715: if ($awarded < 1 && $awarded > 0) {
716: $message=&mt('You are partially correct.');
1.221 albertel 717: $css_class=$possible_class{'not_charged_try'};
1.170 albertel 718: } elsif ($awarded < 1) {
719: $message=&mt('Incorrect.');
1.221 albertel 720: $css_class=$possible_class{'charged_try'};
1.170 albertel 721: }
1.172 albertel 722: if ($env{'request.filename'} =~
723: m|/res/lib/templates/examupload.problem$|) {
724: $message = &mt("A score has been assigned.");
725: $added_computer_text=1;
1.135 albertel 726: } else {
1.172 albertel 727: if ($target eq 'tex') {
728: $message = '\textbf{'.$message.'}';
729: } else {
730: $message = "<b>".$message."</b>";
1.180 albertel 731: $message.= $computer;
1.135 albertel 732: }
1.172 albertel 733: $added_computer_text=1;
1.235 albertel 734: if ($awarded > 0) {
735: my ($symb) = &Apache::lonnet::whichuser();
736: if (($symb ne '')
737: &&
738: ($env{'course.'.$env{'request.course.id'}.
1.237 www 739: '.disable_receipt_display'} ne 'yes') &&
740: ($Apache::lonhomework::type ne 'practice')) {
1.235 albertel 741: $message.=(($target eq 'web')?'<br />':' ').
1.256 biermanm 742: &mt('Your receipt no. is [_1]',
1.235 albertel 743: (&Apache::lonnet::receipt($Apache::inputtags::part).
744: (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):'')));
745: }
1.135 albertel 746: }
747: }
748: $button=0;
749: $previousmsg='';
750: } elsif ($solved =~ /^excused/) {
751: if ($target eq 'tex') {
752: $message = ' \textbf{'.&mt('You are excused from the problem.').'} ';
753: } else {
754: $message = "<b>".&mt('You are excused from the problem.')."</b>";
755: }
1.221 albertel 756: $css_class=$possible_class{'charged_try'};
1.135 albertel 757: $button=0;
758: $previousmsg='';
759: } elsif ($award eq 'EXACT_ANS' || $award eq 'APPROX_ANS' ) {
760: if ($solved =~ /^incorrect/ || $solved eq '') {
1.144 albertel 761: $message = &mt("Incorrect").".";
1.221 albertel 762: $css_class=$possible_class{'charged_try'};
1.135 albertel 763: $button=1;
764: } else {
1.144 albertel 765: if ($target eq 'tex') {
766: $message = '\textbf{'.&mt('You are correct.').'}';
767: } else {
768: $message = "<b>".&mt('You are correct.')."</b>";
1.180 albertel 769: $message.= $computer;
1.144 albertel 770: }
1.148 albertel 771: $added_computer_text=1;
1.235 albertel 772: if ($awarded > 0
773: && $env{'course.'.
1.165 albertel 774: $env{'request.course.id'}.
1.235 albertel 775: '.disable_receipt_display'} ne 'yes') {
1.135 albertel 776: $message.=(($target eq 'web')?'<br />':' ').
1.235 albertel 777: &mt('Your receipt is [_1]',
778: (&Apache::lonnet::receipt($Apache::inputtags::part).
779: (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):'')));
1.135 albertel 780: }
1.221 albertel 781: $css_class=$possible_class{'correct'};
1.135 albertel 782: $button=0;
783: $previousmsg='';
784: }
785: } elsif ($award eq 'NO_RESPONSE') {
786: $message = '';
1.221 albertel 787: $css_class=$possible_class{'no_feedback'};
1.135 albertel 788: $button=1;
1.182 albertel 789: } elsif ($award eq 'EXTRA_ANSWER') {
790: $message = &mt('Some extra items were submitted.');
1.221 albertel 791: $css_class=$possible_class{'not_charged_try'};
1.182 albertel 792: $button = 1;
1.135 albertel 793: } elsif ($award eq 'MISSING_ANSWER') {
1.245 bisitz 794: $message = &mt('Some items were not submitted.');
795: if ($target ne 'tex') {
796: $message .= &Apache::loncommon::help_open_topic('Some_Items_Were_Not_Submitted');
797: }
1.221 albertel 798: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 799: $button = 1;
800: } elsif ($award eq 'ERROR') {
1.247 bisitz 801: $message = &mt('An error occurred while grading your answer.');
1.221 albertel 802: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 803: $button = 1;
804: } elsif ($award eq 'TOO_LONG') {
805: $message = &mt("The submitted answer was too long.");
1.221 albertel 806: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 807: $button=1;
808: } elsif ($award eq 'WANTED_NUMERIC') {
809: $message = &mt("This question expects a numeric answer.");
1.221 albertel 810: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 811: $button=1;
812: } elsif ($award eq 'MISORDERED_RANK') {
1.242 bisitz 813: $message = &mt('You have provided an invalid ranking.');
814: if ($target ne 'tex') {
815: $message.=' '.&mt('Please refer to [_1]',&Apache::loncommon::help_open_topic('Ranking_Problems',&mt('help on ranking problems')));
816: }
1.221 albertel 817: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 818: $button=1;
1.248 raeburn 819: } elsif ($award eq 'EXCESS_FILESIZE') {
820: $message = &mt('Submission won\'t be graded. The combined size of submitted files exceeded the amount allowed.');
821: $css_class=$possible_class{'not_charged_try'};
822: $button=1;
1.135 albertel 823: } elsif ($award eq 'INVALID_FILETYPE') {
1.255 bisitz 824: $message = &mt("Submission won't be graded. The type of file submitted is not allowed.");
1.221 albertel 825: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 826: $button=1;
827: } elsif ($award eq 'SIG_FAIL') {
1.145 albertel 828: my ($used,$min,$max)=split(':',$awardmsg);
1.212 albertel 829: my $word = ($used < $min) ? 'more' : 'fewer';
1.250 bisitz 830: $message = &mt("Submission not graded. Use $word digits.",$used);
1.221 albertel 831: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 832: $button=1;
1.137 albertel 833: } elsif ($award eq 'UNIT_INVALID_INSTRUCTOR') {
834: $message = &mt('Error in instructor specifed unit. This error has been reported to the instructor.', $awardmsg);
835: if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');}
1.221 albertel 836: $css_class=$possible_class{'not_charged_try'};
1.137 albertel 837: $button=1;
838: } elsif ($award eq 'UNIT_INVALID_STUDENT') {
1.155 albertel 839: $message = &mt('Unable to interpret units. Computer reads units as "[_1]".',&markup_unit($awardmsg,$target));
1.137 albertel 840: if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');}
1.221 albertel 841: $css_class=$possible_class{'not_charged_try'};
1.137 albertel 842: $button=1;
1.140 matthew 843: } elsif ($award eq 'UNIT_FAIL' || $award eq 'UNIT_IRRECONCIBLE') {
1.155 albertel 844: $message = &mt('Incompatible units. No conversion found between "[_1]" and the required units.',&markup_unit($awardmsg,$target));
1.136 albertel 845: if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');}
1.221 albertel 846: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 847: $button=1;
848: } elsif ($award eq 'UNIT_NOTNEEDED') {
1.155 albertel 849: $message = &mt('Only a number required. Computer reads units of "[_1]".',&markup_unit($awardmsg,$target));
1.221 albertel 850: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 851: $button=1;
852: } elsif ($award eq 'NO_UNIT') {
1.144 albertel 853: $message = &mt("Units required").'.';
1.135 albertel 854: if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units')};
1.221 albertel 855: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 856: $button=1;
1.153 albertel 857: } elsif ($award eq 'COMMA_FAIL') {
858: $message = &mt("Proper comma separation is required").'.';
1.221 albertel 859: $css_class=$possible_class{'not_charged_try'};
1.153 albertel 860: $button=1;
1.135 albertel 861: } elsif ($award eq 'BAD_FORMULA') {
1.240 www 862: $message = &mt("Unable to understand formula").'.';
863: if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Formula_Answers')};
1.221 albertel 864: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 865: $button=1;
1.251 www 866: } elsif ($award eq 'INTERNAL_ERROR') {
867: $message = &mt("An internal error occurred while processing your answer. Please try again later.");
868: $css_class=$possible_class{'not_charged_try'};
869: $button=1;
1.135 albertel 870: } elsif ($award eq 'INCORRECT') {
1.144 albertel 871: $message = &mt("Incorrect").'.';
1.221 albertel 872: $css_class=$possible_class{'charged_try'};
1.135 albertel 873: $button=1;
874: } elsif ($award eq 'SUBMITTED') {
875: $message = &mt("Your submission has been recorded.");
1.221 albertel 876: $css_class=$possible_class{'no_grade'};
1.135 albertel 877: $button=1;
1.261 raeburn 878: } elsif ($award eq 'SUBMITTED_CREDIT') {
879: $message = &mt("Your submission has been recorded, and credit awarded.");
880: $css_class=$possible_class{'correct'};
881: $button=1;
882: } elsif ($award eq 'ANONYMOUS') {
883: $message = &mt("Your anonymous submission has been recorded.");
884: $css_class=$possible_class{'no_grade'};
885: $button=1;
886: } elsif ($award eq 'ANONYMOUS_CREDIT') {
887: $message = &mt("Your anonymous submission has been recorded, and credit awarded.");
888: $css_class=$possible_class{'correct'};
1.135 albertel 889: } elsif ($award eq 'DRAFT') {
1.258 riegler 890: $message = &mt("Copy saved but not submitted.");
1.221 albertel 891: $css_class=$possible_class{'not_charged_try'};
1.135 albertel 892: $button=1;
893: } elsif ($award eq 'ASSIGNED_SCORE') {
1.144 albertel 894: $message = &mt("A score has been assigned.");
1.221 albertel 895: $css_class=$possible_class{'correct'};
1.135 albertel 896: $button=0;
1.144 albertel 897: } elsif ($award eq '') {
1.186 albertel 898: if ($handgrade && $Apache::inputtags::status[-1] eq 'SHOW_ANSWER') {
899: $message = &mt("Nothing submitted.");
1.221 albertel 900: $css_class=$possible_class{'charged_try'};
1.186 albertel 901: } else {
1.221 albertel 902: $css_class=$possible_class{'not_charged_try'};
1.186 albertel 903: }
1.144 albertel 904: $button=1;
1.135 albertel 905: } else {
906: $message = &mt("Unknown message").": $award";
907: $button=1;
908: }
1.209 albertel 909: my (undef,undef,$domain,$user)=&Apache::lonnet::whichuser();
1.194 banghart 910: foreach my $resid(@Apache::inputtags::response){
911: if ($Apache::lonhomework::history{"resource.$part.$resid.handback"}) {
1.254 raeburn 912: if ($target eq 'tex') {
913: $message.= "\\\\\n";
914: } else {
915: $message.='<br />';
916: }
1.198 albertel 917: my @files = split(/\s*,\s*/,
918: $Apache::lonhomework::history{"resource.$part.$resid.handback"});
919: my $file_msg;
920: foreach my $file (@files) {
1.254 raeburn 921: if ($target eq 'tex') {
922: $file_msg.= "\\\\\n".$file;
923: } else {
924: $file_msg.= '<br /><a href="/uploaded/'."$domain/$user".'/'.$file.'">'.$file.'</a>';
925: }
1.198 albertel 926: }
927: $message .= &mt('Returned file(s): [_1]',$file_msg);
1.254 raeburn 928: if ($target eq 'tex') {
929: $message.= "\\\\\n";
930: } else {
931: $message.='<br />';
932: }
1.198 albertel 933: }
1.194 banghart 934: }
935:
1.233 albertel 936: if (&Apache::lonhomework::hide_problem_status()
937: && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER'
938: && &hide_award($award)) {
1.135 albertel 939: $message = &mt("Answer Submitted: Your final submission will be graded after the due date.");
1.221 albertel 940: $css_class=$possible_class{'no_grade'};
1.135 albertel 941: $button=1;
942: }
1.148 albertel 943: if ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER' &&
1.150 albertel 944: !$added_computer_text && $target ne 'tex') {
1.180 albertel 945: $message.= $computer;
1.148 albertel 946: $added_computer_text=1;
1.144 albertel 947: }
1.237 www 948: if ($Apache::lonhomework::type eq 'practice') {
1.244 raeburn 949: if ($target eq 'web') {
950: $message .= '<br />';
951: } else {
952: $message .= ' ';
953: }
954: $message.=&mt('Submissions to practice problems are not permanently recorded.');
1.237 www 955: }
956:
1.221 albertel 957: return ($button,$css_class,$message,$previousmsg);
1.12 albertel 958: }
959:
1.155 albertel 960: sub markup_unit {
961: my ($unit,$target)=@_;
962: if ($target eq 'tex') {
963: return '\texttt{'.&Apache::lonxml::latex_special_symbols($unit).'}';
964: } else {
965: return "<tt>".$unit."</tt>";
966: }
967: }
968:
1.88 albertel 969: sub removealldata {
1.87 albertel 970: my ($id)=@_;
971: foreach my $key (keys(%Apache::lonhomework::results)) {
972: if (($key =~ /^resource\.\Q$id\E\./) && ($key !~ /\.collaborators$/)) {
973: &Apache::lonxml::debug("Removing $key");
974: delete($Apache::lonhomework::results{$key});
975: }
976: }
977: }
978:
1.142 albertel 979: sub hidealldata {
980: my ($id)=@_;
981: foreach my $key (keys(%Apache::lonhomework::results)) {
982: if (($key =~ /^resource\.\Q$id\E\./) && ($key !~ /\.collaborators$/)) {
983: &Apache::lonxml::debug("Hidding $key");
984: my $newkey=$key;
985: $newkey=~s/^(resource\.\Q$id\E\.[^\.]+\.)(.*)$/${1}hidden${2}/;
986: $Apache::lonhomework::results{$newkey}=
987: $Apache::lonhomework::results{$key};
988: delete($Apache::lonhomework::results{$key});
989: }
990: }
991: }
992:
1.12 albertel 993: sub setgradedata {
1.136 albertel 994: my ($award,$msg,$id,$previously_used) = @_;
1.154 albertel 995: if ($Apache::lonhomework::scantronmode &&
1.165 albertel 996: &Apache::lonnet::validCODE($env{'form.CODE'})) {
997: $Apache::lonhomework::results{"resource.CODE"}=$env{'form.CODE'};
1.154 albertel 998: } elsif ($Apache::lonhomework::scantronmode &&
1.165 albertel 999: $env{'form.CODE'} eq '' &&
1.154 albertel 1000: $Apache::lonhomework::history{"resource.CODE"} ne '') {
1001: $Apache::lonhomework::results{"resource.CODE"}='';
1.141 albertel 1002: }
1.154 albertel 1003:
1.135 albertel 1004: if (!$Apache::lonhomework::scantronmode &&
1005: $Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
1006: $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
1007: $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;
1.87 albertel 1008: return '';
1.135 albertel 1009: } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~
1.233 albertel 1010: /^correct/
1011: || $Apache::lonhomework::scantronmode
1012: || &Apache::lonhomework::hide_problem_status() ) {
1.154 albertel 1013: # the student doesn't already have it correct,
1014: # or we are in a mode (scantron orno problem status) where a correct
1015: # can become incorrect
1016: # handle assignment of tries and solved status
1.135 albertel 1017: my $solvemsg;
1018: if ($Apache::lonhomework::scantronmode) {
1019: $solvemsg='correct_by_scantron';
1020: } else {
1021: $solvemsg='correct_by_student';
1022: }
1023: if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) {
1024: $Apache::lonhomework::results{"resource.$id.afterduedate"}='';
1025: }
1026: if ( $award eq 'ASSIGNED_SCORE') {
1027: $Apache::lonhomework::results{"resource.$id.tries"} =
1028: $Apache::lonhomework::history{"resource.$id.tries"} + 1;
1029: $Apache::lonhomework::results{"resource.$id.solved"} =
1030: $solvemsg;
1031: my $numawards=scalar(@Apache::inputtags::response);
1032: $Apache::lonhomework::results{"resource.$id.awarded"} = 0;
1033: foreach my $res (@Apache::inputtags::response) {
1.232 albertel 1034: if (defined($Apache::lonhomework::results{"resource.$id.$res.awarded"})) {
1035: $Apache::lonhomework::results{"resource.$id.awarded"}+=
1036: $Apache::lonhomework::results{"resource.$id.$res.awarded"};
1037: } else {
1038: $Apache::lonhomework::results{"resource.$id.awarded"}+=
1039: &awarddetail_to_awarded($Apache::lonhomework::results{"resource.$id.$res.awarddetail"});
1040: }
1.135 albertel 1041: }
1042: if ($numawards > 0) {
1043: $Apache::lonhomework::results{"resource.$id.awarded"}/=
1044: $numawards;
1045: }
1046: } elsif ( $award eq 'APPROX_ANS' || $award eq 'EXACT_ANS' ) {
1047: $Apache::lonhomework::results{"resource.$id.tries"} =
1048: $Apache::lonhomework::history{"resource.$id.tries"} + 1;
1049: $Apache::lonhomework::results{"resource.$id.solved"} =
1050: $solvemsg;
1051: $Apache::lonhomework::results{"resource.$id.awarded"} = '1';
1.261 raeburn 1052: } elsif ( $award eq 'SUBMITTED_CREDIT' ) {
1053: $Apache::lonhomework::results{"resource.$id.tries"} =
1054: $Apache::lonhomework::history{"resource.$id.tries"} + 1;
1055: $Apache::lonhomework::results{"resource.$id.solved"} =
1056: 'credit_attempted';
1057: $Apache::lonhomework::results{"resource.$id.awarded"} = '1';
1058: } elsif ( $award eq 'ANONYMOUS_CREDIT' ) {
1059: $Apache::lonhomework::results{"resource.$id.tries"} =
1060: $Apache::lonhomework::history{"resource.$id.tries"} + 1;
1061: $Apache::lonhomework::results{"resource.$id.solved"} =
1062: 'credit_attempted';
1063: $Apache::lonhomework::results{"resource.$id.awarded"} = '1';
1.135 albertel 1064: } elsif ( $award eq 'INCORRECT' ) {
1065: $Apache::lonhomework::results{"resource.$id.tries"} =
1066: $Apache::lonhomework::history{"resource.$id.tries"} + 1;
1.233 albertel 1067: if (&Apache::lonhomework::hide_problem_status()
1068: || $Apache::lonhomework::scantronmode) {
1.135 albertel 1069: $Apache::lonhomework::results{"resource.$id.awarded"} = 0;
1070: }
1071: $Apache::lonhomework::results{"resource.$id.solved"} =
1072: 'incorrect_attempted';
1073: } elsif ( $award eq 'SUBMITTED' ) {
1074: $Apache::lonhomework::results{"resource.$id.tries"} =
1075: $Apache::lonhomework::history{"resource.$id.tries"} + 1;
1076: $Apache::lonhomework::results{"resource.$id.solved"} =
1077: 'ungraded_attempted';
1.261 raeburn 1078: } elsif ( $award eq 'ANONYMOUS' ) {
1079: $Apache::lonhomework::results{"resource.$id.tries"} =
1080: $Apache::lonhomework::history{"resource.$id.tries"} + 1;
1081: $Apache::lonhomework::results{"resource.$id.solved"} =
1082: 'ungraded_attempted';
1.135 albertel 1083: } elsif ( $award eq 'DRAFT' ) {
1084: $Apache::lonhomework::results{"resource.$id.solved"} = '';
1085: } elsif ( $award eq 'NO_RESPONSE' ) {
1086: #no real response so delete any data that got stored
1.129 albertel 1087: &removealldata($id);
1088: return '';
1089: } else {
1.135 albertel 1090: $Apache::lonhomework::results{"resource.$id.solved"} =
1091: 'incorrect_attempted';
1.233 albertel 1092: if (&Apache::lonhomework::show_no_problem_status()
1093: || $Apache::lonhomework::scantronmode) {
1.135 albertel 1094: $Apache::lonhomework::results{"resource.$id.tries"} =
1095: $Apache::lonhomework::history{"resource.$id.tries"} + 1;
1096: $Apache::lonhomework::results{"resource.$id.awarded"} = 0;
1097: }
1.233 albertel 1098:
1099: if (&Apache::lonhomework::show_some_problem_status()) {
1100: # clear out the awarded if they had gotten it wrong/right
1101: # and are now in an error mode
1102: $Apache::lonhomework::results{"resource.$id.awarded"} = '';
1103: }
1.135 albertel 1104: }
1.136 albertel 1105: if (defined($msg)) {
1106: $Apache::lonhomework::results{"resource.$id.awardmsg"} = $msg;
1107: }
1.135 albertel 1108: # did either of the overall awards chage? If so ignore the
1109: # previous check
1110: if (($Apache::lonhomework::results{"resource.$id.awarded"} eq
1111: $Apache::lonhomework::history{"resource.$id.awarded"}) &&
1112: ($Apache::lonhomework::results{"resource.$id.solved"} eq
1113: $Apache::lonhomework::history{"resource.$id.solved"})) {
1114: # check if this was a previous submission if it was delete the
1115: # unneeded data and update the previously_used attribute
1116: if ( $previously_used eq 'PREVIOUSLY_USED') {
1.233 albertel 1117: if (&Apache::lonhomework::show_problem_status()) {
1.135 albertel 1118: delete($Apache::lonhomework::results{"resource.$id.tries"});
1119: $Apache::lonhomework::results{"resource.$id.previous"} = '1';
1120: }
1121: } elsif ( $previously_used eq 'PREVIOUSLY_LAST') {
1122: #delete all data as they student didn't do anything, but save
1123: #the list of collaborators.
1124: &removealldata($id);
1125: #and since they didn't do anything we were never here
1126: return '';
1127: } else {
1128: $Apache::lonhomework::results{"resource.$id.previous"} = '0';
1129: }
1.101 albertel 1130: }
1.135 albertel 1131: } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} =~
1132: /^correct/ ) {
1133: #delete all data as they student already has it correct
1134: &removealldata($id);
1135: #and since they didn't do anything we were never here
1136: return '';
1.40 albertel 1137: }
1.135 albertel 1138: $Apache::lonhomework::results{"resource.$id.award"} = $award;
1.184 albertel 1139: if ($award eq 'SUBMITTED') {
1140: &Apache::response::add_to_gradingqueue();
1141: }
1.261 raeburn 1142: if (($Apache::lonhomework::type eq 'anonsurvey') ||
1143: ($Apache::lonhomework::type eq 'anonsurveycred')) {
1144: $Apache::lonhomework::results{"resource.$id.type"} = $Apache::lonhomework::type;
1145: }
1.10 albertel 1146: }
1147:
1.219 albertel 1148: sub find_which_previous {
1149: my ($version) = @_;
1150: my $part = $Apache::inputtags::part;
1151: my (@previous_version);
1152: foreach my $resp (@Apache::inputtags::response) {
1153: my $key = "$version:resource.$part.$resp.submission";
1154: my $submission = $Apache::lonhomework::history{$key};
1155: my %previous = &Apache::response::check_for_previous($submission,
1156: $part,$resp,
1157: $version);
1158: push(@previous_version,$previous{'version'});
1159: }
1160: return &previous_match(\@previous_version,
1161: scalar(@Apache::inputtags::response));
1162: }
1163:
1164: sub previous_match {
1165: my ($previous_array,$count) = @_;
1166: my $match = 0;
1167: my @matches;
1168: foreach my $versionar (@$previous_array) {
1169: foreach my $version (@$versionar) {
1170: $matches[$version]++;
1171: }
1172: }
1173: my $which=0;
1174: foreach my $elem (@matches) {
1175: if ($elem eq $count) {
1176: $match=1;
1177: last;
1178: }
1179: $which++;
1180: }
1181: return ($match,$which);
1182: }
1183:
1.9 albertel 1184: sub grade {
1.135 albertel 1185: my ($target) = @_;
1186: my $id = $Apache::inputtags::part;
1187: my $response='';
1.165 albertel 1188: if ( defined $env{'form.submitted'}) {
1.136 albertel 1189: my (@awards,@msgs);
1.135 albertel 1190: foreach $response (@Apache::inputtags::response) {
1191: &Apache::lonxml::debug("looking for response.$id.$response.awarddetail");
1192: my $value=$Apache::lonhomework::results{"resource.$id.$response.awarddetail"};
1193: &Apache::lonxml::debug("keeping $value from $response for $id");
1194: push (@awards,$value);
1.136 albertel 1195: $value=$Apache::lonhomework::results{"resource.$id.$response.awardmsg"};
1196: &Apache::lonxml::debug("got message $value from $response for $id");
1197: push (@msgs,$value);
1.135 albertel 1198: }
1.232 albertel 1199: my ($finalaward,$msg) =
1200: &finalizeawards(\@awards,\@msgs,undef,undef,
1201: $Apache::lonhomework::scantronmode);
1.135 albertel 1202: my $previously_used;
1203: if ( $#Apache::inputtags::previous eq $#awards ) {
1.219 albertel 1204: my ($match) =
1205: &previous_match(\@Apache::inputtags::previous_version,
1206: scalar(@Apache::inputtags::response));
1.244 raeburn 1207:
1.135 albertel 1208: if ($match) {
1209: $previously_used = 'PREVIOUSLY_LAST';
1210: foreach my $value (@Apache::inputtags::previous) {
1211: if ($value eq 'PREVIOUSLY_USED' ) {
1212: $previously_used = $value;
1213: last;
1214: }
1.75 albertel 1215: }
1216: }
1.43 albertel 1217: }
1.136 albertel 1218: &Apache::lonxml::debug("final award $finalaward, $previously_used, message $msg");
1219: &setgradedata($finalaward,$msg,$id,$previously_used);
1.43 albertel 1220: }
1.135 albertel 1221: return '';
1.1 albertel 1222: }
1223:
1.217 albertel 1224: sub get_grade_messages {
1225: my ($id,$prefix,$target,$status) = @_;
1226:
1227: my ($message,$latemessage,$trystr,$previousmsg);
1228: my $showbutton = 1;
1229:
1230: my $award = $Apache::lonhomework::history{"$prefix.award"};
1231: my $awarded = $Apache::lonhomework::history{"$prefix.awarded"};
1232: my $solved = $Apache::lonhomework::history{"$prefix.solved"};
1233: my $previous = $Apache::lonhomework::history{"$prefix.previous"};
1234: my $awardmsg = $Apache::lonhomework::history{"$prefix.awardmsg"};
1235: &Apache::lonxml::debug("Found Award |$award|$solved|$awardmsg");
1236: if ( $award ne '' || $solved ne '' || $status eq 'SHOW_ANSWER') {
1237: &Apache::lonxml::debug('Getting message');
1.221 albertel 1238: ($showbutton,my $css_class,$message,$previousmsg) =
1.217 albertel 1239: &decideoutput($award,$awarded,$awardmsg,$solved,$previous,
1240: $target);
1241: if ($target eq 'tex') {
1242: $message='\vskip 2 mm '.$message.' ';
1243: } else {
1.221 albertel 1244: $message="<td class=\"$css_class\">$message</td>";
1.217 albertel 1245: if ($previousmsg) {
1.221 albertel 1246: $previousmsg="<td class=\"LC_answer_previous\">$previousmsg</td>";
1.217 albertel 1247: }
1248: }
1249: }
1250: my $tries = $Apache::lonhomework::history{"$prefix.tries"};
1251: my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
1252: &Apache::lonxml::debug("got maxtries of :$maxtries:");
1253: #if tries are set to negative turn off the Tries/Button and messages
1254: if (defined($maxtries) && $maxtries < 0) { return ''; }
1255: if ( $tries eq '' ) { $tries = '0'; }
1256: if ( $maxtries eq '' ) { $maxtries = '2'; }
1257: if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; }
1.263 ! raeburn 1258: my $tries_text= &get_tries_text();;
1.217 albertel 1259: if ($showbutton) {
1260: if ($target eq 'tex') {
1261: if ($env{'request.state'} ne "construct"
1262: && $Apache::lonhomework::type ne 'exam'
1263: && $env{'form.suppress_tries'} ne 'yes') {
1264: $trystr = ' {\vskip 1 mm \small \textit{'.$tries_text.'} '.
1265: $tries.'/'.$maxtries.'} \vskip 2 mm ';
1266: } else {
1267: $trystr = '\vskip 0 mm ';
1268: }
1269: } else {
1.263 ! raeburn 1270: $trystr = '<td><span class="LC_nobreak">'.&mt($tries_text)." $tries";
1.217 albertel 1271: if ($Apache::lonhomework::parsing_a_task) {
1272: } elsif($env{'request.state'} ne 'construct') {
1273: $trystr.="/$maxtries";
1274: } else {
1275: if (defined($Apache::inputtags::params{'maxtries'})) {
1276: $trystr.="/".$Apache::inputtags::params{'maxtries'};
1277: }
1278: }
1.253 bisitz 1279: $trystr.="</span></td>";
1.217 albertel 1280: }
1281: }
1.221 albertel 1282:
1.217 albertel 1283: if ($Apache::lonhomework::history{"$prefix.afterduedate"}) {
1284: #last submissions was after due date
1285: $latemessage=&mt(' The last submission was after the Due Date ');;
1286: if ($target eq 'web') {
1.221 albertel 1287: $latemessage='<td class="LC_answer_late">'.$latemessage.'</td>';
1.217 albertel 1288: }
1289: }
1290: return ($previousmsg,$latemessage,$message,$trystr,$showbutton);
1291: }
1292:
1.11 albertel 1293: sub gradestatus {
1.223 albertel 1294: my ($id,$target,$no_previous) = @_;
1.135 albertel 1295: my $showbutton = 1;
1296: my $message = '';
1297: my $latemessage = '';
1298: my $trystr='';
1299: my $button='';
1300: my $previousmsg='';
1301:
1302: my $status = $Apache::inputtags::status['-1'];
1303: &Apache::lonxml::debug("gradestatus has :$status:");
1.183 albertel 1304: if ( $status ne 'CLOSED'
1305: && $status ne 'UNAVAILABLE'
1306: && $status ne 'INVALID_ACCESS'
1307: && $status ne 'NEEDS_CHECKIN'
1308: && $status ne 'NOT_IN_A_SLOT') {
1.217 albertel 1309:
1310: ($previousmsg,$latemessage,$message,$trystr) =
1311: &get_grade_messages($id,"resource.$id",$target,$status,
1312: $showbutton);
1313: if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {
1314: $showbutton = 0;
1.164 albertel 1315: }
1.218 albertel 1316: if ( $status eq 'SHOW_ANSWER') {
1317: undef($previousmsg);
1318: }
1.135 albertel 1319: if ( $showbutton ) {
1320: if ($target ne 'tex') {
1.230 albertel 1321: $button =
1.262 www 1322: '<input onmouseup="javascript:setSubmittedPart(\''.$id.'\');this.form.action+=\'#'.&escape($id).'\';"
1.260 droeschl 1323: type="submit" name="submit_'.$id.'"
1324: value="'.&mt('Submit Answer').'" />';
1.135 albertel 1325: }
1326: }
1.217 albertel 1327:
1.135 albertel 1328: }
1329: my $output= $previousmsg.$latemessage.$message.$trystr;
1330: if ($output =~ /^\s*$/) {
1331: return $button;
1.63 sakharuk 1332: } else {
1.135 albertel 1333: if ($target eq 'tex') {
1334: return $button.' \vskip 0 mm '.$output.' ';
1335: } else {
1.223 albertel 1336: $output =
1337: '<table><tr><td>'.$button.'</td>'.$output;
1338: if (!$no_previous) {
1339: $output.='<td>'.&previous_tries($id,$target).'</td>';
1340: }
1341: $output.= '</tr></table>';
1342: return $output;
1.135 albertel 1343: }
1.63 sakharuk 1344: }
1.11 albertel 1345: }
1.217 albertel 1346:
1347: sub previous_tries {
1348: my ($id,$target) = @_;
1349: my $output;
1350: my $status = $Apache::inputtags::status['-1'];
1.219 albertel 1351:
1352: my $count;
1353: my %count_lookup;
1354:
1.217 albertel 1355: foreach my $i (1..$Apache::lonhomework::history{'version'}) {
1356: my $prefix = $i.":resource.$id";
1.263 ! raeburn 1357: my $is_anon;
! 1358: if (defined($env{'form.grade_symb'})) {
! 1359: if (($Apache::lonhomework::history{"$prefix.type"} eq 'anonsurvey') ||
! 1360: ($Apache::lonhomework::history{"$prefix.type"} eq 'anonsurveycred')) {
! 1361: $is_anon = 1;
! 1362: }
! 1363: }
1.217 albertel 1364: next if (!exists($Apache::lonhomework::history{"$prefix.award"}));
1.219 albertel 1365: $count++;
1366: $count_lookup{$i} = $count;
1367:
1.217 albertel 1368: my ($previousmsg,$latemessage,$message,$trystr);
1369:
1370: ($previousmsg,$latemessage,$message,$trystr) =
1371: &get_grade_messages($id,"$prefix",$target,$status);
1372:
1.219 albertel 1373: if ($previousmsg ne '') {
1374: my ($match,$which) = &find_which_previous($i);
1375: $message=$previousmsg;
1376: my $previous = $count_lookup{$which};
1.226 albertel 1377: $message =~ s{(</td>)}{ as submission \# $previous $1};
1.221 albertel 1378: } elsif ($Apache::lonhomework::history{"$prefix.tries"}) {
1.233 albertel 1379: if (!(&Apache::lonhomework::hide_problem_status()
1.225 albertel 1380: && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER')
1381: && $Apache::lonhomework::history{"$prefix.solved"} =~/^correct/
1382: ) {
1383:
1.238 bisitz 1384: my $txt_correct = &mt('Correct');
1.221 albertel 1385: $message =~ s{(<td.*?>)(.*?)(</td>)}
1.238 bisitz 1386: {$1 <strong>$txt_correct</strong>. $3}s;
1.221 albertel 1387: }
1.238 bisitz 1388: my $trystr = "(".&mt('Try [_1]',$Apache::lonhomework::history{"$prefix.tries"}).")";
1.221 albertel 1389: $message =~ s{(</td>)}{ $trystr $1};
1.219 albertel 1390: }
1.221 albertel 1391: my ($class) = ($message =~ m{<td.*class="([^"]*)"}); #"
1392: $message =~ s{(<td.*?>)}{<td>};
1393:
1.219 albertel 1394:
1.221 albertel 1395: $output.='<tr class="'.$class.'">';
1.223 albertel 1396: $output.='<td align="center">'.$count.'</td>';
1.219 albertel 1397: $output.=$message;
1.217 albertel 1398:
1399: foreach my $resid (@Apache::inputtags::response) {
1400: my $prefix = $prefix.".$resid";
1401: if (exists($Apache::lonhomework::history{"$prefix.submission"})) {
1402: my $submission =
1403: $Apache::inputtags::submission_display{"$prefix.submission"};
1404: if (!defined($submission)) {
1405: $submission =
1406: $Apache::lonhomework::history{"$prefix.submission"};
1407: }
1.263 ! raeburn 1408: if ($is_anon) {
! 1409: $output.='<td>'.&mt('(only shown to submitter)').'</td>';
! 1410: } else {
! 1411: $output.='<td>'.$submission.'</td>';
! 1412: }
1.217 albertel 1413: } else {
1414: $output.='<td></td>';
1415: }
1416: }
1.221 albertel 1417: $output.=&Apache::loncommon::end_data_table_row()."\n";
1.217 albertel 1418: }
1419: return if ($output eq '');
1.219 albertel 1420: my $headers =
1.222 albertel 1421: '<tr>'.'<th>'.&mt('Submission #').'</th><th>'.&mt('Try').
1.219 albertel 1422: '</th><th colspan="'.scalar(@Apache::inputtags::response).'">'.
1423: &mt('Submitted Answer').'</th>';
1424: $output ='<table class="LC_prior_tries">'.$headers.$output.'</table>';
1.217 albertel 1425: #return $output;
1.229 albertel 1426: $output = &Apache::loncommon::js_ready($output);
1.226 albertel 1427: $output.='<br /><form action=""><center><input type="button" name="close" value="'.&mt('Close Window').'" onClick="window.close()" /></center></form>';
1428:
1.217 albertel 1429: my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
1.263 ! raeburn 1430: my $tries_text = &get_tries_text('link');
1.217 albertel 1431: my $start_page =
1.263 ! raeburn 1432: &Apache::loncommon::start_page($tries_text, undef,
1.229 albertel 1433: {'only_body' => 1,
1434: 'bgcolor' => '#FFFFFF',
1435: 'js_ready' => 1,
1436: 'inherit_jsmath' => 1, });
1.217 albertel 1437: my $end_page =
1438: &Apache::loncommon::end_page({'js_ready' => 1,});
1.231 albertel 1439: my $prefix = $env{'form.request.prefix'};
1440: $prefix =~ tr{.}{_};
1441: my $function_name = "LONCAPA_previous_tries_".$prefix.
1.234 albertel 1442: $Apache::lonxml::curdepth.'_'.$env{'form.counter'};
1.217 albertel 1443: my $result ="<script type=\"text/javascript\">
1444: // <![CDATA[
1.231 albertel 1445: function $function_name() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.$windowopen;newWindow.document.writeln('$start_page $output $end_page');newWindow.document.close();newWindow.focus()}
1.217 albertel 1446: // ]]>
1.263 ! raeburn 1447: </script><a href=\"javascript:$function_name();void(0);\">".&mt($tries_text)."</a><br />";
1.217 albertel 1448: #use Data::Dumper;
1449: #&Apache::lonnet::logthis(&Dumper(\%Apache::inputtags::submission_display));
1450: return $result;
1451: }
1452:
1.263 ! raeburn 1453: sub get_tries_text {
! 1454: my ($context) = @_;
! 1455: my $tries_text;
! 1456: if ($context eq 'link') {
! 1457: $tries_text = 'Previous Tries';
! 1458: } else {
! 1459: $tries_text = 'Tries';
! 1460: }
! 1461: if ( $Apache::lonhomework::type eq 'survey' ||
! 1462: $Apache::lonhomework::type eq 'surveycred' ||
! 1463: $Apache::lonhomework::type eq 'anonsurvey' ||
! 1464: $Apache::lonhomework::type eq 'anonsurveycred' ||
! 1465: $Apache::lonhomework::parsing_a_task) {
! 1466: if ($context eq 'link') {
! 1467: $tries_text = 'Previous Submissions';
! 1468: } else {
! 1469: $tries_text = 'Submissions';
! 1470: }
! 1471: }
! 1472: return $tries_text;
! 1473: }
! 1474:
1.1 albertel 1475: 1;
1476: __END__
1.249 jms 1477:
1478: =pod
1479:
1480: =back
1481:
1482: =cut
1.43 albertel 1483:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>