Commit 158e7cb0 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1938842: Allow view submissions to host rather than group



Change-Id: Iae13b7aa73db37e85a323932d433e534674ca145
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit 5e1f7175)
parent 9337a21e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -877,7 +877,7 @@ function submit_view_for_assessment($username, $id, $iscollection = false, $apil
                $access = View::get_invisible_token($id);
            }
            else {
                View::_db_submit(array($id), null, $remotehost, $userid);
                $view->submit(null, $remotehost, $userid);
                $access = View::new_token($id, false);
            }
            $token = $access->token;
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ function submitview_submit(Pieform $form, $values) {
    global $SESSION, $USER, $portfolioType, $portfolioElement, $group;

    if (!empty($portfolioElement)) {
        $portfolioElement->submit($group, $USER);
        $portfolioElement->submit($group, null, null, true);
        $SESSION->add_ok_msg(get_string($portfolioType .'submitted', 'view'));
    }
    redirect(gotoURL());
+27 −6
Original line number Diff line number Diff line
@@ -6944,23 +6944,44 @@ class View {
        return $data;
    }

    public function submit($group, $sendnotification=true) {
    /**
     * Submit this View to a group or a remote host.
     *
     * While $group and $submittedhost are optional, at least one is required.
     *
     * The notification is only sent if we have a $group and $sendnotification
     * is true.
     *
     * @param object|null $group The Group object.
     * @param string|null $submittedhost A URL for the remote host.
     * @param int|null $owner A User ID.
     * @param bool $sendnotification Should we send a notification for this submission?
     */
    public function submit($group = null, $submittedhost = null, $owner = null, $sendnotification=true) {
        global $USER;

        // One of these is needed.
        if (!$group && !$submittedhost) {
            throw new SystemException('Group or Submitted Host is needed.');
        }

        if ($this->is_submitted()) {
            throw new SystemException('Attempting to submit a submitted view');
        }

        if ($group) {
            $group->roles = get_column('grouptype_roles', 'role', 'grouptype', $group->grouptype, 'see_submitted_views', 1);
        }

        self::_db_submit(array($this->id), $group, $submittedhost, $owner);

        self::_db_submit(array($this->id), $group);
        handle_event('addsubmission', array('id' => $this->id,
                                            'eventfor' => 'view',
                                            'name' => $this->title,
                                            'group' => $group->id,
                                            'groupname' => $group->name));
                                            'group' => ($group) ? $group->id : null,
                                            'groupname' => ($group) ? $group->name : null));

        if ($sendnotification) {
        if ($group && $sendnotification) {
            activity_occurred(
                'groupmessage',
                array(
+1 −1
Original line number Diff line number Diff line
@@ -373,7 +373,7 @@ class PluginModuleLti extends PluginModule {
        else {
            $view = new View($viewid);

            $view->submit(get_group_by_id($assessment->group), false);
            $view->submit(get_group_by_id($assessment->group), null, null, false);
            $submissionname = $view->get('title');
        }

+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ function submitview_submit(Pieform $form, $values) {
        $SESSION->add_ok_msg(get_string('collectionsubmitted', 'view'));
    }
    else if (!empty($view)) {
        $view->submit($group, $USER);
        $view->submit($group, null, $USER->get('id'));
        $SESSION->add_ok_msg(get_string('viewsubmitted', 'view'));
    }

Loading