You are here

private function OpignoScormPlayer::opignoScormPlayerScormTree in Opigno SCORM 8

Same name and namespace in other branches
  1. 3.x src/OpignoScormPlayer.php \Drupal\opigno_scorm\OpignoScormPlayer::opignoScormPlayerScormTree()

Traverse the SCORM package data and construct a SCO tree.

Parameters

object $scorm: Scorm object.

int $parent_identifier: Parent identifier.

Return value

array SCO tree.

1 call to OpignoScormPlayer::opignoScormPlayerScormTree()
OpignoScormPlayer::toRendarableArray in src/OpignoScormPlayer.php
Build rendarable array for scorm package output.

File

src/OpignoScormPlayer.php, line 105

Class

OpignoScormPlayer
Class OpignoScormPlayer.

Namespace

Drupal\opigno_scorm

Code

private function opignoScormPlayerScormTree($scorm, $parent_identifier = 0) {
  $conenction = $this->database;
  $tree = [];
  $result = $conenction
    ->select('opigno_scorm_package_scos', 'sco')
    ->fields('sco', [
    'id',
  ])
    ->condition('sco.scorm_id', $scorm->id)
    ->condition('sco.parent_identifier', $parent_identifier)
    ->execute();
  while ($sco_id = $result
    ->fetchField()) {
    $sco = $this->scorm_service
      ->scormLoadSco($sco_id);
    $children = $this
      ->opignoScormPlayerScormTree($scorm, $sco->identifier);
    $sco->children = $children;
    $tree[] = $sco;
  }
  return $tree;
}