Exemplo n.º 1
0
    /**
     * Switch to a new workshop phase
     *
     * Modifies the underlying database record. You should terminate the script shortly after calling this.
     *
     * @param int $newphase new phase code
     * @return bool true if success, false otherwise
     */
    public function switch_phase($newphase) {
        global $DB;

        $known = $this->available_phases_list();
        if (!isset($known[$newphase])) {
            return false;
        }

        if (self::PHASE_CLOSED == $newphase) {
            // push the grades into the gradebook
            $workshop = new stdclass();
            foreach ($this as $property => $value) {
                $workshop->{$property} = $value;
            }
            $workshop->course     = $this->course->id;
            $workshop->cmidnumber = $this->cm->id;
            $workshop->modname    = 'workshop';
            workshop_update_grades($workshop);
        }

        $DB->set_field('workshop', 'phase', $newphase, array('id' => $this->id));
        return true;
    }
Exemplo n.º 2
0
 /**
  * Switch to a new workshop phase
  *
  * Modifies the underlying database record. You should terminate the script shortly after calling this.
  *
  * @param int $newphase new phase code
  * @return bool true if success, false otherwise
  */
 public function switch_phase($newphase)
 {
     global $DB;
     $known = $this->available_phases_list();
     if (!isset($known[$newphase])) {
         return false;
     }
     if (self::PHASE_CLOSED == $newphase) {
         // push the grades into the gradebook
         $workshop = new stdclass();
         foreach ($this as $property => $value) {
             $workshop->{$property} = $value;
         }
         $workshop->course = $this->course->id;
         $workshop->cmidnumber = $this->cm->id;
         $workshop->modname = 'workshop';
         workshop_update_grades($workshop);
     }
     $DB->set_field('workshop', 'phase', $newphase, array('id' => $this->id));
     $this->phase = $newphase;
     $eventdata = array('objectid' => $this->id, 'context' => $this->context, 'other' => array('workshopphase' => $this->phase));
     $event = \mod_workshop\event\phase_switched::create($eventdata);
     $event->trigger();
     return true;
 }