Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-xapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Quentin Pimont
moodle-xapi
Commits
99d434af
Commit
99d434af
authored
7 years ago
by
Dasuntha Gunathunga
Browse files
Options
Downloads
Patches
Plain Diff
#130 - Delete records after sent them to LRS
parent
0f00cae0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
classes/log/store.php
+18
-3
18 additions, 3 deletions
classes/log/store.php
classes/task/emit_task.php
+1
-0
1 addition, 0 deletions
classes/task/emit_task.php
with
19 additions
and
3 deletions
classes/log/store.php
100644 → 100755
+
18
−
3
View file @
99d434af
...
...
@@ -150,10 +150,12 @@ class store extends php_obj implements log_writer {
$sentevents
=
[];
foreach
(
$eventbatches
as
$translatoreventsbatch
)
{
$xapievents
=
$xapicontroller
->
create_events
(
$translatoreventsbatch
);
foreach
(
array_keys
(
$xapievents
)
as
$key
)
{
$statements
=
$xapievents
[
'statements'
];
$response
=
$xapievents
[
'response'
];
foreach
(
array_keys
(
$statements
)
as
$key
)
{
if
(
is_numeric
(
$key
))
{
$k
=
$
xapiev
ents
[
$key
][
'context'
][
'extensions'
][
$translatoreventreadreturn
[
0
][
'context_ext_key'
]][
'id'
];
$sentevents
[
$k
]
=
$
xapievents
[
'
last_action_result
'
]
;
$k
=
$
statem
ents
[
$key
][
'context'
][
'extensions'
][
$translatoreventreadreturn
[
0
][
'context_ext_key'
]][
'id'
];
$sentevents
[
$k
]
=
$
this
->
get
last_action_result
(
$response
)
;
}
}
$this
->
error_log_value
(
'xapievents'
,
$xapievents
);
...
...
@@ -162,6 +164,19 @@ class store extends php_obj implements log_writer {
return
$sentevents
;
}
/**
* Get last action result from Learning Locker.
* @param Object TinCan\LRSResponse
*
*/
private
function
getlast_action_result
(
$response
){
if
(
$response
->
success
==
1
)
{
return
"success"
;
}
else
{
return
"failure"
;
}
}
private
function
error_log_value
(
$key
,
$value
)
{
$this
->
error_log
(
'['
.
$key
.
'] '
.
json_encode
(
$value
));
}
...
...
This diff is collapsed.
Click to expand it.
classes/task/emit_task.php
100644 → 100755
+
1
−
0
View file @
99d434af
...
...
@@ -53,6 +53,7 @@ class emit_task extends \core\task\scheduled_task {
foreach
(
array_keys
(
$storereturn
)
as
$eventid
)
{
if
(
$storereturn
[
$eventid
]
==
'success'
)
{
$DB
->
delete_records_list
(
'logstore_xapi_log'
,
'id'
,
array
(
$eventid
));
mtrace
(
"Event id "
.
$eventid
.
" has been successfully sent to LRS."
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment