aboutsummaryrefslogtreecommitdiff
path: root/lib/elearning/ContentModule.class.php
blob: 1b2921bdefb06ff72ce21d43bb0426d9979adb61 (plain)
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO

/**
* class to handle content module data
*
* This class contains methods to handle connected content module data.
*
* @author   Arne Schröder <schroeder@data-quest.de>
* @access   public
* @modulegroup  elearning_interface_modules
* @module       ContentModule
* @package  ELearning-Interface
*/
abstract class ContentModule
{
    /**
     * Fetches data from conencted cms.
     */
    abstract function readData();

    var $id;
    var $title;
    var $module_type;
    var $module_type_name;
    var $icon_file;
    var $cms_type;
    var $cms_name;
    var $description;
    var $authors;
    var $is_connected;
    var $is_dummy;
    var $allowed_operations;

    var $db_class;
    var $view;
    /**
    * constructor
    *
    * init class. don't call directly, class is loaded by ConnectedCMS.
    * @access public
    * @param string $module_id module-id
    * @param string $module_type module-type
    * @param string $cms_type system-type
    */
    function __construct($module_id, $module_type, $cms_type)
    {
        global $connected_cms;

        $this->is_dummy = false;
        $this->setCMSType($cms_type);
        $this->setModuleType($module_type);
        if ($module_id != "")
        {
            $this->setId($module_id);

            $this->readData();
        }
        $this->view = new ContentModuleView($this->cms_type);

/**/    }

/*  // Dummy-method. Must be overwritten by subclass.
    function readData()
    {
        return false;
    }
*/

    /**
    * set id
    *
    * sets id
    * @access public
    * @param string $module_id id
    */
    function setId($module_id)
    {
        $this->id = $module_id;
    }

    /**
    * get id
    *
    * returns id
    * @access public
    * @return string id
    */
    function getId()
    {
        return $this->id;
    }

    /**
    * set cms-type
    *
    * sets cms-type
    * @access public
    * @param string $module_cms_type cms-type
    */
    function setCMSType($module_cms_type)
    {
        global $ELEARNING_INTERFACE_MODULES;
        $this->cms_type = $module_cms_type;
        $this->cms_name = $ELEARNING_INTERFACE_MODULES[$module_cms_type]["name"];
    }

    /**
    * get cms-type
    *
    * returns cms-type
    * @access public
    * @return string cms-type
    */
    function getCMSType()
    {
        return $this->cms_type;
    }

    /**
    * get cms name
    *
    * returns cms name
    * @access public
    * @return string cms name
    */
    function getCMSName()
    {
        return $this->cms_name;
    }

    /**
    * set module-type
    *
    * sets module-type
    * @access public
    * @param string $module_type module-type
    */
    function setModuleType($module_type)
    {
        global $ELEARNING_INTERFACE_MODULES;
        $this->module_type = $module_type;
        $this->module_type_name = $ELEARNING_INTERFACE_MODULES[$this->cms_type]["types"][$module_type]["name"];
        $this->icon_file = $ELEARNING_INTERFACE_MODULES[$this->cms_type]["types"][$module_type]["icon"];
    }

    /**
    * get module-type
    *
    * returns module-type
    * @access public
    * @return string module-type
    */
    function getModuleType()
    {
        return $this->module_type;
    }

    /**
    * get module-type name
    *
    * returns module-type name
    * @access public
    * @return string module-type name
    */
    function getModuleTypeName()
    {
        return $this->module_type_name;
    }

    /**
    * set title
    *
    * sets title
    * @access public
    * @param string $module_title title
    */
    function setTitle($module_title)
    {
        $this->title = $module_title;
    }

    /**
    * get title
    *
    * returns title
    * @access public
    * @return string title
    */
    function getTitle()
    {
        return $this->title;
    }

    /**
    * set description
    *
    * sets description
    * @access public
    * @param string $module_description description
    */
    function setDescription($module_description)
    {
        $this->description = $module_description;
    }

    /**
    * get description
    *
    * returns description
    * @access public
    * @return string description
    */
    function getDescription()
    {
        return $this->description;
    }

    /**
    * set authors
    *
    * sets authors
    * @access public
    * @param array $module_authors authors
    */
    function setAuthors($module_authors)
    {
        $this->authors = $module_authors;
    }

    /**
    * get authors
    *
    * returns authors
    * @access public
    * @return array authors
    */
    function getAuthors()
    {
        return $this->authors;
    }

    /**
    * set connection
    *
    * sets connection with seminar
    * @access public
    * @param string $seminar_id seminar-id
    * @return boolean successful
    */
    function setConnection($seminar_id)
    {
        $this->is_connected = true;
//      echo "$this->id, $this->module_type, $this->cms_type";
        return ObjectConnections::setConnection($seminar_id, $this->id, $this->module_type, $this->cms_type);
    }

    /**
    * unset connection
    *
    * unsets connection with seminar
    * @access public
    * @param string $seminar_id seminar-id
    * @return boolean successful
    */
    function unsetConnection($seminar_id)
    {
        $this->is_connected = false;
        return ObjectConnections::unsetConnection($seminar_id, $this->id, $this->module_type, $this->cms_type);
    }

    /**
    * set connection-status
    *
    * sets connection-status
    * @access public
    * @param boolean $is_connected connection-status
    */
    function setConnectionType($is_connected)
    {
        $this->is_connected = $is_connected;
    }

    /**
    * get connection-status
    *
    * returns true, if module is connected to seminar
    * @access public
    * @return boolean connection-status
    */
    function isConnected()
    {
        return $this->is_connected;
    }

    /**
    * get reference string
    *
    * returns reference string for content-module
    * @access public
    * @return string reference string
    */
    function getReferenceString()
    {
        return $this->cms_type."_".$this->module_type."_".$this->id;
    }

    /**
    * get icon-image
    *
    * returns icon-image
    * @access public
    * @return string icon-image
    */
    function getIcon()
    {
        if (!$this->icon_file) {
            $this->icon_file = 'learnmodule';
        }
        if (mb_strpos('http', $this->icon_file) === 0) {
            return "<img src=\"" . $this->icon_file . "\">";
        } else {
            return Icon::create($this->icon_file, 'inactive')->asImg();
        }
    }

    /**
    * get module-status
    *
    * returns true, if module is a dummy
    * @access public
    * @return boolean module-status
    */
    function isDummy()
    {
        return $this->is_dummy;
    }

    /**
    * create module-dummy
    *
    * sets title and description of module to display error-message
    * @access public
    * @param string $error error-type
    */
    function createDummyForErrormessage($error = "unknown")
    {
        global $connected_cms;

        switch($error)
        {
            case "no permission":
                $this->setTitle(_("--- Keine Lese-Berechtigung! ---"));
                $this->setDescription(sprintf(_("Sie haben im System \"%s\" keine Lese-Berechtigung für das Lernmodul, das dieser Veranstaltung / Einrichtung an dieser Stelle zugeordnet ist."), $this->getCMSName()));
                break;
            case "not found":
                $this->setTitle(_("--- Dieses Content-Modul existiert nicht mehr im angebundenen System! ---"));
                $this->setDescription(sprintf(_("Das Lernmodul, das dieser Veranstaltung / Einrichtung an dieser Stelle zugeordnet war, existiert nicht mehr. Dieser Fehler tritt auf, wenn das angebundene LCMS \"%s\" nicht erreichbar ist oder wenn das Lernmodul innerhalb des angebundenen Systems gelöscht wurde."), $this->getCMSName()));
                break;
            case "deleted":
                $this->setTitle(_("--- Dieses Content-Modul wurde im angebundenen System gelöscht! ---"));
                $this->setDescription(sprintf(_("Das Lernmodul, das dieser Veranstaltung / Einrichtung an dieser Stelle zugeordnet war, wurde gelöscht."), $this->getCMSName()));
                break;
            default:
                $this->setTitle(_("--- Es ist ein unbekannter Fehler aufgetreten! ---"));
                $this->setDescription(sprintf(_("Unbekannter Fehler beim Lernmodul mit der Referenz-ID \"%s\" im LCMS \"%s\""), $this->getId(), $this->getCMSName()));
        }

        $this->is_dummy = true;
    }

    /**
    * ask for permission for given operation
    *
    * dummy-method. returns false. must be overwritten by subclass.
    * @access public
    * @param string $operation operation
    * @return boolean returns false
    */
    function isAllowed($operation)
    {
        return false;
    }
}
?>