Client Editor
Contents
External Client Editor
It is often convenient to use an external editor to write new WeBWorK questions rather than to compose them using the web browser interface. To do this your local
editor calls the script renderProblem.pl
which sends the current contents of the editor off to a WeBWorK server for processing and then displays the resulting
rendered problem in a browser. The question is "live" so you can enter responses and see whether they are graded correctly. The text file for the new question remains on your desktop or laptop.
How to use it
UnderConstruction
- Create a short screencast showing the external client in action.
Install Perl on your local desktop machine
- For a windows machine do the following:
Goto http://www.activestate.com/activeperl/downloads and click on one of the blue buttons (for the 64 or 32 bit versions) "Download ActivePerl 5.12.2 for Windows" .
After it installs under programs you will have a "Perl Package Manager". It will probably be pretty prominent but if not under "all programs" look in "ActivePerl ..."
Open it up and install the following three packages: SOAP-Lite, Class-Inspector and Crypt-SSLeay
You need Crypt-SSLeay only if you plan to access a site using the secure protocol (https). In that case you also need to uncomment the line "use Crypt::SSLeay".
Obtaining the client files
On your desktop machine you need the files WebworkClient.pm
and
renderProblem.pl
.
You can download them from the svn repository using the links above or you can find them in webwork2/clients/renderProblem.pl
and
webwork2/lib/WebworkClient.pm
if you have already downloaded the full WeBWorK software package.
- For UltraEdit on Windows put these files in a directory, for example
\akp\perl\render
- For BBEdit on the Mac, see below for where to put the files
Configuring renderProblem.pl
The configuration section for the client is at the top of the renderProblem.pl file.
- For Windows, you need to edit the
use lib
line (not necessary on the Mac). - A valid local path must be entered for the TEMPOUTPUTFILE.
- A valid command line string must be entered for the DISPLAY_COMMAND.
- Choose a server site to render the questions for display.
- You can add additional server sites in the script file
renderProblem.pl
- You can add additional server sites in the script file
#Sample use lib
line when using Windows (not necessary on the Mac).
#Comment out the original line and enter the directory containing renderProblem.pl and WebworkClient.pm
#use lib '/opt/webwork/webwork2/lib';
use lib 'C:/akp/perl/render';
# Sample path to a temporary file for storing the output of renderProblem.pl on a Mac. use constant TEMPOUTPUTFILE => '/Users/gage/Desktop/renderProblemOutput.html'; # Sample command lines for displaying the temporary file in a browser on a Mac. use constant DISPLAY_COMMAND => 'open -a firefox '; #browser opens tempoutputfile above # use constant DISPLAY_COMMAND => "open -a 'Google Chrome' ";
# Sample path to a temporary file for storing the output of renderProblem.pl on Windows. use constant TEMPOUTPUTFILE => '/Users/Arnie/Desktop/renderProblemOutput.html'; # Sample command lines for displaying the temporary file in a browser on Windows. # I found the directory by right clicking on a shortcut for the browser and then hitting properties. use constant DISPLAY_COMMAND => '/Users/Arnie/AppData/Local/Google/Chrome/Application/chrome.exe file:///C:'; # use constant DISPLAY_COMMAND => "open -a 'Google Chrome' ";
my $use_site; $use_site = 'test_webwork'; # select rendering sitetest.webwork.maa.org
#$use_site = 'local'; # select rendering sitelocalhost
#$use_site = 'rochester_test'; # select rendering site128.151.231.2
(at Rochester)
Configuring the client editor
- BBEdit on the Mac
For BBEdit (on the Mac) the renderProblem.pl
must be copied from webwork2/clients/renderProblem.pl
to ~/Library/Application Support/BBEdit/Unix Support/Unix Filters/renderProblem.pl
on the Mac. WebworkClient.pm
file should be copied to this same directory unless you have all of the webwork software installed at /opt/webwork/webwork2
Assigning this filter a key command ^R
allows you to render a problem with a single stroke.
Problems with pictures and applets might not render perfectly on the external editor since there are some auxiliary files that are not transferred between the server and the desktop.
- UltraEdit on Windows
Open Ultraedit and in the top toolbar click on Advanced, Tool Configuration..., Insert: Enter WeBWorK
for the name,
C:\akp\perl\render\renderProblem.pl "%f"
for the command line (where you should change \akp\perl\render\ to match the location of the files) and save it.
To display a problem, open the pg file in UltraEdit (either locally or on a remote machine via sftp). Then click on Advanced, WeBWorK and you should see the problem displayed. If you think clicking "Advanced, WeBWorK" is too hard, you can set up a hot key to do that in one click.
- Unix editors
Most modern browsers have facilities for passing their contents through a command line filter.
- Command line
From the command line
renderProblem.pl <TextInputFileName
- grabs the contents of the file
TextInputFileName
- ships it to the WeBWorK server site for rendering,
- stores the result in the TEMPOUTPUTFILE and then
- executes the DISPLAY_COMMAND to display the TEMPOUTPUTFILE.
Configuring the server
Every WeBWorK site is automatically configured to be a server for external client editors. But it needs to be turned on. Here is the relevant snippet in webwork.apache2-config:
########### WebworkWebservice XMLRPC handler ########## PerlModule WebworkWebservice <Location /mod_xmlrpc> SetHandler perl-script PerlHandler Apache::XMLRPC::Lite PerlSetVar dispatch_to "WebworkXMLRPC" PerlSetVar options "compress_threshold => 10000" Order Allow,Deny Allow from All </Location>
IMPORTANT: The line defining the server url must be completed. It should appear
near the top of global.conf
and should be copied from global.conf.dist
if it does not.
$server_root_url = ""; # http://your.server.edu
Other changes, such as modifications to the password and to the name of the "daemon_course" associated with the external client editor are made in webwork2/lib/WeBWorK/ContentGenerator/renderViaXMLRPC.pm
. (These configuration lines may be moved to global.conf
at a later date.)
When working correctly a reboot of the apache server should print to the command line several messages specifying the location of the top directory (e.g. /opt/webwork/webwork2
) of the WeBWorK source code.
webwork.apache2-config: WeBWorK server is starting webwork.apache2-config: WeBWorK root directory set to /opt/webwork/webwork2 in webwork2/conf/webwork.apache2-config webwork.apache2-config: The following locations and urls are set in webwork2/conf/global.conf webwork.apache2-config: PG root directory set to /opt/webwork/pg webwork.apache2-config: WeBWorK server userID is wwadmin webwork.apache2-config: WeBWorK server groupID is wwdata webwork.apache2-config: The webwork url on this site is http://localhost/webwork2 WebworkWebservice: webwork_directory set to /opt/webwork/webwork2 via $WeBWorK::Constants::WEBWORK_DIRECTORY set in webwork.apache2-config