You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(53) |
Feb
(56) |
Mar
|
Apr
|
May
(30) |
Jun
(78) |
Jul
(121) |
Aug
(155) |
Sep
(77) |
Oct
(61) |
Nov
(45) |
Dec
(94) |
2006 |
Jan
(116) |
Feb
(33) |
Mar
(11) |
Apr
(23) |
May
(60) |
Jun
(89) |
Jul
(130) |
Aug
(109) |
Sep
(124) |
Oct
(63) |
Nov
(82) |
Dec
(45) |
2007 |
Jan
(31) |
Feb
(35) |
Mar
(123) |
Apr
(36) |
May
(18) |
Jun
(134) |
Jul
(133) |
Aug
(241) |
Sep
(126) |
Oct
(31) |
Nov
(15) |
Dec
(5) |
2008 |
Jan
(11) |
Feb
(6) |
Mar
(16) |
Apr
(29) |
May
(43) |
Jun
(149) |
Jul
(27) |
Aug
(29) |
Sep
(37) |
Oct
(20) |
Nov
(4) |
Dec
(6) |
2009 |
Jan
(34) |
Feb
(30) |
Mar
(16) |
Apr
(6) |
May
(1) |
Jun
(32) |
Jul
(22) |
Aug
(7) |
Sep
(18) |
Oct
(50) |
Nov
(22) |
Dec
(8) |
2010 |
Jan
(17) |
Feb
(15) |
Mar
(10) |
Apr
(9) |
May
(67) |
Jun
(30) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
From: Matt L. v. a. <we...@ma...> - 2007-09-25 02:27:00
|
Log Message: ----------- Better errors Modified Files: -------------- wwmoodle/wwassignment3/moodle/lang/en_utf8: wwassignment.php Revision Data ------------- Index: wwassignment.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8/wwassignment.php,v retrieving revision 1.2 retrieving revision 1.3 diff -Lwwassignment3/moodle/lang/en_utf8/wwassignment.php -Lwwassignment3/moodle/lang/en_utf8/wwassignment.php -u -r1.2 -r1.3 --- wwassignment3/moodle/lang/en_utf8/wwassignment.php +++ wwassignment3/moodle/lang/en_utf8/wwassignment.php @@ -44,10 +44,13 @@ //ERRORS -$string['construction_error'] = 'An error occured in the connection to the WeBWorK server. Perhaps you have your wsdl path set wrong?'; +$string['construction_error'] = 'An error occured in establishing the connection to WeBWorK.<br>The most likely cause of this problem is that your WSDL path is incorrect.'; + $string['event_creation_error'] = 'wwassignment event could not be created.'; $string['webwork_course_list_map_failure'] = 'Could not retrieve a list of courses on the current WeBWorK server.'; -$string['webwork_course_map_failure'] = 'No WeBWorK course is mapped to the current Moodle course.'; + +$string['webwork_course_map_failure'] = 'No WeBWorK course is linked to this course.<br>Use the WWLink block to create a connection between this Moodle course and a WeBWorK course.'; + $string['webwork_set_map_failure'] = 'No WeBWorK problem set is mapped to the current Moodle problem set.'; $string['webwork_user_map_failure'] = 'No WeBWorK user is mapped to the current Moodle user.'; $string['webwork_user_set_map_failure'] = 'The WeBWorK user does not have the current Moodle set assigned.'; |
From: Matt L. v. a. <we...@ma...> - 2007-09-25 02:26:29
|
Log Message: ----------- Added Events Modified Files: -------------- wwmoodle/wwassignment3/moodle/mod/wwassignment: config.html locallib.php mod_form.php view.php Revision Data ------------- Index: mod_form.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/mod_form.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/mod_form.php -Lwwassignment3/moodle/mod/wwassignment/mod_form.php -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/mod_form.php +++ wwassignment3/moodle/mod/wwassignment/mod_form.php @@ -1,17 +1,18 @@ <?php require_once ('moodleform_mod.php'); -require_once ('lib.php'); +require_once ('locallib.php'); class mod_wwassignment_mod_form extends moodleform_mod { function definition() { - global $COURSE; + global $COURSE,$USER; $mform =& $this->_form; //Is this particular course mapped to a course in WeBWorK - $wwclient = new webwork_client(); + $wwclient = new wwassignment_client(); $wwcoursename = _wwassignment_mapped_course($COURSE->id,false); $wwsetname = _wwassignment_mapped_set($this->_instance); + $wwusername = $USER->username; //create the instructor if necessary $wwusername = _wwassignment_mapcreate_user($wwcoursename,$wwusername,'10'); @@ -28,6 +29,12 @@ //we are doing an update, since an id exists in moodle db $wwsetlink = _wwassignment_link_to_edit_set_auto_login($wwcoursename,$wwsetname,$wwusername,$wwkey); $mform->addElement('link','edit_set',get_string('edit_set_link_desc','wwassignment'),$wwsetlink,get_string('edit_set_link_name','wwassignment')); + $wwsetdata = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); + + $opendate = strftime("%c", $wwsetdata['open_date']); + $duedate = strftime("%c", $wwsetdata['due_date']); + $mform->addElement('static','opendate','WeBWorK Set Open Date',$opendate); + $mform->addElement('static','duedate','WeBWorK Set Due Date',$duedate); } //define the mapping Index: view.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/view.php,v retrieving revision 1.2 retrieving revision 1.3 diff -Lwwassignment3/moodle/mod/wwassignment/view.php -Lwwassignment3/moodle/mod/wwassignment/view.php -u -r1.2 -r1.3 --- wwassignment3/moodle/mod/wwassignment/view.php +++ wwassignment3/moodle/mod/wwassignment/view.php @@ -4,7 +4,7 @@ */ require_once("../../config.php"); -require_once("lib.php"); +require_once("locallib.php"); $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or $a = optional_param('a', 0, PARAM_INT); // NEWMODULE ID Index: config.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/config.html,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/config.html -Lwwassignment3/moodle/mod/wwassignment/config.html -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/config.html +++ wwassignment3/moodle/mod/wwassignment/config.html @@ -0,0 +1,56 @@ +<?php +// $Id$ + + if( empty($CFG->wwassignment_webworkurl) ) { + $CFG->wwassignment_webworkurl = "HOSTNAME/webwork2"; + } + if( empty($CFG->wwassignment_iframewidth) ) { + $CFG->wwassignment_iframewidth = "95%"; + } + if( empty($CFG->wwassignment_iframeheight) ) { + $CFG->wwassignment_iframeheight = "500px"; + } + if( empty($CFG->wwassignment_rpc_wsdl) ) { + $CFG->wwassignment_rpc_wsdl = "HOSTNAME/webwork2_wsdl"; + } + if( empty($CFG->wwassignment_rpc_key) ) { + $CFG->wwassignment_rpc_key = ""; + } +?> +<form method="post" action="module.php" name="form"> + <input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>"> + <table cellpadding="9" cellspacing="0"> + <tr valign='top'> + <td align="right"><label for='wwassignment_webworkurl'><b>wwassignment_webworkurl:</b></label></td> + <td><input type='text' name='wwassignment_webworkurl' id='wwassignment_webworkurl' value="<?php p($CFG->wwassignment_webworkurl); ?>" size="30" /></td> + <td><?php print_string('webwork_url', 'wwassignment'); ?></td> + </tr> + + <tr valign='top'> + <td align='right'><label for='wwassignment_iframewidth'><b>wwassignment_iframewidth:</b></label></td> + <td><input type='text' name='wwassignment_iframewidth' id='wwassignment_iframewidth' value="<?php p($CFG->wwassignment_iframewidth); ?>" size="30" /></td> + <td><?php print_string('iframe_width', 'wwassignment'); ?></td> + </tr> + <tr valign='top'> + <td align='right'><label for='wwassignment_iframeheight'><b>wwassignment_iframeheight:</b></label></td> + <td><input type='text' name='wwassignment_iframeheight' id='wwassignment_iframeheight' value="<?php p($CFG->wwassignment_iframeheight); ?>" size="30" /></td> + + <td><?php print_string('iframe_height', 'wwassignment'); ?></td> + </tr> + <tr valign='top'> + <td align='right'><label for='wwassignment_rpc_wsdl'><b>wwassignment_rpc_wsdl:</b></label></td> + <td><input type='text' name='wwassignment_rpc_wsdl' id='wwassignment_rpc_wsdl' value="<?php p($CFG->wwassignment_rpc_wsdl); ?>" size="30" /></td> + <td><?php print_string('rpc_wsdl', 'wwassignment'); ?></td> + </tr> + <tr valign='top'> + + <td align='right'><label for='wwassignment_rpc_key'><b>wwassignment_rpc_key:</b></label></td> + <td><input type='text' name='wwassignment_rpc_key' id='wwassignment_rpc_key' value="<?php p($CFG->wwassignment_rpc_key); ?>" size="30" /></td> + <td><?php print_string('rpc_key', 'wwassignment'); ?></td> + </tr> + <tr> + <td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges") ?>" /></td> + </tr> + </table> + +</form> Index: locallib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/locallib.php,v retrieving revision 1.2 retrieving revision 1.3 diff -Lwwassignment3/moodle/mod/wwassignment/locallib.php -Lwwassignment3/moodle/mod/wwassignment/locallib.php -u -r1.2 -r1.3 --- wwassignment3/moodle/mod/wwassignment/locallib.php +++ wwassignment3/moodle/mod/wwassignment/locallib.php @@ -2,6 +2,8 @@ require_once("$CFG->libdir/soap/nusoap.php"); +define(WWASSIGNMENT_DEBUG,1); + ////////////////////////////////////////////////////////////////// //EVENT CREATION AND DELETION ////////////////////////////////////////////////////////////////// @@ -15,14 +17,17 @@ * @return integer 0 on success. -1 on error. */ function _wwassignment_create_events($wwsetname,$wwassignmentid,$opendate,$duedate) { + global $COURSE; unset($event); $event->name = $wwsetname; - $openevent->description = ''; + $event->description = 'WeBWorK Set Event'; $event->courseid = $COURSE->id; $event->groupid = 0; $event->userid = 0; + $event->format = 1; $event->modulename = 'wwassignment'; $event->instance = $wwassignmentid; + $event->visible = 1; $openevent = $event; $dueevent = $event; @@ -37,6 +42,7 @@ $dueevent->timestart = $duedate; $dueevent->timeduration = 1; + $result = 0; if(!add_event($openevent)) { $result = -1; @@ -128,7 +134,7 @@ return $wwassignmentbridge->webwork_course; } if(!$silent) { - print_error(get_string('webwork_course_map_failure','wwassignment')); + print_error('webwork_course_map_failure','wwassignment'); } return -1; } @@ -145,7 +151,7 @@ return $wwassignment->webwork_set; } if(!$silent) { - print_error(get_string('webwork_set_map_failure','wwassignment')); + print_error('webwork_set_map_failure','wwassignment'); } return -1; } @@ -206,7 +212,8 @@ * @return URL. */ function _wwassignment_link_to_course($webworkcourse) { - return WWASSIGNMENT_WEBWORK_URL."/$webworkcourse/"; + global $CFG; + return $CFG->wwassignment_webworkurl."/$webworkcourse/"; } @@ -222,24 +229,26 @@ var $defaultparams; var $datacache; var $mappingcache; + /** * @desc Constructs a singleton webwork_client. */ function wwassignment_client() { + global $CFG; // static associative array containing the real objects, key is classname static $instances=array(); // get classname $class = get_class($this); if (!array_key_exists($class, $instances)) { // does not yet exist, save in array - $this->client = new soap_client(WWASSIGNMENT_WEBWORK_WSDL,'wsdl'); + $this->client = new soap_client($CFG->wwassignment_rpc_wsdl,'wsdl'); $err = $this->client->getError(); if ($err) { - print_error(get_string('construction_error','wwassignment')."<BR>$err"); + print_error('construction_error','wwassignment'); } $this->defaultparams = array(); - $this->defaultparams['authenKey'] = WWASSIGNMENT_WEBWORK_KEY; + $this->defaultparams['authenKey'] = $CFG->wwassignment_rpc_key; $this->datacache = array(); $this->mappingcache = array(); $instances[$class] = $this; @@ -248,7 +257,8 @@ foreach (get_class_vars($class) as $var => $value) { $this->$var =& $instances[$class]->$var; } - } + } + /** *@desc Calls a SOAP function and passes (authenkey,course) automatically in the parameter list. *@param string $functioncall The function to call @@ -263,11 +273,18 @@ if(!$override) { $params = array_merge($this->defaultparams,$params); } + if(WWASSIGNMENT_DEBUG) { + echo "Called: $functioncall <br>"; + echo "Params: "; + var_dump($params); + echo "<br>"; + } $result = $this->client->call($functioncall,$params); + //$result = call_user_func_array(array(&$this->client,$functioncall),$params); if($err = $this->client->getError()) { //print_error(get_string("rpc_fault","wwassignment') . " " . $functioncall. " ". $err); - print_error(get_string('rpc_error','wwassignment')."<BR>$err<BR><BR>Response:<BR>".$this->client->response ); + print_error('rpc_error','wwassignment'); } return $result; } @@ -289,7 +306,7 @@ return $webworkuser; } if(!$silent) { - print_error(get_string('webwork_user_map_failure',"wwassignment")); + print_error('webwork_user_map_failure',"wwassignment"); } return -1; } @@ -313,7 +330,7 @@ } if(!$silent) { - print_error(get_string('webwork_user_set_map_failure','wwassignment')); + print_error('webwork_user_set_map_failure','wwassignment'); } return -1; } @@ -336,7 +353,7 @@ return $setinfo; } if(!$silent) { - print_error(get_string('webwork_set_map_failure','wwassignment')); + print_error('webwork_set_map_failure','wwassignment'); } return -1; @@ -356,7 +373,7 @@ return $record; } if(!$silent) { - print_error(get_string('webwork_user_set_map_failure','wwassignment')); + print_error('webwork_user_set_map_failure','wwassignment'); } return -1; } @@ -374,7 +391,7 @@ return count($record); } if(!$silent) { - print_error(get_string('webwork_set_map_failure','wwassignment')); + print_error('webwork_set_map_failure','wwassignment'); } return -1; @@ -392,7 +409,7 @@ return $key; } if(!$silent) { - print_error(get_string('webwork_user_map_failure','wwassignment')); + print_error('webwork_user_map_failure','wwassignment'); } return -1; } @@ -414,7 +431,7 @@ return $setoptions; } if(!$silent) { - print_error(get_string('webwork_course_map_failure','wwassignment')); + print_error('webwork_course_map_failure','wwassignment'); } return -1; } @@ -435,7 +452,7 @@ return $courseoptions; } if(!$silent) { - print_error(get_string('webwork_course_list_map_failure','wwassignment')); + print_error('webwork_course_list_map_failure','wwassignment'); } return -1; |
From: Matt L. v. a. <we...@ma...> - 2007-09-24 23:19:37
|
Log Message: ----------- Documentation Modified Files: -------------- wwmoodle/wwassignment3/moodle/lang/en_utf8: block_wwlink.php wwassignment.php Revision Data ------------- Index: wwassignment.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8/wwassignment.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/lang/en_utf8/wwassignment.php -Lwwassignment3/moodle/lang/en_utf8/wwassignment.php -u -r1.1 -r1.2 --- wwassignment3/moodle/lang/en_utf8/wwassignment.php +++ wwassignment3/moodle/lang/en_utf8/wwassignment.php @@ -0,0 +1,58 @@ +<?php +// $Id$ +// language strings for wwmoodle_set + +$string['modulename'] = "WeBWorK Problem Set"; +$string['modulenameplural'] = "WeBWorK Problem Sets"; + +$string['set_name'] = $string['modulename']; + +//index list +$string['open_date'] = "Opened"; +$string['due_date'] = "Due"; + +//viewing page +$string['go_to_webwork'] = "Administer the WeBWorK portion of this course."; +$string['iframeNoShow-1'] = "If you are unable to view this problem set, please "; +$string['iframeNoShow-2'] = "click here"; + +//Defining New Module without Block +$string['mainpage_link_desc'] = 'You need to create the webwork course mapping by creating a WeBWorK link block.'; +$string['mainpage_link_name'] = 'Course Page'; + +//Course Link form +$string['course_initialization'] = 'Linking to WeBWorK'; +$string['webwork_course'] = 'WeBWorK Course'; + +//Set Link form +$string['set_initialization'] = 'Linking to WeBWorK Problem Set'; +$string['wwassignmentname'] = 'Name'; +$string['webwork_set'] = 'WeBWorK Set'; +$string['instructor_page_link_desc'] = 'Link to the Instructor Section of WeBWorK'; +$string['instructor_page_link_name'] = 'Go To WeBWorK Instructor Tools'; + +$string['edit_set_link_desc'] = 'Link to Set Modification Section of WeBWorK'; +$string['edit_set_link_name'] = 'Modify Set'; + +//CONFIG +$string['webwork_url'] = "The URL location of webwork on the server. ex: http://www.example.org/webwork2"; +$string['iframe_width'] = "The width in percentage of the page of the iframe displaying WeBWorK problem sets."; +$string['iframe_height'] = "The height in pixels of the iframe displaying WeBWorK problem sets."; +$string['rpc_wsdl'] = "Path to the WSDL file on the host running WeBWorK."; +$string['rpc_key'] = "Key identifying Moodle to WeBWorK."; +$string['testchanges'] = "Test WeBWorK Connection."; + + +//ERRORS +$string['construction_error'] = 'An error occured in the connection to the WeBWorK server. Perhaps you have your wsdl path set wrong?'; +$string['event_creation_error'] = 'wwassignment event could not be created.'; +$string['webwork_course_list_map_failure'] = 'Could not retrieve a list of courses on the current WeBWorK server.'; +$string['webwork_course_map_failure'] = 'No WeBWorK course is mapped to the current Moodle course.'; +$string['webwork_set_map_failure'] = 'No WeBWorK problem set is mapped to the current Moodle problem set.'; +$string['webwork_user_map_failure'] = 'No WeBWorK user is mapped to the current Moodle user.'; +$string['webwork_user_set_map_failure'] = 'The WeBWorK user does not have the current Moodle set assigned.'; +$string['rpc_error'] = 'Communication error between the Moodle client and WeBWorK server.'; + + + +?> \ No newline at end of file Index: block_wwlink.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8/block_wwlink.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/lang/en_utf8/block_wwlink.php -Lwwassignment3/moodle/lang/en_utf8/block_wwlink.php -u -r1.1 -r1.2 --- wwassignment3/moodle/lang/en_utf8/block_wwlink.php +++ wwassignment3/moodle/lang/en_utf8/block_wwlink.php @@ -0,0 +1,11 @@ +<?php + +$string['blockname'] = 'WeBWorK Link'; +$string['webworklink'] = 'WeBWorK Link'; + +$string['config_select_webwork_course'] = 'Select WeBWorK Course'; + +$string['connected'] = 'Connected to WeBWorK Course:'; +$string['not_connected'] = 'Not Connected to WeBWorK'; + +?> |
From: Matt L. v. a. <we...@ma...> - 2007-09-24 22:57:58
|
Log Message: ----------- Code revision Added Files: ----------- wwmoodle/wwassignment3/moodle/mod/wwassignment/db: upgrade.php Revision Data ------------- --- /dev/null +++ wwassignment3/moodle/mod/wwassignment/db/upgrade.php @@ -0,0 +1,21 @@ +<?php + +function xmldb_wwassignment_upgrade($oldversion=0) { + + global $CFG, $THEME, $db; + + $result = true; + +/// And upgrade begins here. For each one, you'll need one +/// block of code similar to the next one. Please, delete +/// this comment lines once this file start handling proper +/// upgrade code. + +/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php +/// $result = result of "/lib/ddllib.php" function calls +/// } + + return $result; +} +?> + |
From: Matt L. v. a. <we...@ma...> - 2007-09-24 22:52:41
|
Log Message: ----------- Major code refactoring Modified Files: -------------- wwmoodle/wwassignment3/moodle/blocks/wwlink: block_wwlink.php config_instance.html Revision Data ------------- Index: config_instance.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/blocks/wwlink/config_instance.html,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/blocks/wwlink/config_instance.html -Lwwassignment3/moodle/blocks/wwlink/config_instance.html -u -r1.1 -r1.2 --- wwassignment3/moodle/blocks/wwlink/config_instance.html +++ wwassignment3/moodle/blocks/wwlink/config_instance.html @@ -0,0 +1,36 @@ +<?php + global $CFG; + $lib = $CFG->wwwroot . '/mod/wwassignment/locallib.php'; +?> +<table cellpadding="9" cellspacing="0" align="center"> + <?php if(!file_exists($lib)) { ?> + <tr valign="top"> + <td align="center"> + <?php echo '<strong>'.get_string('config_wwassigment_mod_missing','block_wwlink').'</strong>'; ?> + </td> + </tr> + <?php } else { ?> + <tr valign="top"> + + <td align="right"> + <?php print_string('config_select_webwork_course', 'block_wwlink'); ?> + </td> + <td align="center"> + <?php + require_once($lib); + $client = new wwassignment_client(); + $options = $client->options_course(true); + choose_from_menu($options,'webwork_link_id',empty($this->config->webwork_link_id) ? 0 : $this->config->webwork_link_id); + global $COURSE; + $courseid = $COURSE->id; + ?> + <input type="hidden" name="courseid" value="<?php echo $courseid;?>" /> + </td> + </tr> + <tr> + <td colspan="2" align="center"> + <input type="submit" value="<?php print_string('savechanges') ?>" /> + </td> + </tr> + <?php } ?> +</table> Index: block_wwlink.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/blocks/wwlink/block_wwlink.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/blocks/wwlink/block_wwlink.php -Lwwassignment3/moodle/blocks/wwlink/block_wwlink.php -u -r1.1 -r1.2 --- wwassignment3/moodle/blocks/wwlink/block_wwlink.php +++ wwassignment3/moodle/blocks/wwlink/block_wwlink.php @@ -0,0 +1,71 @@ +<?php + +/** +* @desc This block creates the tie between a Moodle course and a WeBWorK course +*/ +class block_wwlink extends block_base { + + /** + * @desc Sets the title of the block and the current version. + */ + function init() { + $this->title = get_string('blockname','block_wwlink'); + $this->version = 2007092100; + } + /** + * @desc Allows each instance of the block to have its own configuration settings. + */ + function instance_allow_config() { + return true; + } + + /** + * @desc Saves the form data from configuration into the wwassignment_bridge table. + */ + function instance_config_save($data) { + + $webworkcourse = $data->webwork_link_id; + $moodlecourse = $data->courseid; + + $wwassignmentbridge = new stdClass; + $wwassignmentbridge->course = $moodlecourse; + $wwassignmentbridge->webwork_course = $webworkcourse; + + //has this mapping been defined + $record = get_record('wwassignment_bridge','course',$moodlecourse); + if(!$record) { + //new one + insert_record('wwassignment_bridge',$wwassignmentbridge); + } else { + //update + $wwassignmentbridge->id = $record->id; + update_record('wwassignment_bridge',$wwassignmentbridge); + } + + return parent::instance_config_save($data); + } + + /** + * @desc Makes sure that the only place this block can be added is on course-view page. This insures one block per course. + */ + function applicable_formats() { + return array('all' => false, 'course-view' => true); + } + + /** + * @desc Prints the content of the block. Whether or not the course is connected to a moodle course. + */ + function get_content() { + global $COURSE; + + $courseid = $COURSE->id; + $record = get_record('wwassignment_bridge','course',$courseid); + if(!$record) { + $this->content->text = get_string('not_connected','block_wwlink'); + } else { + $this->content->text = get_string('connected','block_wwlink') . ' ' . $record->webwork_course; + } + return $this->content; + } +} +?> |
From: Matt L. v. a. <we...@ma...> - 2007-09-24 22:52:18
|
Log Message: ----------- Code refactoring Added Files: ----------- wwmoodle/wwassignment3/moodle/mod/wwassignment: mod_form.php Revision Data ------------- --- /dev/null +++ wwassignment3/moodle/mod/wwassignment/mod_form.php @@ -0,0 +1,57 @@ +<?php +require_once ('moodleform_mod.php'); +require_once ('lib.php'); + +class mod_wwassignment_mod_form extends moodleform_mod { + + function definition() { + global $COURSE; + $mform =& $this->_form; + + //Is this particular course mapped to a course in WeBWorK + $wwclient = new webwork_client(); + $wwcoursename = _wwassignment_mapped_course($COURSE->id,false); + $wwsetname = _wwassignment_mapped_set($this->_instance); + + //create the instructor if necessary + $wwusername = _wwassignment_mapcreate_user($wwcoursename,$wwusername,'10'); + + //login the instructor + $wwkey = _wwassignment_login_user($wwcoursename,$wwusername); + + $wwinstructorlink = _wwassignment_link_to_instructor_auto_login($wwcoursename,$wwusername,$wwkey); + + $mform->addElement('link','instructor_page_link',get_string('instructor_page_link_desc','wwassignment'),$wwinstructorlink,get_string('instructor_page_link_name','wwassignment')); + + + if($wwsetname != -1) { + //we are doing an update, since an id exists in moodle db + $wwsetlink = _wwassignment_link_to_edit_set_auto_login($wwcoursename,$wwsetname,$wwusername,$wwkey); + $mform->addElement('link','edit_set',get_string('edit_set_link_desc','wwassignment'),$wwsetlink,get_string('edit_set_link_name','wwassignment')); + } + + //define the mapping + $mform->addElement('header','set_initialization',get_string('set_initialization','wwassignment')); + + //name + $mform->addElement('text', 'name', get_string('wwassignmentname', 'wwassignment'), array('size'=>'64')); + $mform->setType('name', PARAM_TEXT); + $mform->addRule('name', null, 'required', null, 'client'); + + //set select + $options = $wwclient->options_set($wwcoursename,false); + $mform->addElement('select','webwork_set',get_string('webwork_set','wwassignment'),$options); + $mform->setHelpButton('webwork_set', array('webwork_set', get_string('webwork_set', 'wwassignment'), 'wwassignment')); + + //description + $mform->addElement('htmleditor', 'description', get_string('description', 'assignment')); + $mform->setType('description', PARAM_RAW); + $mform->setHelpButton('description', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton'); + + $this->add_action_buttons(); + $this->standard_hidden_coursemodule_elements(); + return; + } +} + +?> \ No newline at end of file |
From: Matt L. v. a. <we...@ma...> - 2007-09-24 22:51:43
|
Log Message: ----------- Major Code Refactoring Modified Files: -------------- wwmoodle/wwassignment3/moodle/mod/wwassignment: index.php lib.php locallib.php version.php view.php wwmoodle/wwassignment3/moodle/mod/wwassignment/db: install.xml wwmoodle/wwassignment3/moodle/mod/wwassignment/simpletest: testwwassignment.php Revision Data ------------- Index: version.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/version.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/version.php -Lwwassignment3/moodle/mod/wwassignment/version.php -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/version.php +++ wwassignment3/moodle/mod/wwassignment/version.php @@ -0,0 +1,11 @@ +<?php +// $Id$ +///////////////////////////////////////////////////////////////////////////////// +/// Code fragment to define the version of wwassignment +/// This fragment is called by moodle_needs_upgrading() and /admin/index.php +///////////////////////////////////////////////////////////////////////////////// + +$module->version = 2007092500; // The current module version (Date: YYYYMMDDXX) +$module->cron = 0; // Period for cron to check this module (secs) + +?> \ No newline at end of file Index: index.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/index.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/index.php -Lwwassignment3/moodle/mod/wwassignment/index.php -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/index.php +++ wwassignment3/moodle/mod/wwassignment/index.php @@ -0,0 +1,95 @@ +<?php +/** +* @desc This page lists all the instances of wwassignments within a particular course. +*/ + +require_once("../../config.php"); +require_once("locallib.php"); + +//get the course ID from GET line +$id = required_param('id', PARAM_INT); + +//check this course exists +if (!$course = get_record("course", "id", $id)) { + error("Course ID is incorrect"); +} + +//force login +require_login($course->id); +add_to_log($course->id, "wwassignment", "view all", "index.php?id=$course->id", ""); + +//Get all required strings +$strwwassignments = get_string("modulenameplural", "wwassignment"); +$strwwassignment = get_string("modulename", "wwassignment"); + +//Print the header +if ($course->category) { + $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> »"; +} +print_header("$course->shortname: $strwwassignments", "$course->fullname", "$navigation $strwwassignments", "", "", true, "", navmenu($course)); + +//Get all the appropriate data +if (!$wwassignments = get_all_instances_in_course("wwassignment", $course)) { + notice("There are no $strwwassignments", "../../course/view.php?id=$course->id"); + die; +} + +//Print the list of instances (your module will probably extend this) +$timenow = time(); +$strname = get_string("name"); +$strweek = get_string("week"); +$strtopic = get_string("topic"); +$strdescription = get_string('description'); +$stropendate = get_string("open_date", "wwassignment"); +$strduedate = get_string("due_date", "wwassignment"); + +if ($course->format == "weeks") { + $table->head = array ($strweek, $strname,$strdescription, $strOpenDate, $strDueDate); + $table->align = array ("center", "left", "left", "left", "left"); +} else if ($course->format == "topics") { + $table->head = array ($strtopic, $strname,$strdescription, $strOpenDate, $strDueDate); + $table->align = array ("center", "left", "left", "left", "left", "left", "left"); +} else { + $table->head = array ($strname,$strdescription, $strOpenDate, $strDueDate); + $table->align = array ("left", "left", "left", "left", "left", "left"); +} + +$wwclient = new wwassignment_client(); +$wwcoursename = _wwassignment_mapped_course($COURSE->id,false); + +foreach ($wwassignments as $wwassignment) { + // grab specific info for this set: + if(isset($wwassignment)) { + $wwsetname = $wwassignment->webwork_set; + $wwsetinfo = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); + + if (!$wwassignment->visible) { + //Show dimmed if the mod is hidden + $link = "<a class=\"dimmed\" href=\"view.php?id=$wwassignment->coursemodule\">$wwassignment->name</a>"; + } else { + //Show normal if the mod is visible + $link = "<a href=\"view.php?id=$wwassignment->coursemodule\">$wwassignment->name</a>"; + } + if ($course->format == "weeks" or $course->format == "topics") { + $table->data[] = array ($wwassignment->section, $link, $wwassignment->description, strftime("%c", $wwsetinfo['open_date']), strftime("%c", $wwsetinfo['due_date'])); + } else { + $table->data[] = array ($link, $wwassignment->description, strftime("%c", $wwsetinfo['open_date']), strftime("%c", $wwsetinfo['due_date'])); + } + } +} + +echo "<br />"; + +print_table($table); + +/*if( isteacher($course->id) ) { + $wwusername = $USER->username; + + $wwlink = _wwassignment_link_to_instructor_auto_login($wwcoursename,$wwusername,) + print("<p style='font-size: smaller; color: #aaa; text-align: center;'><a style='color: #666;text-decoration:underline' href='".WWASSIGNMENT_WEBWORK_URL."/$course->shortname/instructor' target='_webwork_edit'>".get_string("go_to_webwork", "wwassignment")."</a></p>"); +}*/ + +/// Finish the page +print_footer($course); + +?> Index: view.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/view.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/view.php -Lwwassignment3/moodle/mod/wwassignment/view.php -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/view.php +++ wwassignment3/moodle/mod/wwassignment/view.php @@ -0,0 +1,88 @@ +<?php +/** +* @desc Prints an actual wwassignment with an iframe to WeBWorK. +*/ + +require_once("../../config.php"); +require_once("lib.php"); + +$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or +$a = optional_param('a', 0, PARAM_INT); // NEWMODULE ID + +if($id) { + if (! $cm = get_record("course_modules", "id", $id)) { + error("Course Module ID was incorrect"); + } + + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); + } + if (! $wwassignment = get_record("wwassignment", "id", $cm->instance)) { + error("Course module is incorrect"); + } +} else { + + if (! $wwassignment = get_record("wwassignment", "id", $a)) { + error("Course module is incorrect"); + } + if (! $course = get_record("course", "id", $wwassignment->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("wwassignment", $wwassignment->id, $course->id)) { + error("Course Module ID was incorrect"); + } +} + +//catch the guests +global $USER; +if($USER->username == 'guest') { + print_error('Guests cannot view WeBWorK Problem Sets'); +} + +//force login +$courseid = $course->id; +$wwassignmentid = $wwassignment->id; +require_login($courseid); + +//webwork code +$wwcoursename = _wwassignment_mapped_course($courseid,false); +$wwusername = $USER->username; +$wwsetname = $wwassignment->webwork_set; +_wwassignment_mapcreate_user($wwcoursename,$wwusername); +_wwassignment_mapcreate_user_set($wwcoursename,$wwusername,$wwsetname); +$wwkey = _wwassignment_login_user($wwcoursename,$wwusername); +$wwsetlink = _wwassignment_link_to_set_auto_login($wwcoursename,$wwsetname,$wwusername,$wwkey); + +add_to_log($course->id, "wwassignment", "view", "view.php?id=$cm->id", "$wwassignment->id"); + +/// Print the page header + +if ($course->category) { + $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->"; +} + +$strwwassignments = get_string("modulenameplural", "wwassignment"); +$strwwassignment = get_string("modulename", "wwassignment"); + +print_header("$course->shortname: $wwassignment->name", "$course->fullname", "$navigation <a href='index.php?id=$course->id'>$strwwassignments</a> -> $wwassignment->name", "", "", true, update_module_button($cm->id, $course->id, $strwwassignment), navmenu($course, $cm)); +/// Print the main part of the page + + + +// Print webwork in iframe and link to escape to have webwork in a single window +print("<p style='font-size: smaller; color: #aaa;'>" . get_string("iframeNoShow-1", "wwassignment") + . "<a href='$wwsetlink'>" . get_string("iframeNoShow-2", "wwassignment") + ."</a><p align='center'></iframe></p>\n" + ); +print("<iframe id='wwPage' src='$wwsetlink' frameborder='1' " + . "width='".$CFG->wwassignment_iframewidth."' " + . "height='".$CFG->wwassignment_iframeheight."'>" + ); + +print("<script>ww.Init(".isteacher($course->id).")</script>"); + + +/// Finish the page +print_footer($course); + +?> Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/lib.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/lib.php -Lwwassignment3/moodle/mod/wwassignment/lib.php -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/lib.php +++ wwassignment3/moodle/mod/wwassignment/lib.php @@ -0,0 +1,204 @@ +<?php + +//////////////////////////////////////////////////////////////// +//Functions that are called by the Moodle System +//////////////////////////////////////////////////////////////// + +/** +* @desc Called when the module is installed into the Moodle System +*/ +function wwassignment_install() { +} + +/** +* @desc Creates a new Moodle assignment <-> Webwork problem set tie. +* @param $wwassignment object The data of the record to be entered in the DB. +* @return integer The ID of the new record. +*/ +function wwassignment_add_instance($wwassignment) { + global $COURSE; + + //Get data about the set from WebWorK + $wwclient = new wwassignment_client(); + $wwcoursename = _wwassignment_mapped_course($COURSE->id,false); + $wwsetname = $wwassignment->webwork_set; + $wwsetdata = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); + + //Attaching Moodle Set to WeBWorK Set + $returnid = insert_record('wwassignment',$wwassignment); + + //Creating events + _wwassignment_create_events($wwsetname,$wwassignment->id,$wwsetdata['open_date'],$wwsetdata['due_date']); + + return $returnid; +} + +/** +* @desc Updates and resynchronizes all information related to the a moodle assignment <-> webwork problem set tie. +* @param $wwassignment object The data of the record to be updated in the DB. +* @return integer The result of the update_record function. +*/ +function wwassignment_update_instance($wwassignment) { + global $COURSE; + + //checking mappings + $wwclient = new wwassignment_client(); + $wwcoursename = _wwassignment_mapped_course($COURSE->id,false); + $wwsetname = $wwassignment->webwork_set; + + //get data from WeBWorK + $wwsetdata = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); + $wwassignment->id = $wwassignment->instance; + + $returnid = update_record('wwassignment',$wwassignment); + + _wwassignment_delete_events($wwassignment->id); + _wwassignment_create_events($wwsetname,$wwassignment->id,$wwsetdata['open_date'],$wwsetdata['due_date']); + + return $returnid; +} + +/** +* @desc Deletes a tie in Moodle. Deletes nothing in webwork. +* @param integer $wwassignmentid The id of the assignment to delete. +* @return bool Delete was successful or not. +*/ +function wwassignment_delete_instance($wwassignmentid) { + + $result = true; + + #delete DB record + if (!delete_records('wwassignment', 'id',$wwassignmentid)) { + $result = false; + } + + #delete events + _wwassignment_delete_events($wwassignmentid); + + // Get the cm id to properly clean up the grade_items for this assignment + // bug 4976 + if (! $cm = get_record('modules', 'name', 'wwassignment')) { + $result = false; + } else { + if (! delete_records('grade_item', 'modid', $cm->id, 'cminstance', $wwassignment->id)) { + $result = false; + } + } + return $result; +} + +/** +* @desc Contacts webwork to find out the completion status of a problem set for all users in a course. +* @param integer $wwassignmentid The problem set +* @return object The student grades indexed by student ID. +*/ +function wwassignment_grades($wwassignmentid) { + global $COURSE; + $wwclient = new wwassignment_client(); + + $studentgrades = new stdClass; + $studentgrades->grades = array(); + $studentgrades->maxgrade = 0; + + $gradeformula = '$finalgrade += ($problem->status > 0) ? 1 : 0;'; + + $wwcoursename = _wwassignment_mapped_course($COURSE->id,false); + $wwsetname = _wwassignment_mapped_set($wwassignmentid,false); + + // enumerate over the students in the course: + $students = get_course_students($COURSE->id); + + $usernamearray = array(); + foreach($students as $student) { + array_push($usernamearray,$student->username); + } + $gradearray = $wwclient->grade_users_sets($wwcoursename,$usernamearray,$wwsetname); + $i = 0; + foreach($students as $student) { + $studentgrades->grades[$student->id] = $gradearray[$i]; + $i++; + } + $studentgrades->maxgrade = $wwclient->get_max_grade($wwcoursename,$wwsetname); + return $studentgrades; +} + + +/** +* @desc Returns a small object with summary information about a wwassignment instance. Used for user activity repots. +* @param string $course The ID of the course. +* @param string $user The ID of the user. +* @param string $wwassignment The ID of the wwassignment instance. +* @return array Representing time, info pairing. +*/ +function wwassignment_user_outline($course, $user, $mod, $wwassignment) { + $aLogs = get_logs("l.userid=$user AND l.course=$course AND l.cmid={$wwassignment->id}"); + if( count($aLogs) > 0 ) { + $return->time = $aLogs[0]->time; + $return->info = $aLogs[0]->info; + } + return $return; +} + +/** +* @desc Prints a detailed representation of what a user has done with a instance of this module. +* @param string $course The ID of the course. +* @param string $user The ID of the user. +* @param string $wwassignment The ID of the wwassignment instance. +* @return array Representing time, info pairing. +*/ +function wwassignment_user_complete($course, $user, $mod, $wwassignment) { + return true; +} + + + +function wwassignment_delete_course() { +} + +function wwassignment_process_options() { +} + +function wwassignment_reset_course_form() { +} + +function wwassignment_delete_userdata() { + +} + +/** +* @desc Finds recent activity that has occured in wwassignment activities. +*/ +function wwassignment_print_recent_activity($course, $isteacher, $timestart) { + global $CFG; + return false; // True if anything was printed, otherwise false +} + +/** +* @desc Function that is run by the cron job. This makes sure that all data is pushed to webwork. +*/ +function wwassignment_cron() { + //FIXME: Add a call that updates all events with dates (in case people forgot to push) + return true; +} + + + +/** +* @desc Finds all the participants in the course +* @param string $wwassignmentid The Moodle wwassignment ID. +* @return array An array of course users (IDs). +*/ +/*function wwassignment_get_participants($wwassignmentid) { + $wwassignment = get_record('wwassignment', 'id', $wwassignmentid); + if(!isset($wwassignment)) { + return array(); + } + return get_course_users($wwassignment->course); +} + +function wwassignment_refresh_events($courseid = 0) { + error_log('wwassignment_refresh_events called'); + return true; +}*/ + +?> \ No newline at end of file Index: locallib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/locallib.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/locallib.php -Lwwassignment3/moodle/mod/wwassignment/locallib.php -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/locallib.php +++ wwassignment3/moodle/mod/wwassignment/locallib.php @@ -0,0 +1,502 @@ +<?php + +require_once("$CFG->libdir/soap/nusoap.php"); + +////////////////////////////////////////////////////////////////// +//EVENT CREATION AND DELETION +////////////////////////////////////////////////////////////////// + +/** +* @desc Creates the corresponding events for a wwassignment. +* @param $wwsetname string The name of the set. +* @param $wwassignmentid string The ID of the wwassignment record. +* @param $opendate integer The UNIX timestamp of the open date. +* @param $duedate integer The UNIX timestamp of the due date. +* @return integer 0 on success. -1 on error. +*/ +function _wwassignment_create_events($wwsetname,$wwassignmentid,$opendate,$duedate) { + unset($event); + $event->name = $wwsetname; + $openevent->description = ''; + $event->courseid = $COURSE->id; + $event->groupid = 0; + $event->userid = 0; + $event->modulename = 'wwassignment'; + $event->instance = $wwassignmentid; + + $openevent = $event; + $dueevent = $event; + + $openevent->name .= ' is Open.'; + $openevent->eventtype = 'open'; + $openevent->timestart = $opendate; + $openevent->timeduration = $duedate - $opendate; + + $dueevent->name .= ' is Due.'; + $dueevent->eventtype = 'due'; + $dueevent->timestart = $duedate; + $dueevent->timeduration = 1; + + $result = 0; + if(!add_event($openevent)) { + $result = -1; + } + if(!add_event($dueevent)) { + $result = -1; + } + return $result; +} + + +/** +* @desc Deletes all events relating to the wwassignment passed in. +* @param $wwassignmentid integer The wwassignment ID. +* @return integer 0 on success +*/ +function _wwassignment_delete_events($wwassignmentid) { + if ($events = get_records_select('event', "modulename = 'wwassignment' and instance = '$wwassignmentid'")) { + foreach($events as $event) { + delete_event($event->id); + } + } + return 0; +} + +////////////////////////////////////////////////////////////////// +//Functions that ensure creation of WeBWorK Data +////////////////////////////////////////////////////////////////// + +/** +* @desc Checks whether a user exists in a WW course. If it doesnt creates the user using the currently logged in one. +* @param $wwcoursename string The WW course. +* @param $username string The username to check. +* @param $permission string The permission the user needs if created. +* @return string the new username. +*/ +function _wwassignment_mapcreate_user($wwcoursename,$username,$permission = '0') { + $wwclient = new wwassignment_client(); + $exists = $wwclient->mapped_user($wwcoursename,$username); + if($exists == -1) { + global $USER; + $tempuser = $USER; + $newusername = $wwclient->create_user($wwcoursename,$tempuser,$permission); + return $newusername; + } + return $username; +} + +/** +* @desc Checks whether a set exists for a user in a WW course. If it doesnt autocreates. +* @param $wwcoursename string The WW course. +* @param $wwusername string The WW user. +* @param $wwsetname string The WW set. +* @return integer 0. +*/ +function _wwassignment_mapcreate_user_set($wwcoursename,$wwusername,$wwsetname) { + $wwclient = new wwassignment_client(); + $exists = $wwclient->mapped_user_set($wwcoursename,$wwusername,$wwsetname); + if($exists == -1) { + $wwclient->create_user_set($wwcoursename,$wwusername,$wwsetname); + } + return 0; +} + +/** +* @desc Makes sure that a user is logged in to WW. +* @param $wwcoursename string The course to login to. +* @param $wwusername string The user to login. +* @return string The users key for WW. +*/ +function _wwassignment_login_user($wwcoursename,$wwusername) { + $wwclient = new wwassignment_client(); + return $wwclient->login_user($wwcoursename,$wwusername,false); +} + +//////////////////////////////////////////////////////////////// +//functions that check mapping existance in the local db +//////////////////////////////////////////////////////////////// + +/** +* @desc Finds the webwork course name from a moodle course id. +* @param integer $courseid Moodle Course ID. +* @param integer $silent whether to trigger an error message. +* @return string the name of the webwork course on success and -1 on failure. +*/ +function _wwassignment_mapped_course($courseid,$silent = true) { + $wwassignmentbridge = get_record('wwassignment_bridge','course', $courseid); + if((isset($wwassignmentbridge)) && (isset($wwassignmentbridge->webwork_course))) { + return $wwassignmentbridge->webwork_course; + } + if(!$silent) { + print_error(get_string('webwork_course_map_failure','wwassignment')); + } + return -1; +} + +/** +* @desc Finds the webwork set name from a wwassignment id. +* @param integer $wwassignmentid Moodle wwassignment ID. +* @param integer $silent whether to trigger an error message. +* @return string the name of the webwork set on success and -1 on failure. +*/ +function _wwassignment_mapped_set($wwassignmentid,$silent = true) { + $wwassignment = get_record('wwassignment','id',$wwassignmentid); + if((isset($wwassignment)) && (isset($wwassignment->webwork_set))) { + return $wwassignment->webwork_set; + } + if(!$silent) { + print_error(get_string('webwork_set_map_failure','wwassignment')); + } + return -1; +} + +//////////////////////////////////////////////////////////////// +//functions that create links to the webwork site. +//////////////////////////////////////////////////////////////// + +/** +* @desc Returns URL link to a webwork course logging the user in. +* @param string $webworkcourse The webwork course. +* @param string $webworkset The webwork set. +* @param string $webworkuser The webwork user. +* @param string $key The key used to login the user. +* @return URL. +*/ +function _wwassignment_link_to_edit_set_auto_login($webworkcourse,$webworkset,$username,$key) { + return _wwassignment_link_to_course($webworkcourse) . "instructor/sets/$webworkset/?effectiveUser=$username&user=$username&key=$key"; +} + + +/** +* @desc Returns URL link to a webwork course logging the user in. +* @param string $webworkcourse The webwork course. +* @param string $webworkuser The webwork user. +* @param string $key The key used to login the user. +* @return URL. +*/ +function _wwassignment_link_to_instructor_auto_login($webworkcourse,$username,$key) { + return _wwassignment_link_to_course($webworkcourse) . "instructor/?effectiveUser=$username&user=$username&key=$key"; +} + +/** +* @desc Returns the URL link to a webwork course and a particular set logged in. +* @param string $webworkcourse The webwork course. +* @param string $webworkset The webwork set. +* @param string $webworkuser The webwork user. +* @param string $key The key used to login the user. +* @return URL. +*/ +function _wwassignment_link_to_set_auto_login($webworkcourse,$webworkset,$webworkuser,$key) { + return _wwassignment_link_to_set($webworkcourse,$webworkset) . "?effectiveUser=$webworkuser&user=$webworkuser&key=$key"; +} + +/** +* @desc Returns the URL link to a webwork course and a particular set. +* @param string $webworkcourse The webwork course. +* @param string $webworkset The webwork set. +* @return URL. +*/ +function _wwassignment_link_to_set($webworkcourse,$webworkset) { + return _wwassignment_link_to_course($webworkcourse) . "$webworkset/"; +} + +/** +* @desc Returns the URL link to a webwork course. +* @param string $webworkcourse The webwork course. +* @return URL. +*/ +function _wwassignment_link_to_course($webworkcourse) { + return WWASSIGNMENT_WEBWORK_URL."/$webworkcourse/"; +} + + +/////////////////////////////////////////////////////////////// +//wwassignment client class +/////////////////////////////////////////////////////////////// + +/** +* @desc This singleton class acts as the gateway for all communication from the Moodle Client to the WeBWorK SOAP Server. It encapsulates an instance of a SoapClient. +*/ +class wwassignment_client { + var $client; + var $defaultparams; + var $datacache; + var $mappingcache; + /** + * @desc Constructs a singleton webwork_client. + */ + function wwassignment_client() + { + // static associative array containing the real objects, key is classname + static $instances=array(); + // get classname + $class = get_class($this); + if (!array_key_exists($class, $instances)) { + // does not yet exist, save in array + $this->client = new soap_client(WWASSIGNMENT_WEBWORK_WSDL,'wsdl'); + $err = $this->client->getError(); + if ($err) { + print_error(get_string('construction_error','wwassignment')."<BR>$err"); + } + $this->defaultparams = array(); + $this->defaultparams['authenKey'] = WWASSIGNMENT_WEBWORK_KEY; + $this->datacache = array(); + $this->mappingcache = array(); + $instances[$class] = $this; + + } + foreach (get_class_vars($class) as $var => $value) { + $this->$var =& $instances[$class]->$var; + } + } + /** + *@desc Calls a SOAP function and passes (authenkey,course) automatically in the parameter list. + *@param string $functioncall The function to call + *@param array $params The parameters to the function. + *@param integer $override=false whether to override the default parameters that are passed to the soap function (authenKey). + *@return Result of the soap function. + */ + function handler($functioncall,$params=array(),$override=false) { + if(!is_array($params)) { + $params = array($params); + } + if(!$override) { + $params = array_merge($this->defaultparams,$params); + } + $result = $this->client->call($functioncall,$params); + //$result = call_user_func_array(array(&$this->client,$functioncall),$params); + if($err = $this->client->getError()) { + //print_error(get_string("rpc_fault","wwassignment') . " " . $functioncall. " ". $err); + print_error(get_string('rpc_error','wwassignment')."<BR>$err<BR><BR>Response:<BR>".$this->client->response ); + } + return $result; + } + + /** + * @desc Checks whether a user is in a webwork course. + * @param string $webworkcourse The webwork course name. + * @param string $webworkuser The webwork user name. + * @param integer $silent whether to trigger an error message + * @return string Returns the webwork user on success and -1 on failure. + */ + function mapped_user($webworkcourse,$webworkuser,$silent = true) { + if(isset($this->mappingcache[$webworkcourse]['user'][$webworkuser])) { + return $this->mappingcache[$webworkcourse]['user'][$webworkuser]; + } + $record = $this->handler('get_user',array('courseName' => $webworkcourse,'userID' => $webworkuser)); + if($record != -1) { + $this->mappingcache[$webworkcourse]['user'][$webworkuser] = $webworkuser; + return $webworkuser; + } + if(!$silent) { + print_error(get_string('webwork_user_map_failure',"wwassignment")); + } + return -1; + } + + /** + * @desc Checks whether a user has his own copy of a set built in a webwork course. + * @param string $webworkcourse The webwork course name. + * @param string $webworkuser The webwork user name. + * @param string $webworkset The webwork set name. + * @param integer $silent whether to trigger an error message + * @return integer Returns 1 on success and -1 on failure. + */ + function mapped_user_set($webworkcourse,$webworkuser,$webworkset,$silent = true) { + if(isset($this->mappingcache[$webworkcourse]['user_set'][$webworkuser][$webworkset])) { + return $this->mappingcache[$webworkcourse]['user_set'][$webworkuser][$webworkset]; + } + $record = $this->handler('get_user_set',array('courseName' => $webworkcourse,'userID' => $webworkuser,'setID' => $webworkset)); + if($record != -1) { + $this->mappingcache[$webworkcourse]['user_set'][$webworkuser][$webworkset] = 1; + return 1; + } + + if(!$silent) { + print_error(get_string('webwork_user_set_map_failure','wwassignment')); + } + return -1; + } + + /** + * @desc Gets the record of the global set for a webwork course and set name. + * @param string $webworkcourse The webwork course name. + * @param string $webworkset The webwork set name. + * @param integer $silent whether to trigger an error message + * @return array Returns set information on success or -1 on failure. + */ + function get_assignment_data($webworkcourse,$webworkset,$silent = true) { + $record = $this->handler('get_global_set',array('courseName' => $webworkcourse, 'setID' => $webworkset)); + if(isset($record)) { + $setinfo = array(); + $setinfo['open_date'] = $record['open_date']; + $setinfo['due_date'] = $record['due_date']; + $setinfo['set_id'] = $record['set_id']; + $setinfo['name'] = $record['set_id']; + return $setinfo; + } + if(!$silent) { + print_error(get_string('webwork_set_map_failure','wwassignment')); + } + return -1; + + } + + /** + * @desc Gets all the user problems for a specfic course, user and set. + * @param string $webworkcourse The webwork course name. + * @param string $webworkuser The webwork users name. + * @param string $webworkset The webwork set name. + * @param integer $silent whether to trigger an error message + * @return array Returns an array of problems on success or -1 on failure. + */ + function get_user_problems($webworkcourse,$webworkuser,$webworkset,$silent = true) { + $record = $this->handler('get_all_user_problems',array('courseName' => $webworkcourse,'userID' => $webworkuser,'setID' => $webworkset)); + if(isset($record)) { + return $record; + } + if(!$silent) { + print_error(get_string('webwork_user_set_map_failure','wwassignment')); + } + return -1; + } + + /** + * @desc Calculates the max grade on a set by counting the number of problems in the set. + * @param string $webworkcourse The webwork course name. + * @param string $webworkset The webwork set name. + * @param integer $silent whether to trigger an error message + * @return integer The max grade on success or -1 on failure. + */ + function get_max_grade($webworkcourse,$webworkset,$silent = true) { + $record = $this->handler('list_global_problems',array('courseName' => $webworkcourse,'setID' => $webworkset)); + if(isset($record)) { + return count($record); + } + if(!$silent) { + print_error(get_string('webwork_set_map_failure','wwassignment')); + } + return -1; + + } + /** + * @desc Forces a login of a user into a course. + * @param string $webworkcourse The webwork course name. + * @param string $webworkuser The webwork users name. + * @param integer $silent whether to trigger an error message + * @return string The webwork key for URL on success or -1 on failure. + */ + function login_user($webworkcourse,$webworkuser,$silent = true) { + $key = $this->handler('login_user',array('courseName' => $webworkcourse,'userID' => $webworkuser)); + if(isset($key)) { + return $key; + } + if(!$silent) { + print_error(get_string('webwork_user_map_failure','wwassignment')); + } + return -1; + } + + /** + * @desc Retrieves a list of sets from a webwork course and converts it into form options format. + * @param string $webworkcourse The webwork course name. + * @param integer $silent whether to trigger an error message + * @return array The form options. + */ + function options_set($webworkcourse,$silent = true) { + $setlist = $this->handler('list_global_sets',array('courseName' => $webworkcourse)); + if(isset($setlist)) { + $setoptions = array(); + foreach($setlist as $setid) { + + $setoptions[$setid] = $setid; + } + return $setoptions; + } + if(!$silent) { + print_error(get_string('webwork_course_map_failure','wwassignment')); + } + return -1; + } + + /** + * @desc Retrieves a list of courses from a webwork course and converts it into form options format. + * @param integer $silent whether to trigger an error message + * @return array The form options. + */ + function options_course($silent = true) { + $courselist = $this->handler('list_courses'); + sort($courselist); + if(isset($courselist)) { + $courseoptions = array(); + foreach($courselist as $course) { + $courseoptions[$course] = $course; + } + return $courseoptions; + } + if(!$silent) { + print_error(get_string('webwork_course_list_map_failure','wwassignment')); + } + return -1; + + } + + /** + * @desc Creates a user in the WeBWorK course. + * @param string $webworkcourse The webwork course name. + * @param array $userdata The user data to use in creation. + * @param string $permission The permissions of the new user, defaults to 0. + * @return Returns 1 on success. + */ + function create_user($webworkcourse,&$userdata,$permission='0') { + $studentid = $userid; + # FIXME: find permission for this user and set permissions appropriately in webwork + # FIXME: find the group(s) that this person is a member of + # FIXME: I have used the following scheme: gage_SEC use groups ending like this to determine sections in webwork + # FIXME: use ordinary groups taName to correspond to recitation sections in WeBWorK + # + # FIXME: make it so an update_user function is called whenever the user data in moodle is changed + # FIXME: so if a student switches groups this is reflected in WeBWorK + $this->handler('add_user',array('courseName' => $webworkcourse, 'record' => array( + 'user_id' => $userdata->username, + 'first_name' => $userdata->firstname, + 'last_name' => $userdata->lastname, + 'email_address' => $userdata->email, + 'student_id' => $studentid, + 'status' => 'C', + 'section' => '', + 'recitation' => '', + 'comment' => 'moodle created user'))); + $this->handler('add_permission',array('courseName' => $webworkcourse,'record' => array( + 'user_id' => $userdata->username, + 'permission' => $permission))); + $this->handler('add_password',array('courseName' => $webworkcourse,'record' => array( + 'user_id' => $userdata->username, + 'password' => $userdata->password))); + return 1; + } + + /** + * @desc Creates a user set in WeBWorK + * @param string $webworkcourse The webwork course name. + * @param string $webworkuser The webwork user name. + * @param string $webworkset The webwork set name. + * @return Returns 1 on success. + */ + function create_user_set($webworkcourse,$webworkuser,$webworkset) { + $this->handler('assign_set_to_user',array('courseName' => $webworkcourse,'userID' => $webworkuser, 'setID' => $webworkset)); + return 1; + } + + /** + * @desc Finds grades of many users for one set. + * @param string $webworkcourse The webwork course name. + * @param array $webworkusers A list of webwork users + * @param string $webworkset The webwork set name + * @return array Returns an array of grades + */ + function grade_users_sets($webworkcourse,$webworkusers,$webworkset) { + return $this->handler('grade_users_sets',array('courseName' => $webworkcourse, 'userIDs' => $webworkusers, 'setID' => $webworkset)); + } +}; +?> \ No newline at end of file Index: install.xml =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/db/install.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/db/install.xml -Lwwassignment3/moodle/mod/wwassignment/db/install.xml -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/db/install.xml +++ wwassignment3/moodle/mod/wwassignment/db/install.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<XMLDB PATH="mod/wwassignment/db" VERSION="20070620" COMMENT="XMLDB file for Moodle mod/wwassignment" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"> + <TABLES> + <TABLE NAME="wwassignment" COMMENT="" NEXT="wwassignment_bridge"> + <FIELDS> + <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/> + <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/> + <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="description"/> + <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="webwork_set"/> + <FIELD NAME="webwork_set" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" DEFAULT="undefined" PREVIOUS="description"/> + + </FIELDS> + <KEYS> + <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for data"/> + </KEYS> + </TABLE> + <TABLE NAME="wwassignment_bridge" COMMENT="" PREVIOUS="wwassignment"> + <FIELDS> + <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/> + <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="webwork_course"/> + + <FIELD NAME="webwork_course" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course"/> + </FIELDS> + <KEYS> + <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for data"/> + </KEYS> + </TABLE> + </TABLES> + <STATEMENTS> + </STATEMENTS> + +</XMLDB> \ No newline at end of file Index: testwwassignment.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/simpletest/testwwassignment.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwassignment3/moodle/mod/wwassignment/simpletest/testwwassignment.php -Lwwassignment3/moodle/mod/wwassignment/simpletest/testwwassignment.php -u -r1.1 -r1.2 --- wwassignment3/moodle/mod/wwassignment/simpletest/testwwassignment.php +++ wwassignment3/moodle/mod/wwassignment/simpletest/testwwassignment.php @@ -0,0 +1,48 @@ +<?php +require_once(dirname(__FILE__) . '/../../config.php'); + +global $CFG; + +require_once($CFG->libdir . '/simpletestlib.php'); +require_once($CFG->dirroot . '/mod/wwassignment/locallib.php'); + +class wwassignment_test extends UnitTestCase { + + function setUp() { + } + + function tearDown() { + } + + /** + * @desc Test Module Name. + */ + function test_name() { + $this->assertEqual($this->qtype->name(),'webwork','Module Test'); + } + + /** + * @desc Test WSDL Path is set. + */ + function test_wsdl_path() { + $this->assertNotEqual(WWQUESTION_WSDL,'ENTER YOUR WSDL PATH HERE','WSDL Path Test'); + } + + /** + * @desc Test Webwork Path + */ + function test_webwork_path() { + } + + /** + * @desc Test Basic Communication + */ + function test_basic_communication() { + $client = new wwassignment_client(); + $response = $client->handler('hello'); + $this->assertEqual('hello world!',$response,'Webwork Server Communication Test.'); + } +} + +?> + |
From: dpvc v. a. <we...@ma...> - 2007-09-24 22:40:26
|
Log Message: ----------- Update the List() object to not add "(" and ")" around the list unless they are explicitly entered by the author. This prevents extraneous parentheses from being introduced into the problem text that the author hadn't expected. Parentheses now are added only for nested lists, as in List(1,List(2,3)), which will display as "1, (2, 3)", not "1, 2, 3". Modified Files: -------------- pg/lib: Value.pm pg/lib/Parser/Context: Default.pm pg/lib/Value: List.pm Revision Data ------------- Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value.pm,v retrieving revision 1.91 retrieving revision 1.92 diff -Llib/Value.pm -Llib/Value.pm -u -r1.91 -r1.92 --- lib/Value.pm +++ lib/Value.pm @@ -325,8 +325,8 @@ sub canBeInUnion { my $self = shift; my $def = $self->context->lists->get($self->class); - my $open = $self->{open}; $open = $def->{open} unless defined $open; - my $close = $self->{close}; $close = $def->{close} unless defined $close; + my $open = $self->{open}; $open = $def->{open}||$def->{nestedOpen} unless defined $open; + my $close = $self->{close}; $close = $def->{close}||$def->{nestedClose} unless defined $close; return $self->length == 2 && $self->typeRef->{entryType}{name} eq 'Number' && $open =~ m/^[\(\[]$/ && $close =~ m/^[\)\]]$/; } Index: Default.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context/Default.pm,v retrieving revision 1.42 retrieving revision 1.43 diff -Llib/Parser/Context/Default.pm -Llib/Parser/Context/Default.pm -u -r1.42 -r1.43 --- lib/Parser/Context/Default.pm +++ lib/Parser/Context/Default.pm @@ -120,7 +120,8 @@ 'Point' => {class =>'Parser::List::Point', open => '(', close => ')', separator => ','}, 'Vector' => {class =>'Parser::List::Vector', open => '<', close => '>', separator => ','}, 'Matrix' => {class =>'Parser::List::Matrix', open => '[', close => ']', separator => ','}, - 'List' => {class =>'Parser::List::List', open => '(', close => ')', separator => ', '}, + 'List' => {class =>'Parser::List::List', open => '', close => '', separator => ', ', + nestedOpen => '(', nestedClose => ')'}, 'Interval' => {class =>'Parser::List::Interval', open => '(', close => ')', separator => ','}, 'Set' => {class =>'Parser::List::Set', open => '{', close => '}', separator => ','}, 'Union' => {class =>'Parser::List::Union', open => '', close => '', separator => ' U '}, Index: List.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/List.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -Llib/Value/List.pm -Llib/Value/List.pm -u -r1.26 -r1.27 --- lib/Value/List.pm +++ lib/Value/List.pm @@ -15,10 +15,12 @@ sub new { my $self = shift; my $class = ref($self) || $self; my $context = (Value::isContext($_[0]) ? shift : $self->context); + my $def = $context->lists->get("List"); my $p = shift; my $isFormula = 0; my $isSingleton = (scalar(@_) == 0 && !(Value::isValue($p) && $p->classMatch('List'))); $p = $p->data if (Value::isValue($p) && $p->classMatch('List') && scalar(@_) == 0); - $p = [$p,@_] if (ref($p) ne 'ARRAY' || scalar(@_) > 0); + $p = [] unless defined $p; + $p = [$p,@_] if ref($p) ne 'ARRAY' || scalar(@_) > 0; my $type; foreach my $x (@{$p}) { $x = Value::makeValue($x,context=>$context) unless ref($x); @@ -27,11 +29,20 @@ if (!$type) {$type = $x->type} else {$type = 'unknown' unless $type eq $x->type} } else {$type = 'unknown'} + if (!$isSingleton && $x->type eq 'List') { + $x->{open} = $def->{nestedOpen} unless $x->{open}; + $x->{close} = $def->{nestedClose} unless $x->{close}; + } } return $p->[0] if ($isSingleton && $type eq 'List' && !$p->[0]{open}); return $self->formula($p) if $isFormula; my $list = bless {data => $p, type => $type, context=>$context}, $class; - $list->{correct_ans} = $p->[0]{correct_ans} if $isSingleton && defined $p->[0]{correct_ans}; + $list->{correct_ans} = $p->[0]{correct_ans} + if $isSingleton && defined scalar(@{$p}) && defined $p->[0]{correct_ans}; + if (scalar(@{$p}) == 0) { + $list->{open} = $def->{nestedOpen}; + $list->{close} = $def->{nestedClose}; + } return $list; } |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:32:14
|
Log Message: ----------- Combining wwlink and wwassignment with new setup file. Added Files: ----------- wwmoodle/wwassignment3: CHANGES README wwmoodle/wwassignment3/bin/setup: setup.pl wwmoodle/wwassignment3/moodle/blocks/wwlink: block_wwlink.php config_instance.html wwmoodle/wwassignment3/moodle/lang/en_utf8: block_wwlink.php wwassignment.php wwmoodle/wwassignment3/moodle/mod/wwassignment: backuplib.php config.html icon.gif index.php javascript.php lib.php locallib.php restorelib.php version.php view.php wwmoodle/wwassignment3/moodle/mod/wwassignment/db: install.xml wwmoodle/wwassignment3/moodle/mod/wwassignment/simpletest: testwwassignment.php Revision Data ------------- --- /dev/null +++ wwassignment3/bin/setup/setup.pl @@ -0,0 +1,105 @@ +#!/usr/bin/env perl + +use Cwd; + +sub promptUser { + + #-------------------------------------------------------------------# + # two possible input arguments - $promptString, and $defaultValue # + # make the input arguments local variables. # + #-------------------------------------------------------------------# + + local($promptString,$defaultValue) = @_; + + #-------------------------------------------------------------------# + # if there is a default value, use the first print statement; if # + # no default is provided, print the second string. # + #-------------------------------------------------------------------# + + if ($defaultValue) { + print $promptString, "[", $defaultValue, "]: "; + } else { + print $promptString, ": "; + } + + $| = 1; # force a flush after our print + $_ = <STDIN>; # get the input from STDIN (presumably the keyboard) + + + #------------------------------------------------------------------# + # remove the newline character from the end of the input the user # + # gave us. # + #------------------------------------------------------------------# + + chomp; + + #-----------------------------------------------------------------# + # if we had a $default value, and the user gave us input, then # + # return the input; if we had a default, and they gave us no # + # no input, return the $defaultValue. # + # # + # if we did not have a default value, then just return whatever # + # the user gave us. if they just hit the <enter> key, # + # the calling routine will have to deal with that. # + #-----------------------------------------------------------------# + + if ("$defaultValue") { + return $_ ? $_ : $defaultValue; # return $_ if it has a value + } else { + return $_; + } +} + +print "###################################\n"; +print "#WeBWorK Assignment in Moodle #\n"; +print "###################################\n"; + +#Continue? +print "This script will setup the WeBWorK Assignment Type.\n"; +$continue = promptUser('Continue','y'); +if($continue ne "y") { + exit; +} + +#Program Root +print "Please enter the root directory where wwassignment3 module is located. \n"; +print "Example: /tmp/wwmoodle/wwassignment3\n"; +$wwassignmentRoot = promptUser(''); + +#Moodle Root +print "Please enter the root directory where Moodle is installed. \n"; +print "Example: /var/www/moodle \n"; +$moodleRoot = promptUser(''); + +#File Moving/Linking +$files = promptUser('Would you like me to place the files into proper directories (y,n)','y'); +if($files eq 'y') { + $doWhat = promptUser('Would you like me to copy the help files or soft link them.(copy,link)','link'); + if($doWhat eq 'link') { + $action = 'ln -sf '; + } elsif ($doWhat eq 'copy') { + print "Remember to rerun setup when/if you update from the CVS\n"; + $action = 'cp -R '; + } else { + exit; + } + #wipe existing directories + system("rm -rf $moodleRoot/mod/wwassignment"); + system("rm -rf $moodleRoot/blocks/wwlink"); + system("rm -rf $moodleRoot/lang/en_utf8/help/wwassignment"); + + #copy php code directories + system("cp -R $wwassignmentRoot/moodle/mod/wwassignment " . $moodleRoot . '/mod/'); + system("cp -R $wwassignmentRoot/moodle/blocks/wwlink " . $moodleRoot . '/blocks/'); + + #help files + system($action . "$wwassignmentRoot/moodle/lang/en_utf8/wwassignment.php " . $moodleRoot . '/lang/en_utf8/wwassignment.php'); + system($action . "$wwassignmentRoot/moodle/lang/en_utf8/block_wwlink.php " . $moodleRoot . '/lang/en_utf8/block_wwlink.php'); + system($action . "$wwassignmentRoot/moodle/lang/en_utf8/help/wwassignment " . $moodleRoot . '/lang/en_utf8/help/'); + + print "Setup Successful!\n"; + + +} + +1; |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:30:37
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/simpletest In directory devel.webwork.rochester.edu:/tmp/cvs-serv11161/simpletest Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/simpletest added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:30:36
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/db In directory devel.webwork.rochester.edu:/tmp/cvs-serv11161/db Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment/db added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:30:06
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment In directory devel.webwork.rochester.edu:/tmp/cvs-serv11145/wwassignment Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod/wwassignment added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:29:51
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8/help/wwassignment In directory devel.webwork.rochester.edu:/tmp/cvs-serv11127/wwassignment Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8/help/wwassignment added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:29:39
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8/help In directory devel.webwork.rochester.edu:/tmp/cvs-serv11110/help Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8/help added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:29:22
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8 In directory devel.webwork.rochester.edu:/tmp/cvs-serv11093/en_utf8 Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang/en_utf8 added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:28:53
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/blocks/wwlink In directory devel.webwork.rochester.edu:/tmp/cvs-serv11041/wwlink Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/blocks/wwlink added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:28:43
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod In directory devel.webwork.rochester.edu:/tmp/cvs-serv11013/mod Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/mod added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:28:37
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang In directory devel.webwork.rochester.edu:/tmp/cvs-serv11001/lang Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/lang added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:28:31
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle/blocks In directory devel.webwork.rochester.edu:/tmp/cvs-serv10989/blocks Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle/blocks added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:28:14
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/bin/setup In directory devel.webwork.rochester.edu:/tmp/cvs-serv10972/setup Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/bin/setup added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:26:58
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/moodle In directory devel.webwork.rochester.edu:/tmp/cvs-serv10949/moodle Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/moodle added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:26:44
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3/bin In directory devel.webwork.rochester.edu:/tmp/cvs-serv10913/bin Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3/bin added to the repository |
From: Matt L. v. a. <we...@ma...> - 2007-09-21 00:26:07
|
Update of /webwork/cvs/system/wwmoodle/wwassignment3 In directory devel.webwork.rochester.edu:/tmp/cvs-serv10892/wwassignment3 Log Message: Directory /webwork/cvs/system/wwmoodle/wwassignment3 added to the repository |
From: dpvc v. a. <we...@ma...> - 2007-09-20 22:53:57
|
Log Message: ----------- Adds a new context that is more limited by not allowing operations within the coefficients and exponents themselves. Access this context using Context("LimitedPolynomial-Strict"); Modified Files: -------------- pg/macros: contextLimitedPolynomial.pl Revision Data ------------- Index: contextLimitedPolynomial.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPolynomial.pl,v retrieving revision 1.13 retrieving revision 1.14 diff -Lmacros/contextLimitedPolynomial.pl -Lmacros/contextLimitedPolynomial.pl -u -r1.13 -r1.14 --- macros/contextLimitedPolynomial.pl +++ macros/contextLimitedPolynomial.pl @@ -7,19 +7,29 @@ ########################################################## # - # Implements a context in which students can only - # enter (expanded) polynomials (i.e., sums of multiples - # of powers of x). + # Implements a context in which students can only enter (expanded) + # polynomials (i.e., sums of multiples of powers of x). # # Select the context using: # # Context("LimitedPolynomial"); # - # If you set the "singlePowers" flag, then only one monomial of - # each degree can be included in the polynomial: + # If you set the "singlePowers" flag, then only one monomial of each + # degree can be included in the polynomial: # # Context("LimitedPolynomial")->flags->set(singlePowers=>1); # + # There is also a strict limited context that does not allow + # operations even within the coefficients. Select it using: + # + # Context("LimitedPolynomial-Strict"); + # + # In addition to disallowing operations within the coefficients, + # this context does not reduce constant operations (since they are + # not allowed), and sets the singlePowers flag automatically. In + # addition, it disables all the functions, though they can be + # re-enabled, if needed. + # =cut @@ -38,8 +48,11 @@ my $self = shift; my $super = ref($self); $super =~ s/LimitedPolynomial/Parser/; &{$super."::_check"}($self); - return if LimitedPolynomial::isConstant($self->{lop}) && - LimitedPolynomial::isConstant($self->{rop}); + if (LimitedPolynomial::isConstant($self->{lop}) && + LimitedPolynomial::isConstant($self->{rop})) { + $self->checkStrict if $self->context->flag("strictCoefficients"); + return; + } return if $self->checkPolynomial; $self->Error("Your answer doesn't look like a polynomial"); } @@ -95,6 +108,15 @@ return 1; } +# +# Report an error when both operands are constants +# and strictCoefficients is in effect. +# +sub checkStrict { + my $self = shift; + $self->Error("Can't use '%s' between constants",$self->{bop}); +} + ################################################## package LimitedPolynomial; @@ -157,11 +179,15 @@ sub checkPolynomial { my $self = shift; my ($l,$r) = ($self->{lop},$self->{rop}); - $self->Error("Addition is allowed only between monomials") - if $r->{isPoly}; + $self->Error("Addition is allowed only between monomials") if $r->{isPoly}; $self->checkPowers; } +sub checkStrict { + my $self = shift; + $self->Error("You can only use addition for the terms of a polynomial",$self->{bop}); +} + ############################################## package LimitedPolynomial::BOP::subtract; @@ -170,11 +196,15 @@ sub checkPolynomial { my $self = shift; my ($l,$r) = ($self->{lop},$self->{rop}); - $self->Error("Subtraction is only allowed between monomials") - if $r->{isPoly}; + $self->Error("Subtraction is allowed only between monomials") if $r->{isPoly}; $self->checkPowers; } +sub checkStrict { + my $self = shift; + $self->Error("You can only use subtraction between the terms of a polynomial",$self->{bop}); +} + ############################################## package LimitedPolynomial::BOP::multiply; @@ -192,6 +222,11 @@ $self->Error("Multiplication can only be used between coefficients and variables"); } +sub checkStrict { + my $self = shift; + $self->Error("You can only use '%s' between a coefficent and a variable in a polynomial",$self->{bop}); +} + ############################################## package LimitedPolynomial::BOP::divide; @@ -210,6 +245,11 @@ return 1; } +sub checkStrict { + my $self = shift; + $self->Error("You can only use '%s' to form fractions",$self->{bop}) if $self->{lop}->class eq 'BOP'; +} + ############################################## package LimitedPolynomial::BOP::power; @@ -234,6 +274,11 @@ return 1; } +sub checkStrict { + my $self = shift; + $self->Error("You can only use powers of a variable in a polynomial"); +} + ############################################## ############################################## # @@ -366,6 +411,13 @@ # $context->reduction->set("(-x)-y"=>0); + # + # A context where coefficients can't include operations + # + $context = $main::context{"LimitedPolynomial-Strict"} = $context->copy; + $context->flags->set(strictCoefficients=>1, singelPowers=>1, reduceConstants=>0); + $context->functions->disable("All"); # can be re-enabled if needed + main::Context("LimitedPolynomial"); ### FIXME: probably should require author to set this explicitly } |
From: dpvc v. a. <we...@ma...> - 2007-09-20 18:09:21
|
Log Message: ----------- Make adaptive parameters try again if they fail to be found the first time (Gavin has found cases where the random points cause the coefficient matrix to be singular, so a second try should resolve the problem). Modified Files: -------------- pg/lib/Value: Formula.pm Revision Data ------------- Index: Formula.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Formula.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -Llib/Value/Formula.pm -Llib/Value/Formula.pm -u -r1.59 -r1.60 --- lib/Value/Formula.pm +++ lib/Value/Formula.pm @@ -182,6 +182,11 @@ # to the ORIGINAL correct answer. (This will have to be # fixed if we ever do adaptive parameters for non-real formulas) # + # FIXME: it doesn't make sense to apply the ORIGINAL value's + # tolerance, and causes problems when the values + # differ in magnitude by much. Gavin has found several + # situations where this is a problem. + # if ($l->AdaptParameters($r,$self->{context}->variables->parameters)) { my $avalues = $l->{test_adapt}; my $tolerance = $self->getFlag('tolerance',1E-4); @@ -412,53 +417,59 @@ # sub AdaptParameters { my $l = shift; my $r = shift; - my @params = @_; my $d = scalar(@params); + my @params = @_; my $d = scalar(@params); my $D; return 0 if $d == 0; return 0 unless $l->usesOneOf(@params); $l->Error("Adaptive parameters can only be used for real-valued formulas") unless $l->{tree}->isRealNumber; + # - # Get coefficient matrix of adaptive parameters - # and value vector for linear system + # Try up to three times (the random points might not work the first time) # - my ($p,$v) = $l->createRandomPoints($d); - my @P = (0) x $d; my ($f,$F) = ($l->{f},$r->{f}); - my @A = (); my @b = (); - foreach my $i (0..$d-1) { - my @a = (); my @p = @{$p->[$i]}; - foreach my $j (0..$d-1) { - $P[$j] = 1; push(@a,(&$f(@p,@P)-$v->[$i])->value); - $P[$j] = 0; + foreach my $attempt (1..3) { + # + # Get coefficient matrix of adaptive parameters + # and value vector for linear system + # + my ($p,$v) = $l->createRandomPoints($d); + my @P = (0) x $d; my ($f,$F) = ($l->{f},$r->{f}); + my @A = (); my @b = (); + foreach my $i (0..$d-1) { + my @a = (); my @p = @{$p->[$i]}; + foreach my $j (0..$d-1) { + $P[$j] = 1; push(@a,(&$f(@p,@P)-$v->[$i])->value); + $P[$j] = 0; + } + push @A, [@a]; push @b, [(&$F(@p,@P)-$v->[$i])->value]; } - push @A, [@a]; push @b, [(&$F(@p,@P)-$v->[$i])->value]; - } - # - # Use MatrixReal1.pm to solve system of linear equations - # - my $M = MatrixReal1->new($d,$d); $M->[0] = \@A; - my $B = MatrixReal1->new($d,1); $B->[0] = \@b; - ($M,$B) = $M->normalize($B); - $M = $M->decompose_LR; - if (($d,$B,$M) = $M->solve_LR($B)) { - if ($d == 0) { - # - # Get parameter values and recompute the points using them - # - my @a; my $i = 0; my $max = $l->getFlag('max_adapt',1E8); - foreach my $row (@{$B->[0]}) { - if (abs($row->[0]) > $max) { - $max = Value::makeValue($max); $row->[0] = Value::makeValue($row->[0]); - $l->Error(["Constant of integration is too large: %s\n(maximum allowed is %s)", - $row->[0]->string,$max->string]) if $params[$i] eq 'C0'; - $l->Error(["Adaptive constant is too large: %s = %s\n(maximum allowed is %s)", - $params[$i],$row->[0]->string,$max->string]); - } - push @a, $row->[0]; $i++; + # + # Use MatrixReal1.pm to solve system of linear equations + # + my $M = MatrixReal1->new($d,$d); $M->[0] = \@A; + my $B = MatrixReal1->new($d,1); $B->[0] = \@b; + ($M,$B) = $M->normalize($B); + $M = $M->decompose_LR; + if (($D,$B,$M) = $M->solve_LR($B)) { + if ($D == 0) { + # + # Get parameter values and recompute the points using them + # + my @a; my $i = 0; my $max = $l->getFlag('max_adapt',1E8); + foreach my $row (@{$B->[0]}) { + if (abs($row->[0]) > $max) { + $max = Value::makeValue($max); $row->[0] = Value::makeValue($row->[0]); + $l->Error(["Constant of integration is too large: %s\n(maximum allowed is %s)", + $row->[0]->string,$max->string]) if $params[$i] eq 'C0' or $params[$i] eq 'n00'; + $l->Error(["Adaptive constant is too large: %s = %s\n(maximum allowed is %s)", + $params[$i],$row->[0]->string,$max->string]); + } + push @a, $row->[0]; $i++; + } + my $context = $l->context; + foreach my $i (0..$#a) {$context->{variables}{$params[$i]}{value} = $a[$i]} + $l->{parameters} = [@a]; + $l->createAdaptedValues; + return 1; } - my $context = $l->context; - foreach my $i (0..$#a) {$context->{variables}{$params[$i]}{value} = $a[$i]} - $l->{parameters} = [@a]; - $l->createAdaptedValues; - return 1; } } $l->Error("Can't solve for adaptive parameters"); |