knitr::opts_chunk$set(
  collapse = TRUE,
  message = FALSE,
  warning = FALSE,
  echo = TRUE,
  comment = "#>"
)

KoboToolbox audit logging feature records all activities related to a specific form submission in a log file. This log file can include things like when the form was opened, when individual questions were answered, when the form was saved, and when it was finally submitted. This feature provides a detailed record of the timing and sequence of events associated with each form submission.

This feature is particularly beneficial for several reasons:

Audit logging data

The following form provides a simplified example to demonstrate how audit logs can be read using robotoolbox.

library(robotoolbox)
library(dplyr)
l <- asset_list

| type | name | label | parameters | |:-----------|:-----------|:------------------------|:---------------------------------------------------------------------------| | start | start | | | | end | end | | | | username | username | | | | audit | audit | | identify-user=true location-priority=balanced location-min-interval=60 location-max-age=120 track-changes=true track-changes-reasons=on-form-edit | | text | Q1 | Q1. What is your name? | | | integer | Q2 | Q2. How old are you? | |

We have four metadata questions: start, end, username and audit. You need to have the audit metadata question enable to use this feature. We also have two questions: Q1 and Q2.

Loading the project

The above form was uploaded to the server. It's the only project named Audit multi params, and can be selected from the list of assets asset_list (using kobo_asset_list).

library(robotoolbox)
library(dplyr)
asset_list <- kobo_asset_list()
uid <- filter(asset_list, name == "Audit multi params") |>
  pull(uid)
asset <- kobo_asset(uid)
asset
asset <- asset_audit
asset

Extracting the audit data

In order to get the audit logging, we need to use the kobo_audit function.

df <- kobo_audit(asset)
glimpse(df)
df <- data_audit
glimpse(df)

The columns in the audit logging data include:

The structure of the output depends on the audit logging parameters you set in your form. For instance, if you set the parameter track-changes=true, the columns old-value and new-value become available. latitude, longitude and accuracy are associated to the parameter location-priority. The user column is available when you use the identify-user=true parameter. Using the parameter track-changes-reasons=on-form-edit prevents editing of filled-out forms without providing a reason. These reasons are recored in the change-reason column. You can learn how to use audit logging in the documentation of KoboToolbox and ODK.



dickoa/robotoolbox documentation built on July 12, 2024, 1:55 p.m.