Skip to content

Commit 0094ac8

Browse files
committed
Merge branch 'WeBWorK-2.15+instructorXML-errors-investigation' into webwork-2.15-new
2 parents 4258044 + e0648ef commit 0094ac8

File tree

13 files changed

+102
-83
lines changed

13 files changed

+102
-83
lines changed

clients/hello_world_apps/webwork_xmlrpc_client.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use constant REQUEST_URI => 'mod_xmlrpc';
3030
use constant TEMPOUTPUTFILE => '/Users/gage/Desktop/renderProblemOutput.html';
3131

32-
our $XML_URL = 'http://localhost:80';
32+
our $SITE_URL = 'http://localhost:80';
3333
our $FORM_ACTION_URL = 'http://localhost:80/webwork2/html2xml';
3434
our $XML_PASSWORD = 'xmlwebwork';
3535
our $XML_COURSE = 'gage_course';
@@ -98,7 +98,7 @@
9898
# Build client
9999
############################################
100100
our $xmlrpc_client = new WebworkClient (
101-
url => $XML_URL,
101+
site_url => $SITE_URL,
102102
form_action_url => $FORM_ACTION_URL,
103103
displayMode => DISPLAYMODE(),
104104

clients/sendXMLRPC.pl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ sub process_problem {
878878

879879
### build client
880880
my $xmlrpc_client = new WebworkClient (
881-
url => $credentials{site_url},
881+
site_url => $credentials{site_url},
882882
form_action_url => $credentials{form_action_url},
883883
site_password => $credentials{site_password}//'',
884884
courseID => $credentials{courseID},
@@ -964,7 +964,7 @@ sub process_problem {
964964
WebworkClient::writeRenderLogEntry("",
965965
"{script:$scriptName; file:$file_path; ".
966966
sprintf("duration: %.3f sec;", $cg_duration).
967-
" url: $credentials{site_url}; }",'');
967+
" site_url: $credentials{site_url}; }",'');
968968

969969
#######################################################################
970970
# End processing of the pg file
@@ -1440,12 +1440,12 @@ sub print_help_message {
14401440
or create a file with this information and specify it with the --credentials option.
14411441
14421442
%credentials = (
1443-
userID => "my login name for the webwork course",
1444-
course_password => "my password ",
1445-
courseID => "the name of the webwork course",
1446-
XML_URL => "url of rendering site
1447-
XML_PASSWORD => "site password" # preliminary access to site
1448-
$FORM_ACTION_URL = 'http://localhost:80/webwork2/html2xml'; #action url for form
1443+
userID => "my login name for the webwork course",
1444+
course_password => "my password ",
1445+
courseID => "the name of the webwork course",
1446+
SITE_URL => "url of rendering site",
1447+
XML_PASSWORD => "site password", # preliminary access to site
1448+
form_action_url => 'http://localhost:80/webwork2/html2xml' #action url for form
14491449
);
14501450
14511451
Options

lib/FormatRenderedProblem.pm

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ sub new {
7777
my $invocant = shift;
7878
my $class = ref $invocant || $invocant;
7979
$self = {
80-
return_object => {},
81-
encoded_source => {},
82-
sourceFilePath => '',
83-
url => 'https://demo.webwork.rochester.edu',
80+
return_object => {},
81+
encoded_source => {},
82+
sourceFilePath => '',
83+
site_url => 'https://demo.webwork.rochester.edu',
8484
form_action_url =>'',
85-
maketext => sub {return @_},
86-
courseID => 'daemon_course', # optional?
87-
userID => 'daemon', # optional?
85+
maketext => sub {return @_},
86+
courseID => 'daemon_course', # optional?
87+
userID => 'daemon', # optional?
8888
course_password => 'daemon',
8989
inputs_ref => {},
9090
@_,
@@ -103,11 +103,11 @@ sub encoded_source {
103103
$self->{encoded_source} =$source if defined $source and $source =~/\S/; # source is non-empty
104104
$self->{encoded_source};
105105
}
106-
sub url {
106+
sub site_url {
107107
my $self = shift;
108108
my $new_url = shift;
109-
$self->{url} = $new_url if defined($new_url) and $new_url =~ /\S/;
110-
$self->{url};
109+
$self->{site_url} = $new_url if defined($new_url) and $new_url =~ /\S/;
110+
$self->{site_url};
111111
}
112112
sub formatRenderedProblem {
113113
my $self = shift;
@@ -237,8 +237,8 @@ sub formatRenderedProblem {
237237

238238

239239
$self->{outputformats}={};
240-
my $XML_URL = $self->url;
241-
my $FORM_ACTION_URL = $self->{form_action_url};
240+
my $SITE_URL = $self->site_url//'';
241+
my $FORM_ACTION_URL = $self->{form_action_url}//'';
242242

243243
#################################################
244244
# Local docker usage with a port number sometimes misbehaves if the port number
@@ -257,11 +257,11 @@ sub formatRenderedProblem {
257257

258258
#################################################
259259

260-
my $courseID = $self->{courseID};
261-
my $userID = $self->{userID};
262-
my $course_password = $self->{course_password};
263-
my $problemSeed = $self->{inputs_ref}->{problemSeed}//4444;
264-
my $psvn = $self->{inputs_ref}->{psvn}//54321;
260+
my $courseID = $self->{courseID}//'';
261+
my $userID = $self->{userID}//'';
262+
my $course_password = $self->{course_password}//'';
263+
my $problemSeed = $self->{inputs_ref}->{problemSeed}//6666;
264+
my $psvn = $self->{inputs_ref}->{psvn}//54321;
265265
my $session_key = $rh_result->{session_key}//'';
266266
my $displayMode = $self->{inputs_ref}->{displayMode};
267267

lib/WeBWorK/ContentGenerator/instructorXMLHandler.pm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ use JSON;
5555
=cut
5656

5757
# To configure the target webwork server two URLs are required
58-
# 1. $XML_URL http://test.webwork.maa.org/mod_xmlrpc
58+
# 1. http://test.webwork.maa.org/mod_xmlrpc
5959
# points to the Webservice.pm and Webservice/RenderProblem modules
6060
# Is used by the client to send the original XML request to the webservice
61-
#
61+
# Note: This not the same as the webworkClient->url which should NOT have
62+
# the mod_xmlrpc segment.
6263
# 2. $FORM_ACTION_URL http:http://test.webwork.maa.org/webwork2/html2xml
6364
# points to the renderViaXMLRPC.pm module.
6465
#
@@ -112,14 +113,14 @@ unless ($server_root_url) {
112113
# child
113114
############################
114115

115-
our ($XML_URL,$FORM_ACTION_URL, $XML_PASSWORD, $XML_COURSE);
116+
our ($SITE_URL, $FORM_ACTION_URL, $XML_PASSWORD, $XML_COURSE);
116117

117118
$XML_PASSWORD = 'xmluser';
118119
$XML_COURSE = 'daemon_course';
119120

120121

121122

122-
$XML_URL = "$server_root_url/mod_xmlrpc";
123+
$SITE_URL = "$server_root_url" ;
123124
$FORM_ACTION_URL = "$server_root_url/webwork2/instructorXMLHandler";
124125

125126
use constant DISPLAYMODE => 'images'; # Mathjax is another possibilities.
@@ -165,11 +166,10 @@ sub pre_header_initialize {
165166
#######################
166167
my $xmlrpc_client = new WebworkClient;
167168

168-
$xmlrpc_client->url($XML_URL);
169+
$xmlrpc_client->site_url($SITE_URL); # does NOT include mod_xmlrpc ending
170+
# $xmlrpc_client->{site_url} =''; # make this the site without the mod_xmlrpc ending? ~= s/mod_xmlrpc$
169171
$xmlrpc_client->{form_action_url}= $FORM_ACTION_URL;
170-
# $xmlrpc_client->{displayMode} = DISPLAYMODE();
171172
$xmlrpc_client->{user} = 'xmluser';
172-
# $xmlrpc_client->{password} = $XML_PASSWORD;
173173
$xmlrpc_client->{site_password} = $XML_PASSWORD;
174174
# $xmlrpc_client->{course} = $r->param('courseID');
175175
$xmlrpc_client->{courseID} = $r->param('courseID');
@@ -263,8 +263,8 @@ sub pre_header_initialize {
263263

264264

265265
if ($UNIT_TESTS_ON) {
266-
print STDERR "instructorXMLHandler.pm ".__LINE__." values obtained from form parameters\n\t",
267-
format_hash_ref($input);
266+
print STDERR "\tinstructorXMLHandler.pm ".__LINE__." values obtained from form parameters\n\t",
267+
format_hash_ref($input),"\n";
268268
}
269269
my $source = "";
270270
#print $r->param('problemPath');

lib/WeBWorK/ContentGenerator/renderViaXMLRPC.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use CGI;
5454
=cut
5555

5656
# To configure the target webwork server two URLs are required
57-
# 1. $XML_URL http://test.webwork.maa.org/mod_xmlrpc
57+
# 1. http://test.webwork.maa.org/mod_xmlrpc
5858
# points to the Webservice.pm and Webservice/RenderProblem modules
5959
# Is used by the client to send the original XML request to the webservice
6060
#
@@ -111,14 +111,14 @@ unless ($server_root_url) {
111111
# child
112112
############################
113113

114-
our ($XML_URL,$FORM_ACTION_URL, $XML_PASSWORD, $XML_COURSE);
114+
our ($SITE_URL,$FORM_ACTION_URL, $XML_PASSWORD, $XML_COURSE);
115115

116116
$XML_PASSWORD = 'xmlwebwork';
117117
$XML_COURSE = 'daemon_course';
118118

119119

120120

121-
$XML_URL = "$server_root_url"; #"$server_root_url/mod_xmlrpc";
121+
$SITE_URL = "$server_root_url";
122122
$FORM_ACTION_URL = "$server_root_url/webwork2/html2xml";
123123

124124

@@ -173,7 +173,7 @@ sub pre_header_initialize {
173173
my $xmlrpc_client = new WebworkClient;
174174

175175
$xmlrpc_client ->encoded_source($r->param('problemSource')) ; # this source has already been encoded
176-
$xmlrpc_client-> url($XML_URL);
176+
$xmlrpc_client-> site_url($SITE_URL);
177177
$xmlrpc_client->{form_action_url} = $FORM_ACTION_URL;
178178
$xmlrpc_client->{userID} = $inputs_ref{userID};
179179
$xmlrpc_client->{course_password} = $inputs_ref{course_password};

lib/WebworkClient.pm

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ WebworkClient.pm
2323
2424
=head1 SYNPOSIS
2525
our $xmlrpc_client = new WebworkClient (
26-
url => $XML_URL,
26+
url => $ce->{server_site_url},
2727
form_action_url => $FORM_ACTION_URL,
2828
site_password => $XML_PASSWORD//'',
2929
courseID => $credentials{courseID},
@@ -62,9 +62,11 @@ use warnings;
6262

6363
# To configure the target webwork server
6464
# two URLs are required
65-
# 1. $XML_URL http://test.webwork.maa.org/mod_xmlrpc
65+
# 1. $SITE_URL http://test.webwork.maa.org/mod_xmlrpc
6666
# points to the Webservice.pm and Webservice/RenderProblem modules
6767
# Is used by the client to send the original XML request to the webservice
68+
# Note: This is not the same as the webworkClient->url which should NOT have
69+
# the mod_xmlrpc segment.
6870
#
6971
# 2. $FORM_ACTION_URL http:http://test.webwork.maa.org/webwork2/html2xml
7072
# points to the renderViaXMLRPC.pm module.
@@ -87,10 +89,11 @@ use warnings;
8789
# The renderViaXMLRPC.pm translates the WeBWorK form, has it processes by the webservice
8890
# and returns the result to the browser.
8991
# The The client renderProblem.pl script is no longer involved.
90-
# 4. Summary: renderProblem.pl is only involved in the first round trip
91-
# of the submitted problem. After that the communication is between the browser and
92-
# renderViaXMLRPC using HTML forms and between renderViaXMLRPC and the WebworkWebservice.pm
93-
# module using XML_RPC.
92+
# 4. Summary: The WebworkWebservice (with command renderProblem) is called directly in the first round trip
93+
# of submitting the problem via the https://mysite.edu/mod_xmlrpc route. After that the communication is
94+
# between the browser and renderViaXMLRPC using HTML forms and the route https://mysite.edu/webwork2/html2xml
95+
# and from there renderViaXMLRPC calls the WebworkWebservice using the route https://mysite.edu/mod_xmlrpc with the
96+
# renderProblem command.
9497

9598

9699
our @COMMANDS = qw( listLibraries renderProblem ); #listLib readFile tex2pdf
@@ -264,23 +267,33 @@ sub xmlrpcCall {
264267

265268
my $requestResult;
266269
my $transporter = TRANSPORT_METHOD->new;
267-
270+
#FIXME -- transitional error fix to remove mod_xmlrpc from end of url call
271+
my $site_url = $self->site_url;
272+
if ($site_url =~ /mod_xmlrpc$/ ){
273+
$site_url =~ s|/mod_xmlrpc/?||; # mod_xmlrpc from https://my.site.edu/mod_xmlrpc
274+
$self->site_url($site_url);
275+
# complain
276+
print STDERR "\n\n\$self->site_url() should not end in /mod_xmlrpc \n\n";
277+
}
268278
eval {
269279
$requestResult= $transporter
270280
#->uri('http://'.HOSTURL.':'.HOSTPORT.'/'.REQUEST_CLASS)
271281
#-> proxy(PROTOCOL.'://'.HOSTURL.':'.HOSTPORT.'/'.REQUEST_URI);
272-
-> proxy(($self->url).'/'.REQUEST_URI);
282+
-> proxy(($site_url).'/'.REQUEST_URI);
273283
};
274-
print STDERR "WebworkClient: Initiating xmlrpc request to url ",($self->url).'/'.REQUEST_URI, " \n Error: $@\n" if $@;
284+
# END of FIXME section
285+
286+
print STDERR "WebworkClient: Initiating xmlrpc request to url ",($self->site_url).'/'.REQUEST_URI, " \n Error: $@\n" if $@;
275287
# turn off verification of the ssl cert
276288
$transporter->transport->ssl_opts(verify_hostname=>0,
277289
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE);
278290

279291
if ($UNIT_TESTS_ON) {
280-
print STDERR "WebworkClient.pm ".__LINE__." xmlrpcCall sent to ", $self->url,"\n";
281-
print STDERR "WebworkClient.pm ".__LINE__." xmlrpcCall issued with command $command\n";
282-
print STDERR "WebworkClient.pm ".__LINE__." input is: ",join(" ", %{$self->request_object}),"\n";
283-
print STDERR "WebworkClient.pm ".__LINE__." xmlrpcCall $command initiated webwork webservice object $requestResult\n";
292+
print STDERR "\n\tWebworkClient.pm ".__LINE__." xmlrpcCall sent to site ", $self->site_url,"\n";
293+
print STDERR "\tWebworkClient.pm ".__LINE__." full xmlrpcCall path ", ($self->site_url).'/'.REQUEST_URI,"\n";
294+
print STDERR "\tWebworkClient.pm ".__LINE__." xmlrpcCall issued with command $command\n";
295+
print STDERR "\tWebworkClient.pm ".__LINE__." input is: ",join(" ", map {$_//'--'} %{$self->request_object}),"\n";
296+
print STDERR "\tWebworkClient.pm ".__LINE__." xmlrpcCall $command initiated webwork webservice object $requestResult\n";
284297
}
285298

286299
local( $result);
@@ -353,7 +366,7 @@ sub jsXmlrpcCall {
353366
my $transporter = TRANSPORT_METHOD->new;
354367

355368
my $requestResult = $transporter
356-
-> proxy(($self->url).'/'.REQUEST_URI);
369+
-> proxy(($self->site_url).'/'.REQUEST_URI);
357370
$transporter->transport->ssl_opts(verify_hostname=>0,
358371
SSL_verify_mode => 'SSL_VERIFY_NONE');
359372

@@ -382,28 +395,26 @@ sub jsXmlrpcCall {
382395
}
383396
}
384397

385-
=head2 encodeSource
386398

387399

388-
=cut
389-
sub encodeSource {
390-
my $self = shift;
391-
my $source = shift||'';
392-
$self->{encoded_source} =encode_utf8_base64($source);
393-
}
394-
395400
=head2 Accessor methods
396-
401+
enconcodeSource # encode source string with utf8 and base64 and store in encoded_source
397402
encoded_source
398403
request_object
399404
return_object
400405
error_string
401406
fault
402-
url
407+
site_url (https://mysite.edu)
403408
form_data
404409
405410
=cut
406411

412+
sub encodeSource {
413+
my $self = shift;
414+
my $source = shift||'';
415+
$self->{encoded_source} =encode_utf8_base64($source);
416+
}
417+
407418
sub encoded_source {
408419
my $self = shift;
409420
my $source = shift;
@@ -434,9 +445,17 @@ sub fault {
434445
$self->{fault_flag} =$fault_flag if defined $fault_flag and $fault_flag =~/\S/; # source is non-empty
435446
$self->{fault_flag};
436447
}
437-
sub url {
448+
sub site_url { #site_url https://mysite.edu
449+
my $self = shift;
450+
my $new_url = shift;
451+
$self->{site_url} = $new_url if defined($new_url) and $new_url =~ /\S/;
452+
$self->{site_url};
453+
}
454+
455+
sub url { #site_url https://mysite.edu
438456
my $self = shift;
439457
my $new_url = shift;
458+
die "use webworkClient->site_url instead of webworkClient->url";
440459
$self->{url} = $new_url if defined($new_url) and $new_url =~ /\S/;
441460
$self->{url};
442461
}

lib/WebworkClient/debug_format.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<html $COURSE_LANG_AND_DIR>
55
<head>
66
<meta charset='utf-8'>
7-
<base href="$XML_URL">
8-
<title>$XML_URL WeBWorK using host: $XML_URL, course: $courseID format: debug</title>
7+
<base href="$SITE_URL">
8+
<title>$SITE_URL WeBWorK using host: $SITE_URL, course: $courseID format: debug</title>
99
</head>
1010
<body>
1111
12-
<h2> WeBWorK using host: $XML_URL, course: $courseID format: debug</h2>
12+
<h2> WeBWorK using host: $SITE_URL, course: $courseID format: debug</h2>
1313
$pretty_print_self
1414
</body>
1515
</html>

lib/WebworkClient/json_format.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$nextBlock = <<'ENDPROBLEMTEMPLATE';
1616
<head>
1717
<meta charset='utf-8'>
18-
<base href="TO_SET_LATER_XML_URL">
18+
<base href="TO_SET_LATER_SITE_URL">
1919
<link rel="shortcut icon" href="/webwork2_files/images/favicon.ico"/>
2020
ENDPROBLEMTEMPLATE
2121

@@ -145,7 +145,7 @@
145145
# to communicate with WW, while the distant client must use URLs of the
146146
# intermediate server (the man in the middle).
147147

148-
push( @pairs_for_json, "real_webwork_XML_URL", '$XML_URL' );
148+
push( @pairs_for_json, "real_webwork_SITE_URL", '$SITE_URL' );
149149
push( @pairs_for_json, "real_webwork_FORM_ACTION_URL", '$FORM_ACTION_URL' );
150150
push( @pairs_for_json, "internal_problem_lang_and_dir", '$PROBLEM_LANG_AND_DIR');
151151

lib/WebworkClient/ptx_format.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$ptx_static_format = <<'ENDPROBLEMTEMPLATE';
2-
<!--$XML_URL WeBWorK Editor using host: $XML_URL, course: $courseID format: ptx -->
2+
<!--$SITE_URL WeBWorK Editor using host: $SITE_URL, course: $courseID format: ptx -->
33
<!--BEGIN PROBLEM-->
44
<webwork>
55
$problemText

0 commit comments

Comments
 (0)