-
Notifications
You must be signed in to change notification settings - Fork 0
/
mask_type_basic.class.php
90 lines (68 loc) · 3.29 KB
/
mask_type_basic.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Display masks plugin frame
*
* @copyright 2016 Edunao SAS ([email protected])
* @author Sadge ([email protected])
* @package mod_masks
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_masks;
defined('MOODLE_INTERNAL') || die;
require_once(dirname(__FILE__).'/mask_type.class.php');
class mask_type_basic extends mask_type{
// -------------------------------------------------------------------------
// data
private $maskType = 'basic';
private $dbInterface = null;
private $fields = null;
// -------------------------------------------------------------------------
// basics
public function __construct(){
// Establish database connection
require_once(dirname(__FILE__).'/database_interface.class.php');
$this->dbInterface = new database_interface;
// Define the fields that are to appear in the question editing form
$this->fields = array(
'title' => FIELD_TEXT + FIELD_REQUIRED,
'note' => FIELD_BIGTEXTAREA + FIELD_REQUIRED,
);
// this is a notes field so override the default mask type family
$this->maskTypeFamily = 'note';
}
// -------------------------------------------------------------------------
// mask_type API
public function onNewMask( $id, $pageId ){
// delegate work to generic method in base class
$this->doNewMask( $id, $pageId, $this->maskType, $this->fields, $this->dbInterface, MASK_FLAGS_CLOSABLE );
}
public function onEditMask( $id, $maskId, $questionId, $questionData ){
// delegate work to generic method in base class
$this->doEditMask( $id, $maskId, $questionId, $questionData, $this->maskType, $this->fields, $this->dbInterface );
}
public function onClickMask( $questionId, $questionData, $hiddenFields, $isLastQuestion ){
global $USER;
// update the database to signal that this element has been seen
$updatedGrades = $this->dbInterface->updateUserQuestionState( $this->cm, $USER->id, $questionId, 'DONE' );
// get hold of the appropriate js code for acknowledging that this mask is being closed
$gradeUpdateScript = $this->getGradeUpdateScript( $updatedGrades );
// delegate work to generic method in base class
$this->renderInfoPage( $questionData->title, $questionData->note, '', 'info once', $gradeUpdateScript.'parent.M.mod_masks.closeMask(); parent.M.mod_masks.closeFrame();' );
// we always close a basic mask after viewing the popup so return true
return true;
}
}