labnbook.php 878 Bytes
Newer Older
Francois Gannaz's avatar
Francois Gannaz committed
1
2
3
4
<?php

/**
 * @license http://www.gnu.org/licenses/gpl-3.0.html  GNU GPL v3
Francois Gannaz's avatar
Francois Gannaz committed
5
 * @copyright  2019 Université Grenoble Alpes
Francois Gannaz's avatar
Francois Gannaz committed
6
7
8
9
10
11
12
 */

namespace mod_labnbook\ar;

/* @var $DB \moodle_database */

/**
Francois Gannaz's avatar
Francois Gannaz committed
13
 * Active Record class that map the "labnbook" table in the DB to a PHP object.
Francois Gannaz's avatar
Francois Gannaz committed
14
15
16
17
 */
class labnbook
{
    public $id;
18
    public $course;
Francois Gannaz's avatar
Francois Gannaz committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    public $name;
    public $intro;
    public $introformat;
    public $labnbook_missionid;
    public $labnbook_teamconfigid;

    public function __construct(array $record = [])
    {
        foreach ($record as $field => $value) {
            if (object_property_exists($this, $field)) {
                $this->$field = $value;
            }
        }
    }

    public static function find(array $criteria)
    {
        global $DB;
        $record = $DB->get_record(LABNBOOK_TABLE, $criteria, '*');
        return new self($record);
    }
}