Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
H5P-PHP-Report
2
==========
3
 
4
A generic library for rendering H5P reports for content types based on their
5
xAPI statements.
6
 
7
## Usage
8
 
9
1. To start with we need xAPI data from the content we will render, covered in [Content type requirements](#content-type-requirements).
10
2. We can then call ```H5PReport->generateReport``` with the content statement and an optional parent ID. Parent ID is provided if the content type is the parent of other content. This can be determined from its children.
11
3. Returned is HTML for the complete report.
12
 
13
### Generate report
14
 
15
Generate report expect a special format of the xAPI data, an object with the
16
several properties. Following is a simple example:
17
 
18
```php
19
(object) array(
20
  'interaction_type' => 'choice',
21
  'description' => 'Do you like cake ?',
22
  'correct_responses_pattern' => '[0]',
23
  'response': '2',
24
  'extras': '{"choices":[{"id":0,"description":{"en-US":"Of course, who doesn't ?"}},{"id":1,"description":{"en-US":"No"}},{"id":2,"description":{"en-US":"What is a cake ?"}}},'
25
)
26
```
27
 
28
Note that ```correct_responses_pattern``` and ```extras``` should be json
29
encoded.
30
 
31
## Content type requirements
32
 
33
The plugin requires content types to implement the ```getXAPIData``` [contract](https://h5p.org/documentation/developers/contracts#guides-header-6)
34
 in order to get the proper reports with a ```statement``` object and an optional
35
```children``` array:
36
```javascript
37
getXAPIData = function () {
38
  return {
39
    statement: {},
40
    children: []
41
  }
42
}
43
```
44
 
45
### Statement
46
 
47
The statement object is a standard xAPI statement, which should adhere to the
48
 [xAPI specification](https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#table-of-contents). You can
49
 see an example for how this looks for [True False question](https://h5p.org/true-false) in [Appendix A](#appendix-a).
50
 
51
 
52
### Children
53
 
54
The children array is a collection of statements for the children of the
55
content.
56
An Interactive Video with "Summary" and "Mark The Words" content inside of it would have its own statement and two children items with their own statements.
57
Children may also have children, so you can follow the chain all the way down to the lowest level.
58
A complete example of [Single Choice Set](https://h5p.org/single-choice-set) can be found in [Appendix B](#appendix-b).
59
 
60
## Appendix A
61
 
62
An example of an xAPI statement from [True False question](https://h5p.org/true-false).
63
 
64
```json
65
{
66
  "actor":{
67
    "name":"user",
68
    "mbox":"mailto:user@mail.com",
69
    "objectType":"Agent"
70
  },
71
  "verb":{
72
    "id":"http://adlnet.gov/expapi/verbs/answered",
73
    "display":{
74
      "en-US":"answered"
75
    }
76
  },
77
  "object":{
78
    "id":"https://h5p.org/true-false",
79
    "objectType":"Activity",
80
    "definition":{
81
      "extensions":{
82
        "http://h5p.org/x-api/h5p-local-content-id":34806
83
      },
84
      "name":{
85
        "en-US":"True/False Question"
86
      },
87
      "interactionType":"true-false",
88
      "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
89
      "description":{
90
        "en-US":"Oslo is the capital of Norway.\n"
91
      },
92
      "correctResponsesPattern":[
93
        "True"
94
      ]
95
    }
96
  },
97
  "context":{
98
    "contextActivities":{
99
      "category":[
100
        {
101
          "id":"http://h5p.org/libraries/H5P.TrueFalse-1.0",
102
          "objectType":"Activity"
103
        }
104
      ]
105
    }
106
  },
107
  "result":{
108
    "score":{
109
      "min":0,
110
      "max":1,
111
      "raw":0,
112
      "scaled":0
113
    },
114
    "completion":true,
115
    "success":false,
116
    "duration":"PT4.92S",
117
    "response":""
118
  }
119
}
120
```
121
 
122
## Appendix B
123
 
124
An example of a complete ```getXAPIData``` call to [Single Choice Set](https://h5p.org/single-choice-set).
125
 
126
```json
127
{
128
  "statement":{
129
    "actor":{
130
      "name":"user",
131
      "mbox":"mailto:user@mail.com",
132
      "objectType":"Agent"
133
    },
134
    "verb":{
135
      "id":"http://adlnet.gov/expapi/verbs/answered",
136
      "display":{
137
        "en-US":"answered"
138
      }
139
    },
140
    "object":{
141
      "id":"https://h5p.org/single-choice-set",
142
      "objectType":"Activity",
143
      "definition":{
144
        "interactionType":"compound",
145
        "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
146
        "extensions":{
147
          "http://h5p.org/x-api/h5p-local-content-id":1515
148
        }
149
      }
150
    },
151
    "result":{
152
      "duration":"PT0S",
153
      "score":{
154
        "raw":0,
155
        "min":0,
156
        "max":3,
157
        "scaled":0
158
      }
159
    }
160
  },
161
  "children":[
162
    {
163
      "statement":{
164
        "actor":{
165
          "name":"user",
166
          "mbox":"mailto:user@mail.com",
167
          "objectType":"Agent"
168
        },
169
        "verb":{
170
          "id":"http://adlnet.gov/expapi/verbs/answered",
171
          "display":{
172
            "en-US":"answered"
173
          }
174
        },
175
        "context":{
176
          "contextActivities":{
177
            "parent":[
178
              {
179
                "id":"https://h5p.org/single-choice-set",
180
                "objectType":"Activity"
181
              }
182
            ]
183
          }
184
        },
185
        "object":{
186
          "id":"https://h5p.org/single-choice-set?subContentId=51445ea9-9c98-437a-8981-72d46d6e86c4",
187
          "objectType":"Activity",
188
          "definition":{
189
            "description":{
190
              "en-US":"Goji berries are also known as ..."
191
            },
192
            "interactionType":"choice",
193
            "correctResponsesPattern":[
194
              "0"
195
            ],
196
            "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
197
            "choices":[
198
              {
199
                "id":"0",
200
                "description":{
201
                  "en-US":"Wolfberries"
202
                }
203
              },
204
              {
205
                "id":"1",
206
                "description":{
207
                  "en-US":"Catberries"
208
                }
209
              },
210
              {
211
                "id":"2",
212
                "description":{
213
                  "en-US":"Bearberries"
214
                }
215
              }
216
            ],
217
            "extensions":{
218
              "http://h5p.org/x-api/h5p-local-content-id":1515,
219
              "http://h5p.org/x-api/h5p-subContentId":"51445ea9-9c98-437a-8981-72d46d6e86c4"
220
            }
221
          }
222
        },
223
        "result":{
224
          "response":"",
225
          "duration":"PT0S",
226
          "score":{
227
            "raw":0,
228
            "min":0,
229
            "max":1,
230
            "scaled":0
231
          }
232
        }
233
      }
234
    },
235
    {
236
      "statement":{
237
        "actor":{
238
          "name":"user",
239
          "mbox":"mailto:user@mail.com",
240
          "objectType":"Agent"
241
        },
242
        "verb":{
243
          "id":"http://adlnet.gov/expapi/verbs/answered",
244
          "display":{
245
            "en-US":"answered"
246
          }
247
        },
248
        "context":{
249
          "contextActivities":{
250
            "parent":[
251
              {
252
                "id":"https://h5p.org/single-choice-set",
253
                "objectType":"Activity"
254
              }
255
            ]
256
          }
257
        },
258
        "object":{
259
          "id":"https://h5p.org/single-choice-set?subContentId=95b60491-e203-4bc5-956c-89e966b1005d",
260
          "objectType":"Activity",
261
          "definition":{
262
            "description":{
263
              "en-US":"Goji berries are native to ..."
264
            },
265
            "interactionType":"choice",
266
            "correctResponsesPattern":[
267
              "0"
268
            ],
269
            "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
270
            "choices":[
271
              {
272
                "id":"0",
273
                "description":{
274
                  "en-US":"Asia"
275
                }
276
              },
277
              {
278
                "id":"1",
279
                "description":{
280
                  "en-US":"Africa"
281
                }
282
              },
283
              {
284
                "id":"2",
285
                "description":{
286
                  "en-US":"Europe"
287
                }
288
              }
289
            ],
290
            "extensions":{
291
              "http://h5p.org/x-api/h5p-local-content-id":1515,
292
              "http://h5p.org/x-api/h5p-subContentId":"95b60491-e203-4bc5-956c-89e966b1005d"
293
            }
294
          }
295
        },
296
        "result":{
297
          "response":"",
298
          "duration":"PT0S",
299
          "score":{
300
            "raw":0,
301
            "min":0,
302
            "max":1,
303
            "scaled":0
304
          }
305
        }
306
      }
307
    },
308
    {
309
      "statement":{
310
        "actor":{
311
          "name":"user",
312
          "mbox":"mailto:user@mail.com",
313
          "objectType":"Agent"
314
        },
315
        "verb":{
316
          "id":"http://adlnet.gov/expapi/verbs/answered",
317
          "display":{
318
            "en-US":"answered"
319
          }
320
        },
321
        "context":{
322
          "contextActivities":{
323
            "parent":[
324
              {
325
                "id":"https://h5p.org/single-choice-set",
326
                "objectType":"Activity"
327
              }
328
            ]
329
          }
330
        },
331
        "object":{
332
          "id":"https://h5p.org/single-choice-set?subContentId=aa694288-df4d-4ed3-8f81-f47fa3d27fe4",
333
          "objectType":"Activity",
334
          "definition":{
335
            "description":{
336
              "en-US":"Goji berries are usually sold ..."
337
            },
338
            "interactionType":"choice",
339
            "correctResponsesPattern":[
340
              "0"
341
            ],
342
            "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
343
            "choices":[
344
              {
345
                "id":"0",
346
                "description":{
347
                  "en-US":"Dried"
348
                }
349
              },
350
              {
351
                "id":"1",
352
                "description":{
353
                  "en-US":"Pickled"
354
                }
355
              },
356
              {
357
                "id":"2",
358
                "description":{
359
                  "en-US":"Frozen"
360
                }
361
              }
362
            ],
363
            "extensions":{
364
              "http://h5p.org/x-api/h5p-local-content-id":1515,
365
              "http://h5p.org/x-api/h5p-subContentId":"aa694288-df4d-4ed3-8f81-f47fa3d27fe4"
366
            }
367
          }
368
        },
369
        "result":{
370
          "response":"",
371
          "duration":"PT0S",
372
          "score":{
373
            "raw":0,
374
            "min":0,
375
            "max":1,
376
            "scaled":0
377
          }
378
        }
379
      }
380
    }
381
  ]
382
}
383
```
384
 
385
## License
386
 
387
(The MIT License)
388
 
389
Copyright (c) 2016 Joubel AS
390
 
391
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
392
 
393
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
394
 
395
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.