Annotation of loncom/homework/response.pm, revision 1.8
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # various response type definitons response definition
3:
1.7 www 4: # 11/23,11/24,11/28 Gerd Kortemeyer
1.5 www 5:
1.1 albertel 6: package Apache::response;
7: use strict;
8:
9: sub BEGIN {
1.3 albertel 10: &Apache::lonxml::register('Apache::response',('responseparam','caparesponse'));
1.1 albertel 11: }
12:
1.7 www 13: sub meta_parameter_write {
14: my ($partid,$name,$type,$default,$display)=@_;
15: return '<parameter part="'.$partid.
16: '" name="'.$name.
17: '" type="'.$type.
18: '" default="'.$default.
19: '" display="'.$display.' [Part: '.$partid.']"></parameter>'
20: ."\n";
21: }
22:
23: sub meta_stores_write {
24: my ($partid,$name,$type,$display)=@_;
25: return '<stores part="'.$partid.
26: '" name="'.$name.
27: '" type="'.$type.
28: '" display="'.$display.' [Part: '.$partid.']"></stores>'
29: ."\n";
30: }
31:
32: sub mandatory_part_meta {
1.8 ! albertel 33: my $partid=shift;
1.7 www 34: #
35: # Autogenerate metadata for mandatory
36: # input (from RAT or lonparmset) and
37: # output (to lonspreadsheet)
38: # of each part
39: #
40: return
41: &meta_parameter_write($partid,'opendate','date_start','',
42: 'Opening Date').
43: &meta_parameter_write($partid,'duedate','date_end','',
44: 'Due Date').
45: &meta_parameter_write($partid,'answerdate','date_start','',
46: 'Show Answer Date').
47: &meta_parameter_write($partid,'weight','int_zeropos','',
48: 'Available Points').
49: &meta_parameter_write($partid,'maxtries','int_pos','',
50: 'Maximum Number of Tries').
51:
52: &meta_stores_write($partid,'solved','string',
53: 'Problem Status').
54: &meta_stores_write($partid,'tries','int_zeropos',
55: 'Number of Unsuccessful Tries').
56: &meta_stores_write($partid,'awarded','float',
57: 'Partial Credit Factor');
58: #
59: # Note: responseid-specific data 'submission' and 'awarddetail'
60: # not available to spreadsheet -> skip here
61: #
62: }
63:
1.1 albertel 64: sub start_caparesponse {
65: require Apache::caparesponse;
66: import Apache::caparesponse;
67: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
1.2 albertel 68: # print "\n<br>\nsimple caparesponse\n";
1.1 albertel 69: Apache::caparesponse::start_caparesponse($target,$token,$parstack,$parser,$safeeval,$style);;
1.2 albertel 70: return "";
1.3 albertel 71: }
72:
73: sub start_responseparam {
74: my ($target,$token,$parstack,$parser,$safeeval)=@_;
1.8 ! albertel 75: if ($target ne 'meta') {
! 76: my $args='';
! 77: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
! 78: my $default = &Apache::run::run("{$args;".'return $default}',$safeeval);
! 79: my $name = &Apache::run::run("{$args;".'return $name}',$safeeval);
! 80: &Apache::lonxml::debug("looking for resource.$Apache::inputtags::part['-1'].$name");
! 81: my $value = &Apache::lonnet::EXT("resource.$Apache::inputtags::part['-1'].$name");
! 82: &Apache::lonxml::debug("$name has value :$value: and default :$default:");
! 83: if (!$value) {
! 84: $Apache::inputtags::params{$name}=$default;
! 85: } else {
! 86: $Apache::inputtags::params{$name}=$value;
! 87: }
! 88: return '';
1.3 albertel 89: } else {
1.8 ! albertel 90: return &meta_parameter_write(
! 91: $Apache::inputtags::part['-1'],
! 92: $token->[2]->{'name'},
! 93: $token->[2]->{'type'},
! 94: $token->[2]->{'default'},
! 95: $token->[2]->{'description'});
1.3 albertel 96: }
97: }
98:
99: sub end_responseparam {
1.1 albertel 100: }
1.2 albertel 101:
1.1 albertel 102: 1;
103: __END__
104:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>