Annotation of loncom/homework/response.pm, revision 1.21

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.21    ! albertel   10:   &Apache::lonxml::register('Apache::response',('responseparam','caparesponse','numericalresponse','radiobuttonresponse','optionresponse','imageresponse'));
1.1       albertel   11: }
                     12: 
1.13      albertel   13: sub start_response {
                     14:   my ($parstack,$safeeval)=@_;  
                     15:   my $args ='';
                     16:   if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
                     17:   my $id = &Apache::run::run("{$args;".'return $id}',$safeeval);
                     18:   if ($id eq '') { $id = $Apache::lonxml::curdepth; }
                     19:   push (@Apache::inputtags::response,$id);
                     20:   push (@Apache::inputtags::responselist,$id);
                     21:   @Apache::inputtags::inputlist=();
                     22:   return $id;
                     23: }
                     24: 
                     25: sub end_response {
                     26:   pop @Apache::inputtags::response;
                     27:   @Apache::inputtags::inputlist=();
                     28:   return '';
                     29: }
                     30: 
1.7       www        31: sub meta_parameter_write {
1.10      www        32:     my ($name,$type,$default,$display)=@_;
                     33:     return '<parameter part="'.$Apache::inputtags::part.
1.7       www        34: 	            '" name="'.$name.
                     35:                     '" type="'.$type.
                     36:                  '" default="'.$default.
1.10      www        37: 	         '" display="'.$display.
                     38:                           ' [Part: '.$Apache::inputtags::part.']"></parameter>'
1.7       www        39:      ."\n";
                     40: }
                     41: 
                     42: sub meta_stores_write {
1.10      www        43:     my ($name,$type,$display)=@_;
                     44:     return '<stores part="'.$Apache::inputtags::part.
1.7       www        45: 	         '" name="'.$name.
                     46:                  '" type="'.$type.
1.10      www        47: 	      '" display="'.$display.
                     48:                        ' [Part: '.$Apache::inputtags::part.']"></stores>'
1.7       www        49:      ."\n";
                     50: }
                     51: 
                     52: sub mandatory_part_meta {
                     53: #
                     54: # Autogenerate metadata for mandatory
                     55: # input (from RAT or lonparmset) and 
                     56: # output (to lonspreadsheet)
                     57: # of each part
                     58: #
                     59:  return
1.10      www        60:     &meta_parameter_write('opendate','date_start','',
1.7       www        61:                           'Opening Date').
1.10      www        62:     &meta_parameter_write('duedate','date_end','',
1.7       www        63:                           'Due Date').
1.10      www        64:     &meta_parameter_write('answerdate','date_start','',
1.7       www        65:                           'Show Answer Date').
1.10      www        66:     &meta_parameter_write('weight','int_zeropos','',
1.7       www        67:                           'Available Points').
1.10      www        68:     &meta_parameter_write('maxtries','int_pos','',
1.7       www        69:                           'Maximum Number of Tries').
                     70: 
1.10      www        71:     &meta_stores_write('solved','string',
1.7       www        72:                           'Problem Status').
1.10      www        73:     &meta_stores_write('tries','int_zeropos',
1.7       www        74:                           'Number of Unsuccessful Tries').
1.10      www        75:     &meta_stores_write('awarded','float',
1.7       www        76: 		          'Partial Credit Factor');
                     77: #
                     78: # Note: responseid-specific data 'submission' and 'awarddetail'
                     79: # not available to spreadsheet -> skip here
                     80: #
1.14      albertel   81: }
                     82: 
1.15      albertel   83: sub check_for_previous {
                     84:   return '0';
                     85: }
                     86: 
1.14      albertel   87: sub start_numericalresponse {
                     88:   require Apache::caparesponse; 
                     89:   import Apache::caparesponse; 
                     90:   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
                     91:   Apache::caparesponse::start_numericalresponse($target,$token,$parstack,$parser,$safeeval,$style);;
                     92:   return "";
1.7       www        93: }
                     94: 
1.1       albertel   95: sub start_caparesponse {
                     96:   require Apache::caparesponse; 
                     97:   import Apache::caparesponse; 
                     98:   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
1.2       albertel   99: #  print "\n<br>\nsimple caparesponse\n";
1.1       albertel  100:   Apache::caparesponse::start_caparesponse($target,$token,$parstack,$parser,$safeeval,$style);;
1.16      albertel  101:   return "";
                    102: }
                    103: 
                    104: sub start_radiobuttonresponse {
                    105:   require Apache::radiobuttonresponse; 
                    106:   import Apache::radiobuttonresponse; 
                    107:   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
1.17      albertel  108:   Apache::radiobuttonresponse::start_radiobuttonresponse($target,$token,$parstack,$parser,$safeeval,$style);;
1.19      albertel  109:   return "";
                    110: }
                    111: 
                    112: sub start_optionresponse {
                    113:   require Apache::optionresponse; 
                    114:   import Apache::optionresponse; 
                    115:   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
                    116:   Apache::optionresponse::start_optionresponse($target,$token,$parstack,$parser,$safeeval,$style);;
1.21    ! albertel  117:   return "";
        !           118: }
        !           119: 
        !           120: sub start_imageresponse {
        !           121:   require Apache::imageresponse; 
        !           122:   import Apache::imageresponse; 
        !           123:   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
        !           124:   Apache::imageresponse::start_imageresponse($target,$token,$parstack,$parser,$safeeval,$style);;
1.2       albertel  125:   return "";
1.3       albertel  126: }
                    127: 
                    128: sub start_responseparam {
                    129:   my ($target,$token,$parstack,$parser,$safeeval)=@_;
1.20      albertel  130:   if ($target eq 'grade' || $target eq 'web') {
1.8       albertel  131:     my $args='';
                    132:     if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
                    133:     my $default = &Apache::run::run("{$args;".'return $default}',$safeeval);
                    134:     my $name = &Apache::run::run("{$args;".'return $name}',$safeeval);
1.9       albertel  135:     &Apache::lonxml::debug("looking for resource.$Apache::inputtags::part.$name");
                    136:     my $value = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.$name");
1.8       albertel  137:     &Apache::lonxml::debug("$name has value :$value: and default :$default:");
1.18      albertel  138:     if ($value eq '' || $value eq 'con_lost') {
                    139:       &Apache::lonxml::debug("defaulting");
1.8       albertel  140:       $Apache::inputtags::params{$name}=$default;
                    141:     } else {
1.11      albertel  142:       &Apache::lonxml::debug("using value");
1.8       albertel  143:       $Apache::inputtags::params{$name}=$value;
                    144:     }
                    145:     return '';
1.12      albertel  146:   } elsif ($target eq 'meta') {
1.10      www       147:     return &meta_parameter_write($token->[2]->{'name'},
1.8       albertel  148: 				 $token->[2]->{'type'},
                    149: 				 $token->[2]->{'default'},
                    150: 				 $token->[2]->{'description'});
1.12      albertel  151:   } else {
                    152:     return '';
1.3       albertel  153:   }
                    154: }
                    155: 
                    156: sub end_responseparam {
1.1       albertel  157: }
1.2       albertel  158: 
1.1       albertel  159: 1;
                    160: __END__
                    161:  

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>