From: Mike G. v. a. <we...@ma...> - 2008-08-24 03:04:27
|
Log Message: ----------- wwlink now saves its configuration internally instead of using the wwassignment_bridge table Modified Files: -------------- wwmoodle/wwassignment4/moodle/blocks/wwlink: block_wwlink.php Revision Data ------------- Index: block_wwlink.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/blocks/wwlink/block_wwlink.php,v retrieving revision 1.3 retrieving revision 1.4 diff -Lwwassignment4/moodle/blocks/wwlink/block_wwlink.php -Lwwassignment4/moodle/blocks/wwlink/block_wwlink.php -u -r1.3 -r1.4 --- wwassignment4/moodle/blocks/wwlink/block_wwlink.php +++ wwassignment4/moodle/blocks/wwlink/block_wwlink.php @@ -22,28 +22,28 @@ /** * @desc Saves the form data from configuration into the wwassignment_bridge table. */ - function instance_config_save($data) { +// function instance_config_save($data) { - $webworkcourse = $data->webwork_link_id; - $moodlecourse = $data->courseid; +// $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); +// } - $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); - } +// 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. @@ -55,26 +55,39 @@ /** * @desc Prints the content of the block. Whether or not the course is connected to a moodle course. */ +// function get_content() { +// global $COURSE; +// print_r($this->config ); +// $courseid = $COURSE->id; +// $record = get_record('wwassignment_bridge','course',$courseid); +// print_r($record); +// if(!$record) { +// $wwlinkdata = $this->config; +// if (!$wwlinkdata) { +// $this->content->text = get_string('not_connected','block_wwlink'); +// } else { +// $this->content->text = "connecting to ". $this->config->webwork_link_id; +// $wwassignmentbridge->course = $courseid; +// $wwassignmentbridge->webwork_course = $wwlinkdata->webwork_link_id; +// insert_record('wwassignment_bridge',$wwassignmentbridge); +// } +// +// } else { +// $this->content->text = get_string('connected','block_wwlink') . ' ' . $record->webwork_course; +// } +// $this->content->footer = ''; +// return $this->content; +// } function get_content() { global $COURSE; - print_r($this->config ); - $courseid = $COURSE->id; - $record = get_record('wwassignment_bridge','course',$courseid); - print_r($record); - if(!$record) { - $wwlinkdata = $this->config; - if (!$wwlinkdata) { - $this->content->text = get_string('not_connected','block_wwlink'); - } else { - $this->content->text = "connecting to ". $this->config->webwork_link_id; - $wwassignmentbridge->course = $courseid; - $wwassignmentbridge->webwork_course = $wwlinkdata->webwork_link_id; - insert_record('wwassignment_bridge',$wwassignmentbridge); - } - - } else { - $this->content->text = get_string('connected','block_wwlink') . ' ' . $record->webwork_course; - } + //print_r($this->config ); + $wwlinkdata = $this->config; + if (!isset($wwlinkdata) || !$wwlinkdata->webwork_link_id ) { // need webwork_link_id to exist and be non-zero + $this->content->text = get_string('not_connected','block_wwlink'); + } else { + $this->content->text = get_string('connected','block_wwlink') . ' ' . $wwlinkdata->webwork_link_id; + } + $this->content->footer = ''; return $this->content; } |