OutOfMonkeyland Tutorial

Home Tutorial Download

1 System requirements

The module should work in any operating system where perl is supported. The modules HTTP and LWP are needed in order for OutOfMonkeyland to work.

2 Installation

In order to install the module the latest module source from sourceforge. After this the procedure is the same than for any perl module. If you are using GNU/Linux, uncompress the downloaded file and then the following commands should install it

perl Makefile.PL
make
make install

If you are using a different operating system, look for the documentation of how to install a perl module.

3 How to get help

You can get help about the module running

perldoc OutOfMonkeyland

4 Getting started

Like any other perl module you will need the following line in order to use it

use OutOfMonkeyland qw(:all);

In many of the functions described in this document you will see the following variables as parameters of functions:

  • root_url This is the url of the main page of your WeBWork site. It is the one with the list of courses in it.
  • course_id The Id of the course you want the function to work on. You can copy and paste the name from the courses menu in the root_url.
  • username and password are a username and password within your WeBWork site with enough privileges to make the changes you want to do with the function you are using.

4.1 Selecting a cookies file

WeBWork stores cookies in your computer for authentication purposes. So, the first thing to do is to choose a file where the cookies are going to be stored. This can be done with the function set_cookies_file as follows

set_cookies_file("path-to-file");

If you do not call this function, the default value of the cookies file is /tmp/cookies.txt. Which will work fine in GNU/Linux but not in other operating systems. So, on Windows or MAC you will have to call this function and select a cookies file.

If the file does not exist already it will be created. If the file already exists it is going to re-write it.

4.2 Setting the number of trials

Sometimes there are problems with the connection ir with the server. Many of the functions in this library try several times to perform an action before flagging an error. The number of trials by default is three. If you would like to change this there is the function set_number_of_trials.

set_number_of_trials(10);

This would change the number of trials to 10. You can use any positive integer instead of 10.

4.3 Creating a course

The function create_course can be used to create a new course. It should be called in the following way

create_course(root_url,
              course_id,
              username,
              password,
              course_title,
              institution_name,
              initial_user_id,
              password,
              first_name,
              last_name,
              email,
              template_course,
              database_layout);

All the parameters should be passed as a string. Each of the parameters that appear in this function correspond to the ones that are asked for you when you click the Add course link in the course administration of WeBWork.

database_layout is optional. If it is not given, the value "sql_single" is assumed.

4.4 Deleting, archiving or unarchiving a course

There are functions for deleting, archiving and unarchiving. They all receive the same arguments.

delete_course(root_url,course_id,username,password);
archive_course(root_url,course_id,username,password);
unarchive_course(root_url,course_id,username,password);

Please notice that archive_course will rewrite existing archived courses with the same name.

4.5 Putting a file in the file manager

You can do this by calling the function

put_file_on_file_manager(root_url,course_id,username,password,file_to_upload)

file_to_upload should be a string with the path of a file that you want to put in the file manager.

4.6 Import students

The following function

import_students(root_url,course_id,username,password,filename,replace_students)

imports students from a existing .lst file from the file manager. filename is the name of the .lst file. If $replace_students is true, it will import the students with the option "replacing any existing users and adding any new users". If it is false, it will replace no existing users. It this variable is not given it will be considered false.

4.7 Assign all assignments

This

assign_all_assignments(root_url,course_id,username,password)

will assign all the existing assignments to the students registered in the course.

4.8 Send e-mail to students in a specific recitation

send_email(root_url,
           course_id,
           username,
           password,
           recitation,
           email_text,
           main_email,
           response_file)

This will send an e-mail with the students in the given recitation. main_email is an e-mail is an e-mail where students having problems logging in can write to get help. email_text can contain the variables that are recognized by WeBWork (like FN, LOGIN, SID, etc), and it can also contain the variable $course_id, that has the name of the course. Thus an example of a valid value for email_text is

'Dear $FN,

   You can access WeBWork at

   https://university.com/webwork/$course_id/.

   Your login information is:
   user: $LOGIN
   password: $SID

Best Regards,

   The WeBWork team.'

The variable response_file is optional. If it is given, it should be a filename. The answer from WeBWork of the request will be written in this file. This can be used to check if the e-mail was actually send. This file can be opened with a browser in order to see it nicely formatted.

4.9 Import assignments

import_assignments(root_url,course_id,username,password,assignment_lists)

This function imports assignments to the course. It works with assignments that are already in the importer. The value of assignment_lists should be a referenced lists with the names of the assignments to be imported, e.g. ["Assignment-1.def","Assignment-2.def","Assignment-3.def"].

4.10 Get assignments list

The following function

get_all_assignments(root_url,course_id,username,password)

returns an array with the names of all the assignments in the course.

4.11 Set dates

The following function

set_dates(root_url,course_id,username,password,assignments_and_dates)

can be used to set the dates of a course.dates should be a reference to an array. Each element of the array should be another reference to an array that has the form: ["Assignment name","open date","due date","answer date"]. This function will set the dates for each assignment

4.12 Download grades

download_grades(root_url,course_id,username,password,filename,avoid_pattern)

This function downloads the grades from $courseid to the file $filename. $avoid_pattern is a regular expression for those sets one does not want to download. If avoidpattern is not given it will download grades for all the sets.

4.13 Output

It is possible to tell the program to add the messages to a queue from the library Thread::Queue instead of the standard output. To do this there is the function set_messages_queue.

set_messages_queue(queue);

where queue is a Thread::Queue object. When this function is called the output messages will be passed to queue instead of being printed on the standard output.

5 Example script

The following script is an example of use. Here it is assumed that there is a file in your computer /home/user/webwork/student_list_math101.lst with the students list with recitation name 1st. The script will create a new course called math101_Fall_2014 that will copy a template from the course math101_Fall_2013. Then it will upload the list of students, it will import the assignments, will assign them and will send an e-mail to all the students in the given recitation with their login information.

use strict;
use warnings;
use OutOfMonkeyland qw(:all); 

my $root_url='https://university.com/webwork/';
my $recitation="1th";
my $main_email='webwork@university.com';
my $email_text='Dear $FN,

   You can access WeBWork at

   https://university.com/webwork/$course_id/.

   Your login information is:
   user: $LOGIN
   password: $SID

Best Regards,

   The WeBWork team.';


create_course("$root_url",
              "math101_Fall_2014",
              "admin",
              "password",
              "matht101",
              "University",
              "admin_math101",
              "password_math201",
              "Webwork",
              "TA",
              $main_email,
              "math101_Fall_2013");

# This will create the course math101_Fall_2014 copying the existing course math101_Fall_2013


put_file_on_file_manager("$root_url",
                         "math101_Fall_2014",
                         "admin_math101",
                         "password_math201",
                         "/home/user/webwork/student_list_math101.lst");
# This will add to the file manager the lst file student_list_math101.lst

import_assignments("$root_url",
                   "math101_Fall_2014",
                   "admin_math101",
                   "password_math201",
                   ["Assignment-1.def","Assignment-2.def","Assignment-3.def"]);
# This will import 3 the assignments with names Assignment-1, Assignment-2 and Assignment-3
# These three assignments are in the importer because they are also in the course from the previous year.

import_students("$root_url",
                "math101_Fall_2014",
                "admin_math101",
                "password_math201",
                "student_list_math101.lst");
# This will import students from the file  student_list_math101.lst that has been already uploaded to the file manager.

assign_all_assignments("$root_url",
                       "math101_Fall_2014",
                       "admin_math101",
                       "password_math201");
# This will assign all the assignments to all the students that have been imported.

send_email("$root_url",
           "math101_Fall_2014",
           "admin_math101",
           "password_math201",
           "1st",
           $email_text,
           $main_email,
           "sent_email.html");
# This will send an e-mail to all the students in the first recitation.

Author: Oscar Alberto Quijano Xacur(qxacur@use.startmail.com)

Date: 2015-09-07

Emacs 24.4.1 (Org mode 8.2.10)

Validate