Skip to content

Context / Context Activities #11

@drewbertola

Description

@drewbertola

Hi. I'd sure love to see an example of context (w/ contextActivities) in the docs. I'm struggling with this - probably unnecessarily.

Specifically, I'm trying to transcribe xAPI v0.9 statements (from Articulate StoryLine) into v.1.0.0 so that they can be pushed onto a LearningLocker LRS. I have the 0.9 statement decomposed, and have everything working except the contextActivities piece.

My code looks like this:

if ( ! empty($data->context) )
{
  $context = new TinCan_Context(array(
    "registration" => $data->context->registration,
  ));

  if ( ! empty($data->context->contextActivities) )
  {
    $contextActivities = new TinCan_ContextActivities(array(
      "grouping" => array("id" => $data->context->contextActivities->grouping->id),
      "parent"   => array("id" => $data->context->contextActivities->parent->id)
    ));

    $context->setContextActivities($contextActivities);
  }
}

The notice I'm getting is this:
PHP Warning: array_push() expects parameter 1 to be array, null given in /var/www/lc/library/TinCan/ContextActivities.php on line 80

which happens in ContextActivities.php in the array_push line here:

private function _listSetter($prop, $value) {
    if (is_array($value)) {
        if ( ! is_array($prop) ) {
        if (isset($value['id'])) {
            array_push($this->$prop, new TinCan_Activity($value));
        }

So, can you provide an example. It's skipped in the docs but it should prove very helpful.

Thanks, Drew

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions