[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 6079 Revision 6178
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$ 4# $CVSHeader: pg/macros/AppletObjects.pl,v 1.23 2009/07/12 23:38:12 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.
47 </script> 47 </script>
48 <script src="/webwork2_files/js/Base64.js" language="javascript"> 48 <script src="/webwork2_files/js/Base64.js" language="javascript">
49 </script> 49 </script>
50 <script src="/webwork2_files/js/ww_applet_support.js"> 50 <script src="/webwork2_files/js/ww_applet_support.js">
51 //upload functions stored in /opt/webwork/webwork2/htdocs/js ... 51 //upload functions stored in /opt/webwork/webwork2/htdocs/js ...
52
53 </script> 52 </script>
54END_HEADER_TEXT 53END_HEADER_TEXT
55 54
56}; 55};
57 56
108sub insertAll { ## inserts both header text and object text 107sub insertAll { ## inserts both header text and object text
109 my $self = shift; 108 my $self = shift;
110 my %options = @_; 109 my %options = @_;
111 110
112 # debugMode can be turned on by setting it to 1 in either the applet definition or at insertAll time 111 # 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; 112 my $debugMode = (defined($options{debug}) and $options{debug}>0) ? $options{debug} : 0;
114 my $includeAnswerBox = (defined($options{includeAnswerBox}) and $options{includeAnswerBox}==1) ? 1 : 0; 113 my $includeAnswerBox = (defined($options{includeAnswerBox}) and $options{includeAnswerBox}==1) ? 1 : 0;
115 $debugMode = $debugMode || $self->debugMode; 114 $debugMode = $debugMode || $self->debugMode;
116 $self->debugMode( $debugMode); 115 $self->debugMode( $debugMode);
117 116
118 117
119 my $reset_button = $options{reinitialize_button} || 0; 118 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 warn qq! please change "reset_button=>1" to "reinitialize_button=>1" in the applet->installAll() command \n! if defined($options{reset_button});
121 # prepare html code for storing state 120 # prepare html code for storing state
122 my $appletName = $self->appletName; 121 my $appletName = $self->appletName;
123 my $appletStateName = "${appletName}_state"; 122 my $appletStateName = "${appletName}_state";
124 my $getState = $self->getStateAlias; 123 my $getState = $self->getStateAlias;
125 my $setState = $self->setStateAlias; 124 my $setState = $self->setStateAlias;
157 } 156 }
158 } 157 }
159 $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
160 # debug version of the applet state answerBox and controls 159 # debug version of the applet state answerBox and controls
161 my $debug_input_element = qq!\n<textarea rows="4" cols="80" 160 my $debug_input_element = qq!\n<textarea rows="4" cols="80"
162 name = "$appletStateName">$decoded_answer_value</textarea><br/> 161 name = "$appletStateName">$decoded_answer_value</textarea><br/>!;
162 if ($getState=~/\S/) { # if getStateAlias is not an empty string
163 $debug_input_element .= qq!
163 <input type="button" value="$getState" 164 <input type="button" value="$getState"
164 onClick="debugText=''; 165 onClick="debugText='';
165 ww_applet_list['$appletName'].getState(); 166 ww_applet_list['$appletName'].getState();
166 if (debugText) {alert(debugText)};" 167 if (debugText) {alert(debugText)};"
167 > 168 >!;
169 }
170 if ($setState=~/\S/) { # if setStateAlias is not an empty string
171 $debug_input_element .= qq!
168 <input type="button" value="$setState" 172 <input type="button" value="$setState"
169 onClick="debugText=''; 173 onClick="debugText='';
170 ww_applet_list['$appletName'].setState(); 174 ww_applet_list['$appletName'].setState();
171 if (debugText) {alert(debugText)};" 175 if (debugText) {alert(debugText)};"
172 > 176 >!;
177 }
178 if ($getConfig=~/\S/) { # if getConfigAlias is not an empty string
179 $debug_input_element .= qq!
173 <input type="button" value="$getConfig" 180 <input type="button" value="$getConfig"
174 onClick="debugText=''; 181 onClick="debugText='';
175 ww_applet_list['$appletName'].getConfig(); 182 ww_applet_list['$appletName'].getConfig();
176 if (debugText) {alert(debugText)};" 183 if (debugText) {alert(debugText)};"
177 > 184 >!;
185 }
186 if ($setConfig=~/\S/) { # if setConfigAlias is not an empty string
187 $debug_input_element .= qq!
178 <input type="button" value="$setConfig" 188 <input type="button" value="$setConfig"
179 onClick="debugText=''; 189 onClick="debugText='';
180 ww_applet_list['$appletName'].setConfig(); 190 ww_applet_list['$appletName'].setConfig();
181 if (debugText) {alert(debugText)};" 191 if (debugText) {alert(debugText)};"
182 > 192 >!;
183 !; 193 }
184 194
185 my $state_input_element = ($debugMode) ? $debug_input_element : 195 my $state_input_element = ($debugMode) ? $debug_input_element :
186 qq!\n<input type="hidden" name = "$appletStateName" value ="$base_64_encoded_answer_value">!; 196 qq!\n<input type="hidden" name = "$appletStateName" value ="$base_64_encoded_answer_value">!;
187 my $reset_button_str = ($reset_button) ? 197 my $reset_button_str = ($reset_button) ?
188 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' value='return this question to its initial state' onClick="setAppletStateToRestart('$appletName')"><br/>!

Legend:
Removed from v.6079  
changed lines
  Added in v.6178

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9