/** * Releases a submission to a remote host. * @param int $id A view or collection id * @param mixed $assessmentdata Assessment data from the remote host, for this assignment * @param string $teacherusername The username of the teacher who is releasing the assignment * @param boolean $iscollection Whether the $id is a view or a collection */ function release_submitted_view($id, $assessmentdata, $teacherusername, $iscollection = false) { global $REMOTEWWWROOT, $USER; list($teacher, $authinstance) = find_remote_user($teacherusername, $REMOTEWWWROOT); require_once 'view.php'; db_begin(); if ($iscollection) { require_once 'collection.php'; $collection = new Collection($id); $collection->release($teacher); } else { $view = new View($id); View::_db_release(array($id), $view->get('owner')); } // Provide each artefact plugin the opportunity to handle the remote submission release foreach (plugins_installed('artefact') as $plugin) { safe_require('artefact', $plugin->name); $classname = generate_class_name('artefact', $plugin->name); if (is_callable($classname . '::view_release_external_data')) { call_static_method($classname, 'view_release_external_data', $id, $assessmentdata, $teacher ? $teacher->id : 0, $iscollection); } } // Release the view for editing db_commit(); }
/** * Release a submitted collection * * @param object $releaseuser The user releasing the collection */ public function release($releaseuser = null) { if (!$this->is_submitted()) { throw new ParameterException("Collection with id " . $this->id . " has not been submitted"); } // One day there might be group and institution collections, so be safe if (empty($this->owner)) { throw new ParameterException("Collection with id " . $this->id . " has no owner"); } $viewids = $this->get_viewids(); db_begin(); execute_sql(' UPDATE {collection} SET submittedgroup = NULL, submittedhost = NULL, submittedtime = NULL, submittedstatus = ' . self::UNSUBMITTED . ' WHERE id = ?', array($this->id)); View::_db_release($viewids, $this->owner, $this->submittedgroup); db_commit(); // We don't send out notifications about the release of remote-submitted Views & Collections // (though I'm not sure why) if ($this->submittedgroup) { $releaseuser = optional_userobj($releaseuser); $releaseuserdisplay = display_name($releaseuser, $this->owner); $submitinfo = $this->submitted_to(); require_once 'activity.php'; activity_occurred('maharamessage', array('users' => array($this->get('owner')), 'strings' => (object) array('subject' => (object) array('key' => 'collectionreleasedsubject', 'section' => 'group', 'args' => array($this->name, $submitinfo->name, $releaseuserdisplay)), 'message' => (object) array('key' => 'collectionreleasedmessage', 'section' => 'group', 'args' => array($this->name, $submitinfo->name, $releaseuserdisplay))), 'url' => $this->get_url(false), 'urltext' => $this->name)); } }