[system] / trunk / pg / macros / AppletObjects.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/AppletObjects.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 6026 Revision 6030
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: pg/macros/AppletObjects.pl,v 1.18 2009/03/10 12:07:47 gage Exp $ 4# $CVSHeader: pg/macros/AppletObjects.pl,v 1.19 2009/03/15 19:25:03 gage Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
109 my $self = shift; 109 my $self = shift;
110 my %options = @_; 110 my %options = @_;
111 111
112 # debugMode can be turned on by setting it to 1 in either the applet definition or at insertAll time 112 # debugMode can be turned on by setting it to 1 in either the applet definition or at insertAll time
113 my $debugMode = (defined($options{debug}) and $options{debug}==1) ? 1 : 0; 113 my $debugMode = (defined($options{debug}) and $options{debug}==1) ? 1 : 0;
114 my $includeAnswerBox = (defined($options{includeAnswerBox}) and $options{includeAnswerBox}==1) ? 1 : 0;
114 $debugMode = $debugMode || $self->debugMode; 115 $debugMode = $debugMode || $self->debugMode;
115 $self->debugMode( $debugMode); 116 $self->debugMode( $debugMode);
116 117
117 118
118 my $reset_button = $options{reset_button} || 0; 119 my $reset_button = $options{reinitialize_button} || 0;
120 warn qq! please change "reset_button=>1" to "reinitialize_button=>1" in the applet->installAll() command ! if defined($options{reset_button});
119 # prepare html code for storing state 121 # prepare html code for storing state
120 my $appletName = $self->appletName; 122 my $appletName = $self->appletName;
121 my $appletStateName = "${appletName}_state"; 123 my $appletStateName = "${appletName}_state";
122 my $getState = $self->getStateAlias; 124 my $getState = $self->getStateAlias;
123 my $setState = $self->setStateAlias; 125 my $setState = $self->setStateAlias;
124 my $getConfig = $self->getConfigAlias; 126 my $getConfig = $self->getConfigAlias;
125 my $setConfig = $self->setConfigAlias; 127 my $setConfig = $self->setConfigAlias;
126 128
127 my $base64_initialState = $self->base64_state; 129 my $base64_initialState = encode_base64($self->initialState);
128 main::RECORD_FORM_LABEL($appletStateName); #this insures that they'll be saved from one invocation to the next 130 main::RECORD_FORM_LABEL($appletStateName); #this insures that they'll be saved from one invocation to the next
129 #main::RECORD_FORM_LABEL("previous_$appletStateName");
130 my $answer_value = ''; 131 my $answer_value = '';
131 132
132 if ( defined( ${$main::inputs_ref}{$appletStateName} ) and ${$main::inputs_ref}{$appletStateName} =~ /\S/ ) { 133 if ( defined( ${$main::inputs_ref}{$appletStateName} ) and ${$main::inputs_ref}{$appletStateName} =~ /\S/ ) {
133 $answer_value = ${$main::inputs_ref}{$appletStateName}; 134 $answer_value = ${$main::inputs_ref}{$appletStateName};
134 } elsif ( defined( $main::rh_sticky_answers->{$appletStateName} ) ) { 135 } elsif ( defined( $main::rh_sticky_answers->{$appletStateName} ) ) {
181 !; 182 !;
182 183
183 my $state_input_element = ($debugMode) ? $debug_input_element : 184 my $state_input_element = ($debugMode) ? $debug_input_element :
184 qq!\n<input type="hidden" name = "$appletStateName" value ="$base_64_encoded_answer_value">!; 185 qq!\n<input type="hidden" name = "$appletStateName" value ="$base_64_encoded_answer_value">!;
185 my $reset_button_str = ($reset_button) ? 186 my $reset_button_str = ($reset_button) ?
186 qq!<br/><input type='button' value='set applet state to restart' onClick="setAppletStateToRestart('$appletName')"> 187 qq!<input type='button' value='return this question to its initial state' onClick="setAppletStateToRestart('$appletName')"><br/>!
188 : '' ;
187 <input type="button" value="reinitialize applet" onClick="getQE('$appletStateName').value='$base64_initialState'"/><br/>! 189 # <input type="button" value="reinitialize applet" onClick="getQE('$appletStateName').value='$base64_initialState'"/><br/>
188 : ''
189 ;
190 # always base64 encode the hidden answer value to prevent problems with quotes. 190 # always base64 encode the hidden answer value to prevent problems with quotes.
191 # 191 #
192 $state_storage_html_code = qq!<input type="hidden" name="previous_$appletStateName" value = "$base_64_encoded_answer_value">! 192 $state_storage_html_code = qq!<input type="hidden" name="previous_$appletStateName" value = "$base_64_encoded_answer_value">!
193 . $reset_button_str
194 . $state_input_element 193 . $state_input_element. $reset_button_str
195 ; 194 ;
196 $answerBox_code = qq!<br/><input type="input" name="answerBox" value="" size =50><br/> 195 my $answerBox_code ='';
196 if ($includeAnswerBox) {
197 if ($debugMode) {
198
199 $answerBox_code = $main::BR . main::NAMED_ANS_RULE('answerBox', 50 );
200 $answerBox_code .= qq!
197 <input type="button" value="get Answer from applet" onClick="eval(ww_applet_list['$appletName'].submitActionScript )"/> 201 <br/><input type="button" value="get Answer from applet" onClick="eval(ww_applet_list['$appletName'].submitActionScript )"/>
198 <br/> 202 <br/>
199 !; 203 !;
200 $answerBox_code = ($debugMode) ? $answerBox_code : q!<input type="hidden" name="answerBox" value="" size =50>!; 204 } else {
205 $answerBox_code = main::NAMED_HIDDEN_ANS_RULE('answerBox', 50 );
206 }
207 }
201 ####### 208 #######
202 # insert header material 209 # insert header material
203 ####### 210 #######
204 main::HEADER_TEXT($self->insertHeader()); 211 main::HEADER_TEXT($self->insertHeader());
205 # update the debug mode for this applet. 212 # update the debug mode for this applet.

Legend:
Removed from v.6026  
changed lines
  Added in v.6030

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9