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.23 2009/07/12 23:38:12 gage Exp $ |
4 | # $CVSHeader: pg/macros/AppletObjects.pl,v 1.24 2010/01/03 17:13:46 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. |
… | |
… | |
156 | } |
156 | } |
157 | } |
157 | } |
158 | $base_64_encoded_answer_value =~ s/\r|\n//g; # get rid of line returns |
158 | $base_64_encoded_answer_value =~ s/\r|\n//g; # get rid of line returns |
159 | # debug version of the applet state answerBox and controls |
159 | # debug version of the applet state answerBox and controls |
160 | my $debug_input_element = qq!\n<textarea rows="4" cols="80" |
160 | my $debug_input_element = qq!\n<textarea rows="4" cols="80" |
161 | name = "$appletStateName">$decoded_answer_value</textarea><br/>!; |
161 | name = "$appletStateName" id = "$appletStateName">$decoded_answer_value</textarea><br/>!; |
162 | if ($getState=~/\S/) { # if getStateAlias is not an empty string |
162 | if ($getState=~/\S/) { # if getStateAlias is not an empty string |
163 | $debug_input_element .= qq! |
163 | $debug_input_element .= qq! |
164 | <input type="button" value="$getState" |
164 | <input type="button" value="$getState" |
165 | onClick="debugText=''; |
165 | onClick="debugText=''; |
166 | ww_applet_list['$appletName'].getState(); |
166 | ww_applet_list['$appletName'].getState(); |
… | |
… | |
191 | if (debugText) {alert(debugText)};" |
191 | if (debugText) {alert(debugText)};" |
192 | >!; |
192 | >!; |
193 | } |
193 | } |
194 | |
194 | |
195 | my $state_input_element = ($debugMode) ? $debug_input_element : |
195 | my $state_input_element = ($debugMode) ? $debug_input_element : |
196 | qq!\n<input type="hidden" name = "$appletStateName" value ="$base_64_encoded_answer_value">!; |
196 | qq!\n<input type="hidden" name = "$appletStateName" id = "$appletStateName" value ="$base_64_encoded_answer_value">!; |
197 | my $reset_button_str = ($reset_button) ? |
197 | my $reset_button_str = ($reset_button) ? |
198 | qq!<input type='submit' name='previewAnswers' value='return this question to its initial state' onClick="setAppletStateToRestart('$appletName')"><br/>! |
198 | qq!<input type='submit' name='previewAnswers' id ='previewAnswers' value='return this question to its initial state' onClick="setAppletStateToRestart('$appletName')"><br/>! |
199 | : '' ; |
199 | : '' ; |
200 | # <input type="button" value="reinitialize applet" onClick="getQE('$appletStateName').value='$base64_initialState'"/><br/> |
200 | # <input type="button" value="reinitialize applet" onClick="getQE('$appletStateName').value='$base64_initialState'"/><br/> |
201 | # always base64 encode the hidden answer value to prevent problems with quotes. |
201 | # always base64 encode the hidden answer value to prevent problems with quotes. |
202 | # |
202 | # |
203 | $state_storage_html_code = qq!<input type="hidden" name="previous_$appletStateName" value = "$base_64_encoded_answer_value">! |
203 | $state_storage_html_code = qq!<input type="hidden" name="previous_$appletStateName" id = "previous_$appletStateName" value = "$base_64_encoded_answer_value">! |
204 | . $state_input_element. $reset_button_str |
204 | . $state_input_element. $reset_button_str |
205 | ; |
205 | ; |
206 | my $answerBox_code =''; |
206 | my $answerBox_code =''; |
207 | if ($includeAnswerBox) { |
207 | if ($includeAnswerBox) { |
208 | if ($debugMode) { |
208 | if ($debugMode) { |