This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelbp_prior_learning.class.php
177 lines (118 loc) · 4.32 KB
/
elbp_prior_learning.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace ELBP\Plugins;
require_once 'lib.php';
class elbp_prior_learning extends Plugin {
/**
* Construct the plugin object
* @param bool $install If true, we want to send the default info to the parent constructor, to install the record into the DB
*/
public function __construct($install = false) {
if ($install){
parent::__construct( array(
"name" => strip_namespace(get_class($this)),
"title" => "Prior Learning",
"path" => '/blocks/gradetracker/',
"version" => \ELBP\ELBP::getBlockVersionStatic()
) );
}
else
{
parent::__construct( strip_namespace(get_class($this)) );
}
}
public function ajax($action, $params, $ELBP) {
}
public function getSummaryBox() {
$TPL = new \ELBP\Template();
$TPL->set("obj", $this);
$user = new \GT\User($this->student->id);
$TPL->set("prior", $user->getQualsOnEntry());
$TPL->set("avgScore", $user->getAverageGCSEScore());
try {
return $TPL->load($this->CFG->dirroot . $this->path . 'tpl/elbp_prior_learning/summary.html');
}
catch (\ELBP\ELBPException $e){
return $e->getException();
}
}
public function getDisplay($params = array()){
$output = "";
$TPL = new \ELBP\Template();
$user = new \GT\User($this->student->id);
$TPL->set("prior", $user->getQualsOnEntry());
$TPL->set("avgScore", $user->getAverageGCSEScore());
$TPL->set("obj", $this);
$TPL->set("access", $this->access);
try {
$output .= $TPL->load($this->CFG->dirroot . $this->path . 'tpl/elbp_prior_learning/expanded.html');
} catch (\ELBP\ELBPException $e){
$output .= $e->getException();
}
return $output;
}
public function getConfigPath()
{
$path = $this->getPath() . 'config_'.$this->getName().'.php';
return $path;
}
public function install() {
global $DB;
$return = true;
$this->id = $this->createPlugin();
// Hooks
$DB->insert_record("lbp_hooks", array("pluginid" => $this->id, "name" => "English GCSE"));
$DB->insert_record("lbp_hooks", array("pluginid" => $this->id, "name" => "Maths GCSE"));
return $return;
}
public function upgrade() {
global $DB;
$return = true;
return $return;
}
public function _callHook_English_GCSE($obj, $params){
if (!$this->isEnabled()) return false;
if (!isset($obj->student->id)) return false;
// Load student
$this->loadStudent($obj->student->id);
$user = new \GT\User($this->student->id);
// $PL = new \UserPriorLearning();
$prior = $user->getQualsOnEntry();
if ($prior)
{
foreach($prior as $qual)
{
//return $qual->getSubjectName($qual->getSubjectID());
if ($qual->getType()->name == 'GCSE' && ($qual->getSubjectName($qual->getSubjectID()) == 'English' || $qual->getSubjectName($qual->getSubjectID()) == 'English Language'))
{
return $qual->getGradeObject()->grade;
}
}
}
return get_string('na', 'block_gradetracker');
}
public function _callHook_Maths_GCSE($obj, $params){
if (!$this->isEnabled()) return false;
if (!isset($obj->student->id)) return false;
// Load student
$this->loadStudent($obj->student->id);
$user = new \GT\User($this->student->id);
// $PL = new \UserPriorLearning();
$prior = $user->getQualsOnEntry();
if ($prior)
{
foreach($prior as $qual)
{
if ($qual->getType()->name == 'GCSE' && ($qual->getSubjectName($qual->getSubjectID()) == 'Mathematics' || $qual->getSubjectName($qual->getSubjectID()) == 'Maths'))
{
return $qual->getGradeObject()->grade;
}
}
}
return get_string('na', 'block_gradetracker');
}
}