[system] / trunk / wwmoodle / wwassignment4 / moodle / mod / wwassignment / locallib.php Repository:
ViewVC logotype

View of /trunk/wwmoodle/wwassignment4/moodle/mod/wwassignment/locallib.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5926 - (download) (as text) (annotate)
Fri Oct 3 03:22:19 2008 UTC (11 years, 4 months ago) by gage
File size: 26552 byte(s)
corrected code updating events

    1 <?php
    2 global $CFG;
    3 require_once("$CFG->libdir/soap/nusoap.php");
    4 
    5 define('WWASSIGNMENT_DEBUG',0);
    6 
    7 
    8 //////////////////////////////////////////////////////////////////
    9 //Utility functions
   10 //////////////////////////////////////////////////////////////////
   11 
   12 /**
   13  * @desc  prints message to the apache log
   14  * @param string  message
   15 **/
   16 
   17 function debugLog($message) {
   18   if (WWASSIGNMENT_DEBUG) {
   19     error_log($message);
   20     var_dump($message);
   21   }
   22 }
   23 
   24 /** (reference from accesslib.php )
   25  * @desc  gets all the users assigned this role in this context or higher
   26  * @param int roleid (can also be an array of ints!)
   27  * @param int contextid
   28  * @param bool parent if true, get list of users assigned in higher context too
   29  * @param string fields - fields from user (u.) , role assignment (ra) or role (r.)
   30  * @param string sort  - sort from user (u.) , role assignment (ra) or role (r.)
   31  * @param bool gethidden - whether to fetch hidden enrolments too
   32  * @return array()
   33  */
   34 //function get_role_users($roleid, $context, $parent=false, $fields='', $sort='u.lastname ASC', $gethidden=true, $group='', $limitfrom='', $limitnum='') {
   35 
   36 
   37 /**
   38 * @desc Finds all of the users in the course
   39 * @param $courseid   -- the course id
   40 * @return record containing user information ( username, userid)
   41 */
   42 
   43 function _wwassignment_get_course_students($courseid) {
   44     debugLog("Begin get_course_students($courseid )");
   45     debugLog("courseID is ". print_r($courseid, true));
   46   $context = get_context_instance(CONTEXT_COURSE, $courseid);
   47   debugLog("context is ". print_r($context, true));
   48 
   49   $users = array();
   50   $roles_used_in_context = get_roles_used_in_context($context);
   51   //debugLog("roles used ". print_r($roles_used_in_context, true));
   52   foreach($roles_used_in_context as $role) {
   53     $roleid = $role->id;
   54     debugLog( "roleid should be 5 for a student $roleid");
   55     //debugLog(get_role_users($roleid, $context, true) );
   56     if ($new_users = get_role_users($roleid, $context, true) ) {
   57       $users = array_merge($users, $new_users );//FIXME a user could be liseted twice
   58     }
   59     debugLog("display users ".print_r($users,true));
   60   }
   61   debugLog("display users in course--on");
   62   debugLog("users again".print_r($users, true));
   63 
   64     debugLog("End get_course_students($courseid )");
   65   return $users;
   66 
   67 
   68 }
   69 
   70 //////////////////////////////////////////////////////////////////
   71 //EVENT CREATION AND DELETION
   72 //////////////////////////////////////////////////////////////////
   73 
   74 /**
   75 * @desc Creates the corresponding events for a wwassignment.
   76 * @param $wwsetname string The name of the set.
   77 * @param $wwassignmentid string The ID of the wwassignment record.
   78 * @param $opendate integer The UNIX timestamp of the open date.
   79 * @param $duedate integer The UNIX timestamp of the due date.
   80 * @return integer 0 on success. -1 on error.
   81 */
   82 function _wwassignment_create_events($wwsetname,$wwassignmentid,$opendate,$duedate) {
   83     error_log("enter create_events");
   84     global $COURSE;
   85     unset($event);
   86     $event->name = $wwsetname;
   87     $event->description = 'WeBWorK Set Event';
   88     $event->courseid = $COURSE->id;
   89     $event->groupid = 0;
   90     $event->userid = 0;
   91     $event->format = 1;
   92     $event->modulename = 'wwassignment';
   93     $event->visible  = 1;
   94     $event->name .= ' is Due.';
   95     $event->eventtype = 'due';
   96     $event->timestart = $duedate;
   97     $event->timeduration = 1;
   98 
   99     // error_log("adding a due event");
  100     $result = 0;
  101     if(!add_event($dueevent)) {
  102         $result = -1;
  103     }
  104     return $result;
  105 }
  106 
  107 
  108 /**
  109 * @desc Deletes all events relating to the wwassignment passed in.
  110 * @param $wwassignmentid integer The wwassignment ID.
  111 * @return integer 0 on success
  112 */
  113 function _wwassignment_delete_events($wwassignmentid) {
  114     if ($events = get_records_select('event', "modulename = 'wwassignment' and instance = '$wwassignmentid'")) {
  115         foreach($events as $event) {
  116                // error_log("deleting  event ".$event->id);
  117             delete_event($event->id);
  118         }
  119     }
  120     return 0;
  121 }
  122 
  123 //////////////////////////////////////////////////////////////////
  124 //Functions that ensure creation of WeBWorK Data
  125 //////////////////////////////////////////////////////////////////
  126 
  127 /**
  128 * @desc Checks whether a user exists in a WW course. If it doesnt creates the user using the currently logged in one.
  129 * @param $wwcoursename string The WW course.
  130 * @param $username string The username to check.
  131 * @param $permission string The permission the user needs if created.
  132 * @return string the new username.
  133 */
  134 function _wwassignment_mapcreate_user($wwcoursename,$username,$permission = '0') {
  135     $wwclient = new wwassignment_client();
  136     $exists = $wwclient->mapped_user($wwcoursename,$username);
  137     if($exists == -1) {
  138         global $USER;
  139         $tempuser = $USER;
  140         $newusername = $wwclient->create_user($wwcoursename,$tempuser,$permission);
  141         return $newusername;
  142     }
  143     return $username;
  144 }
  145 
  146 /**
  147 * @desc Checks whether a set exists for a user in a WW course. If it doesnt autocreates.
  148 * @param $wwcoursename string The WW course.
  149 * @param $wwusername string The WW user.
  150 * @param $wwsetname string The WW set.
  151 * @return integer 0.
  152 */
  153 function _wwassignment_mapcreate_user_set($wwcoursename,$wwusername,$wwsetname) {
  154     $wwclient = new wwassignment_client();
  155     $exists = $wwclient->mapped_user_set($wwcoursename,$wwusername,$wwsetname);
  156     if($exists == -1) {
  157         $wwclient->create_user_set($wwcoursename,$wwusername,$wwsetname);
  158     }
  159     return 0;
  160 }
  161 
  162 /**
  163 * @desc Makes sure that a user is logged in to WW.
  164 * @param $wwcoursename string The course to login to.
  165 * @param $wwusername string The user to login.
  166 * @return string The users key for WW.
  167 */
  168 function _wwassignment_login_user($wwcoursename,$wwusername) {
  169     $wwclient = new wwassignment_client();
  170     return $wwclient->login_user($wwcoursename,$wwusername,false);
  171 }
  172 
  173 ////////////////////////////////////////////////////////////////
  174 //functions that check mapping existance in the local db
  175 ////////////////////////////////////////////////////////////////
  176 /**
  177 @desc Find the id of the wwlink block class
  178 *@param none
  179 *@return  id
  180 */
  181 function _wwasssignment_wwlink_blockid() {
  182    $wwlink = get_record('block','name','wwlink');
  183    return $wwlink->id;
  184 }
  185 /**
  186 @desc Find the id of the wwassignment module class
  187 *@param none
  188 *@return  id
  189 */
  190 function _wwassignment_cmid() {
  191    $wwassignment = get_record('modules','name','wwassignment');
  192    return $wwassignment->id;
  193 }
  194 
  195 /**
  196 * @desc Finds the webwork course name from a moodle course id.
  197 * @param integer $courseid Moodle Course ID.
  198 * @param integer $silent whether to trigger an error message.
  199 * @return string the name of the webwork course on success and -1 on failure.
  200 */
  201 function _wwassignment_mapped_course($courseid,$silent = true) {
  202     $blockinstance = get_record('block_instance','blockid',
  203     _wwasssignment_wwlink_blockid(),
  204     'pageid',$courseid, 'pagetype','course-view');
  205     //error_log("block instance".print_r($blockinstance,true));
  206     $block_config = unserialize(base64_decode($blockinstance->configdata));
  207     //error_log("config_data ".print_r($block_config,true));
  208     if ( isset($block_config) &&  isset($block_config->webwork_link_id)  ) {
  209       return $block_config->webwork_link_id;
  210     }
  211 //     $wwassignmentbridge = get_record('wwassignment_bridge','course', $courseid);
  212 //     if((isset($wwassignmentbridge)) && (isset($wwassignmentbridge->webwork_course))) {
  213 //         return $wwassignmentbridge->webwork_course;
  214 //     }
  215 //     if(!$silent) {
  216 //         print_error('webwork_course_map_failure','wwassignment');
  217 //     }
  218     return -1;
  219 }
  220 
  221 /**
  222 * @desc Finds the webwork set name from a wwassignment id.
  223 * @param integer $wwassignmentid Moodle wwassignment ID.
  224 * @param integer $silent whether to trigger an error message.
  225 * @return string the name of the webwork set on success and -1 on failure.
  226 */
  227 function _wwassignment_mapped_set($wwassignmentid,$silent = true) {
  228     $wwassignment = get_record('wwassignment','id',$wwassignmentid);
  229     if((isset($wwassignment)) && (isset($wwassignment->webwork_set))) {
  230         return $wwassignment->webwork_set;
  231     }
  232     if(!$silent) {
  233         print_error('webwork_set_map_failure','wwassignment');
  234     }
  235     return -1;
  236 }
  237 
  238 ////////////////////////////////////////////////////////////////
  239 //functions that create links to the webwork site.
  240 ////////////////////////////////////////////////////////////////
  241 
  242 /**
  243 * @desc Returns URL link to a webwork course logging the user in.
  244 * @param string $webworkcourse The webwork course.
  245 * @param string $webworkset The webwork set.
  246 * @param string $webworkuser The webwork user.
  247 * @param string $key The key used to login the user.
  248 * @return URL.
  249 */
  250 function _wwassignment_link_to_edit_set_auto_login($webworkcourse,$webworkset,$username,$key) {
  251     return _wwassignment_link_to_course($webworkcourse) . "instructor/sets/$webworkset/?effectiveUser=$username&user=$username&key=$key";
  252 }
  253 
  254 
  255 /**
  256 * @desc Returns URL link to a webwork course logging the user in.
  257 * @param string $webworkcourse The webwork course.
  258 * @param string $webworkuser The webwork user.
  259 * @param string $key The key used to login the user.
  260 * @return URL.
  261 */
  262 function _wwassignment_link_to_instructor_auto_login($webworkcourse,$username,$key) {
  263     return _wwassignment_link_to_course($webworkcourse) . "instructor/?effectiveUser=$username&user=$username&key=$key";
  264 }
  265 
  266 /**
  267 * @desc Returns the URL link to a webwork course and a particular set logged in.
  268 * @param string $webworkcourse The webwork course.
  269 * @param string $webworkset The webwork set.
  270 * @param string $webworkuser The webwork user.
  271 * @param string $key The key used to login the user.
  272 * @return URL.
  273 */
  274 function _wwassignment_link_to_set_auto_login($webworkcourse,$webworkset,$webworkuser,$key) {
  275     return _wwassignment_link_to_set($webworkcourse,$webworkset) .  "?effectiveUser=$webworkuser&user=$webworkuser&key=$key";
  276 }
  277 
  278 /**
  279 * @desc Returns the URL link to a webwork course and a particular set.
  280 * @param string $webworkcourse The webwork course.
  281 * @param string $webworkset The webwork set.
  282 * @return URL.
  283 */
  284 function _wwassignment_link_to_set($webworkcourse,$webworkset) {
  285     return _wwassignment_link_to_course($webworkcourse) . "$webworkset/";
  286 }
  287 
  288 /**
  289 * @desc Returns the URL link to a webwork course.
  290 * @param string $webworkcourse The webwork course.
  291 * @return URL.
  292 */
  293 function _wwassignment_link_to_course($webworkcourse) {
  294     global $CFG;
  295     return $CFG->wwassignment_webworkurl."/$webworkcourse/";
  296 }
  297 
  298 
  299 ///////////////////////////////////////////////////////////////
  300 //wwassignment client class
  301 ///////////////////////////////////////////////////////////////
  302 
  303 /**
  304 * @desc This singleton class acts as the gateway for all communication from the Moodle Client to the WeBWorK SOAP Server.
  305 * It encapsulates an instance of a SoapClient.
  306 */
  307 class wwassignment_client {
  308         var $client;
  309         var $defaultparams;
  310         var $datacache;
  311         var $mappingcache;
  312 
  313         /**
  314          * @desc Constructs a singleton webwork_client.
  315          */
  316         function wwassignment_client()
  317         {
  318             global $CFG;
  319             // static associative array containing the real objects, key is classname
  320             static $instances=array();
  321             // get classname
  322             $class = get_class($this);
  323             if (!array_key_exists($class, $instances)) {
  324                 // does not yet exist, save in array
  325                 $this->client = new soap_client($CFG->wwassignment_rpc_wsdl,'wsdl');
  326                 $err = $this->client->getError();
  327                 if ($err) {
  328                     error_log($err);
  329                     error_log($CFG->wwassignment_rpc_wsdl);
  330                     print_error('construction_error','wwassignment');
  331                 }
  332                 $this->defaultparams = array();
  333                 $this->defaultparams['authenKey']  = $CFG->wwassignment_rpc_key;
  334                 $this->datacache = array();
  335                 $this->mappingcache = array();
  336                 $instances[$class] = $this;
  337 
  338             }
  339             foreach (get_class_vars($class) as $var => $value) {
  340                 $this->$var =& $instances[$class]->$var;
  341             }
  342         }
  343 
  344         /**
  345          *@desc Calls a SOAP function and passes (authenkey,course) automatically in the parameter list.
  346          *@param string $functioncall The function to call
  347          *@param array $params The parameters to the function.
  348          *@param integer $override=false whether to override the default parameters that are passed to the soap function (authenKey).
  349          *@return Result of the soap function.
  350          */
  351         function handler($functioncall,$params=array(),$override=false) {
  352                 if(!is_array($params)) {
  353                         $params = array($params);
  354                 }
  355                 if(!$override) {
  356                         $params = array_merge($this->defaultparams,$params);
  357                 }
  358                 if(WWASSIGNMENT_DEBUG) {
  359                     echo "Called: $functioncall <br>";
  360                     echo "Params: ";
  361                     var_dump($params);
  362                     echo "<br>";
  363                 }
  364                 $result = $this->client->call($functioncall,$params);
  365 
  366                 //$result = call_user_func_array(array(&$this->client,$functioncall),$params);
  367                 if($err = $this->client->getError()) {
  368                         //print_error(get_string("rpc_fault","wwassignment') . " " . $functioncall. " ". $err);
  369                         print_error('rpc_error','wwassignment');
  370                 }
  371                 return $result;
  372         }
  373 
  374         /**
  375         * @desc Checks whether a user is in a webwork course.
  376         * @param string $webworkcourse The webwork course name.
  377         * @param string $webworkuser The webwork user name.
  378         * @param integer $silent whether to trigger an error message
  379         * @return string Returns the webwork user on success and -1 on failure.
  380         */
  381         function mapped_user($webworkcourse,$webworkuser,$silent = true) {
  382             if(isset($this->mappingcache[$webworkcourse]['user'][$webworkuser])) {
  383                 return $this->mappingcache[$webworkcourse]['user'][$webworkuser];
  384             }
  385             $record = $this->handler('get_user',array('courseName' => $webworkcourse,'userID' => $webworkuser));
  386             if($record != -1) {
  387                 $this->mappingcache[$webworkcourse]['user'][$webworkuser] = $webworkuser;
  388                 return $webworkuser;
  389             }
  390             if(!$silent) {
  391                 print_error('webwork_user_map_failure',"wwassignment");
  392             }
  393             return -1;
  394         }
  395 
  396         /**
  397         * @desc Checks whether a user has his own copy of a set built in a webwork course.
  398         * @param string $webworkcourse The webwork course name.
  399         * @param string $webworkuser The webwork user name.
  400         * @param string $webworkset The webwork set name.
  401         * @param integer $silent whether to trigger an error message
  402         * @return integer Returns 1 on success and -1 on failure.
  403         */
  404         function mapped_user_set($webworkcourse,$webworkuser,$webworkset,$silent = true) {
  405             if(isset($this->mappingcache[$webworkcourse]['user_set'][$webworkuser][$webworkset])) {
  406                 return $this->mappingcache[$webworkcourse]['user_set'][$webworkuser][$webworkset];
  407             }
  408             $record = $this->handler('get_user_set',array('courseName' => $webworkcourse,'userID' => $webworkuser,'setID' => $webworkset));
  409             if($record != -1) {
  410                 $this->mappingcache[$webworkcourse]['user_set'][$webworkuser][$webworkset] = 1;
  411                 return 1;
  412             }
  413 
  414             if(!$silent) {
  415                 print_error('webwork_user_set_map_failure','wwassignment');
  416             }
  417             return -1;
  418         }
  419 
  420         /**
  421         * @desc Gets the record of the global set for a webwork course and set name.
  422         * @param string $webworkcourse The webwork course name.
  423         * @param string $webworkset The webwork set name.
  424         * @param integer $silent whether to trigger an error message
  425         * @return array Returns set information on success or -1 on failure.
  426         */
  427         function get_assignment_data($webworkcourse,$webworkset,$silent = true) {
  428             $record = $this->handler('get_global_set',array('courseName' => $webworkcourse, 'setID' => $webworkset));
  429             if(isset($record)) {
  430                 $setinfo = array();
  431                 $setinfo['open_date'] = $record['open_date'];
  432                 $setinfo['due_date'] = $record['due_date'];
  433                 $setinfo['set_id'] = $record['set_id'];
  434                 $setinfo['name'] = $record['set_id'];
  435                 return $setinfo;
  436             }
  437             if(!$silent) {
  438                 print_error('webwork_set_map_failure','wwassignment');
  439             }
  440             return -1;
  441 
  442         }
  443 
  444         /**
  445         * @desc Gets all the user problems for a specfic course, user and set.
  446         * @param string $webworkcourse The webwork course name.
  447         * @param string $webworkuser The webwork users name.
  448         * @param string $webworkset The webwork set name.
  449         * @param integer $silent whether to trigger an error message
  450         * @return array Returns an array of problems on success or -1 on failure.
  451         */
  452         function get_user_problems($webworkcourse,$webworkuser,$webworkset,$silent = true) {
  453             $record = $this->handler('get_all_user_problems',array('courseName' => $webworkcourse,'userID' => $webworkuser,'setID' => $webworkset));
  454             if(isset($record)) {
  455                 return $record;
  456             }
  457             if(!$silent) {
  458                 print_error('webwork_user_set_map_failure','wwassignment');
  459             }
  460             return -1;
  461         }
  462 
  463         /**
  464         * @desc Calculates the max grade on a set by counting the number of problems in the set.
  465         * @param string $webworkcourse The webwork course name.
  466         * @param string $webworkset The webwork set name.
  467         * @param integer $silent whether to trigger an error message
  468         * @return integer The max grade on success or -1 on failure.
  469         */
  470         //FIXME -- this assumes each problem gets 1 point which is false
  471         function get_max_grade($webworkcourse,$webworkset,$silent = true) {
  472             $record = $this->handler('list_global_problems',array('courseName' => $webworkcourse,'setID' => $webworkset));
  473             if(isset($record)) {
  474                 return count($record);
  475             }
  476             if(!$silent) {
  477                 print_error('webwork_set_map_failure','wwassignment');
  478             }
  479             return -1;
  480 
  481         }
  482         /**
  483         * @desc Forces a login of a user into a course.
  484         * @param string $webworkcourse The webwork course name.
  485         * @param string $webworkuser The webwork users name.
  486         * @param integer $silent whether to trigger an error message
  487         * @return string The webwork key for URL on success or -1 on failure.
  488         */
  489         function login_user($webworkcourse,$webworkuser,$silent = true) {
  490             $key = $this->handler('login_user',array('courseName' => $webworkcourse,'userID' => $webworkuser));
  491             if(isset($key)) {
  492                 return $key;
  493             }
  494             if(!$silent) {
  495                 print_error('webwork_user_map_failure','wwassignment');
  496             }
  497             return -1;
  498         }
  499 
  500         /**
  501         * @desc Retrieves a list of sets from a webwork course and converts it into form options format.
  502         * @param string $webworkcourse The webwork course name.
  503         * @param integer $silent whether to trigger an error message
  504         * @return array The form options.
  505         */
  506         function options_set($webworkcourse,$silent = true) {
  507             $setlist = $this->handler('list_global_sets',array('courseName' => $webworkcourse));
  508             if(isset($setlist)) {
  509                 $setoptions = array();
  510                 foreach($setlist as $setid) {
  511 
  512                     $setoptions[$setid] = $setid;
  513                 }
  514                 return $setoptions;
  515             }
  516             if(!$silent) {
  517                 print_error('webwork_course_map_failure','wwassignment');
  518             }
  519             return -1;
  520         }
  521 
  522         /**
  523         * @desc Retrieves a list of courses from a webwork course and converts it into form options format.
  524         * @param integer $silent whether to trigger an error message
  525         * @return array The form options.
  526         */
  527         function options_course($silent = true) {
  528             $courselist = $this->handler('list_courses');
  529             sort($courselist);
  530             if(isset($courselist)) {
  531                 $courseoptions = array();
  532                 foreach($courselist as $course) {
  533                     $courseoptions[$course] = $course;
  534                 }
  535                 return $courseoptions;
  536             }
  537             if(!$silent) {
  538                 print_error('webwork_course_list_map_failure','wwassignment');
  539             }
  540             return -1;
  541 
  542         }
  543 
  544         /**
  545         * @desc Creates a user in the WeBWorK course.
  546         * @param string $webworkcourse The webwork course name.
  547         * @param array $userdata The user data to use in creation.
  548         * @param string $permission The permissions of the new user, defaults to 0.
  549         * @return Returns 1 on success.
  550         */
  551         function create_user($webworkcourse,&$userdata,$permission='0') {
  552             $studentid = $userid;
  553             # FIXME:  find permission for this user and set permissions appropriately in webwork
  554             # FIXME:  find the group(s)  that this person is a member of
  555             # FIXME:  I have used the following scheme:  gage_SEC  use groups ending like this to determine sections in webwork
  556             # FIXME:  use ordinary groups   taName    to correspond to recitation sections in WeBWorK
  557             #
  558             # FIXME:  make it so an update_user function is called whenever the user data in moodle is changed
  559             # FIXME:  so if a student switches groups this is reflected in WeBWorK
  560             $this->handler('add_user',array('courseName' => $webworkcourse, 'record' => array(
  561                 'user_id' => $userdata->username,
  562                 'first_name' => $userdata->firstname,
  563                 'last_name' => $userdata->lastname,
  564                 'email_address' => $userdata->email,
  565                 'student_id' => $studentid,
  566                 'status' => 'C',
  567                 'section' => '',
  568                 'recitation' => '',
  569                 'comment' => 'moodle created user')));
  570             $this->handler('add_permission',array('courseName' => $webworkcourse,'record' => array(
  571                 'user_id' => $userdata->username,
  572                 'permission' => $permission)));
  573             $this->handler('add_password',array('courseName' => $webworkcourse,'record' => array(
  574                 'user_id' => $userdata->username,
  575                 'password' => $userdata->password)));
  576             return 1;
  577         }
  578        /**  NOT yet ready!!!!!!!!!
  579         * @desc Updates data for a user in the WeBWorK course.
  580         * @param string $webworkcourse The webwork course name.
  581         * @param array $userdata The user data to use in creation.
  582         * @param string $permission The permissions of the new user, defaults to 0.
  583         * @return Returns 1 on success.
  584         */
  585         function update_user($webworkcourse,&$userdata,$permission='0') {
  586             error_log("update_user called -- not yet ready");
  587             $studentid = $userid;
  588             # FIXME:  find permission for this user and set permissions appropriately in webwork
  589             # FIXME:  find the group(s)  that this person is a member of
  590             # FIXME:  I have used the following scheme:  gage_SEC  use groups ending like this to determine sections in webwork
  591             # FIXME:  use ordinary groups   taName    to correspond to recitation sections in WeBWorK
  592             #
  593             # FIXME:  make it so an update_user function is called whenever the user data in moodle is changed
  594             # FIXME:  so if a student switches groups this is reflected in WeBWorK
  595             # do get_user first to get current status then update this??
  596             $this->handler('put_user',array('courseName' => $webworkcourse, 'record' => array(
  597                 //'user_id' => $userdata->username,  // can't update this
  598                 'first_name' => $userdata->firstname,
  599                 'last_name' => $userdata->lastname,
  600                 'email_address' => $userdata->email,
  601                 'student_id' => $studentid,
  602                 //'status' => 'C',  //can you update this from moodle?
  603                 'section' => '',
  604                 'recitation' => '',
  605                 'comment' => 'moodle updated user')));
  606             $this->handler('add_permission',array('courseName' => $webworkcourse,'record' => array(
  607                 'user_id' => $userdata->username,
  608                 'permission' => $permission)));
  609             $this->handler('add_password',array('courseName' => $webworkcourse,'record' => array(
  610                 'user_id' => $userdata->username,
  611                 'password' => $userdata->password)));
  612             return 1;
  613         }
  614         /**
  615         * @desc Creates a user set in WeBWorK
  616         * @param string $webworkcourse The webwork course name.
  617         * @param string $webworkuser The webwork user name.
  618         * @param string $webworkset The webwork set name.
  619         * @return Returns 1 on success.
  620         */
  621         function create_user_set($webworkcourse,$webworkuser,$webworkset) {
  622             $this->handler('assign_set_to_user',array('courseName' => $webworkcourse,'userID' => $webworkuser, 'setID' => $webworkset));
  623             return 1;
  624         }
  625 
  626         /**
  627         * @desc Finds grades of many users for one set.
  628         * @param string $webworkcourse The webwork course name.
  629         * @param array $webworkusers A list of webwork users
  630         * @param string $webworkset The webwork set name
  631         * @return array Returns an array of grades
  632         */
  633         function grade_users_sets($webworkcourse,$webworkusers,$webworkset) {
  634             return $this->handler('grade_users_sets',array('courseName' => $webworkcourse, 'userIDs' => $webworkusers, 'setID' => $webworkset));
  635         }
  636 };
  637 ?>

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9