/** * This function print statistic about a user for a scorm organization * @param int $idscorm_organization id of the organization * @param int $idUser id of the user * @return string to output **/ function scorm_userstat($idscorm_organization, $idUser, $idReference = NULL, $mvc = false) { require_once dirname(__FILE__) . '/scorm_items_track.php'; require_once dirname(__FILE__) . '/CPManagerDb.php'; require_once dirname(__FILE__) . '/RendererBase.php'; // get idscorm_package $query = "SELECT idscorm_package, org_identifier " . " FROM %lms_scorm_organizations" . " WHERE idscorm_organization = '" . $idscorm_organization . "'"; $rs = sql_query($query) or communicationError("3"); list($idscorm_package, $org_identifier) = sql_fetch_row($rs); $it = new Scorm_ItemsTrack($GLOBALS['dbConn'], $GLOBALS['prefix_lms']); $org_info = $it->getItemsInfo($idReference, NULL, $idscorm_organization); $output = ""; $str = "<br />" . (!$mvc ? "<div class=\"std_block\">" : ""); if ($mvc) { $output .= $str; } else { $GLOBALS['page']->add($str, 'content'); } $cpm = new CPManagerDb(); $cpm->Open($idReference, $idscorm_package, $GLOBALS['dbConn'], $GLOBALS['prefix_lms']); $cpm->ParseManifest(); $rb = new RendererDefaultImplementation(); $rb->imgPrefix = getPathImage() . 'treeview/'; $rb->imgOptions = 'width="24" height="24"'; $rb->showlinks = FALSE; $rb->showit = TRUE; $rb->itemtrack = $it; $rb->idUser = $idUser; $rb->resBase = ""; if (function_exists('cbMakeReportLink')) { $rb->linkCustomCallBack = 'cbMakeReportLink'; } //$rb->renderStatusCallBack = "renderStatus"; $str = $cpm->RenderOrganization($org_identifier, $rb); if ($mvc) { $output .= $str; } else { $GLOBALS['page']->add($str, 'content'); } if (!$mvc) { $GLOBALS['page']->add("</div>", 'content'); } if ($mvc) { return $output; } }
$resultProg = sql_query($query, $GLOBALS['dbConn']); if (!$resultProg) { die("Error in query " . $query); } list($idscorm_package, $filepath, $organization, $scormVersion) = sql_fetch_row($resultProg); ob_clean(); $it = new Scorm_ItemsTrack($GLOBALS['dbConn'], $GLOBALS['prefix_lms']); $rb = new RendererXML(); $rb->idUser = getLogUserId(); $rb->itemtrack = $it; $cpm = new CPManagerDb(); $filepath = dirname(__FILE__) . '/../../' . $filepath; //die("->Open( $idReference, $idscorm_package, {$GLOBALS['dbConn']}, {$GLOBALS['prefix_lms']} "); if (!$cpm->Open($idReference, $idscorm_package, $GLOBALS['dbConn'], $GLOBALS['prefix_lms'])) { echo 'Error: ' . $cpm->errText . ' [' . $cpm->errCode . ']'; } if (!$cpm->ParseManifest()) { echo 'Error: ' . $cpm->errText . ' [' . $cpm->errCode . ']'; } $idUser = (int) getLogUserId(); $rb->resBase = $filepath . "/"; $cpm->RenderOrganization($organization, $rb); header("Content-Type: text/xml; charset=utf-8"); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo $rb->getOut(); if ($cpm->errCode != 0) { echo 'Error: ' . $cpm->errText . ' [' . $cpm->errCode . ']'; } ob_end_flush(); exit; // to avoid index.php to add additional and unuseful html