[svn r10779] Some fixes to get import of scorm manifest files back to work.

http://www.dokeos.com/forum/viewtopic.php?p=32960
skala
Bart Mollet 19 years ago
parent 08f1af47b8
commit 727ad61ddb
  1. 23
      main/metadata/importmanifest.php
  2. 21
      main/metadata/md_scorm.php

@ -60,11 +60,16 @@ require('md_phpdig.php');
if (isset($workWith)) // explicit in URL, or selected at bottom of screen if (isset($workWith)) // explicit in URL, or selected at bottom of screen
{ {
$scormdocument = Database::get_course_table('lp'); $scormdocument = Database::get_course_table('lp');
$sql = "SELECT id FROM $scormdocument WHERE path='". mysql_real_escape_string(substr($workWith,1)) . "'"; $sql = "SELECT id FROM $scormdocument WHERE path='". mysql_real_escape_string(substr($workWith,1)) . "' OR path='". mysql_real_escape_string(substr($workWith,1)) . "/.'";
$result = api_sql_query($sql, __FILE__, __LINE__); $result = api_sql_query($sql, __FILE__, __LINE__);
if (mysql_num_rows($result) == 1) if (mysql_num_rows($result) == 1)
if (($row = mysql_fetch_array($result))) $sdi = $row['id']; {
if (($row = mysql_fetch_array($result)))
{
$sdi = $row['id'];
}
}
} }
if (isset($sdi) && is_numeric($sdi) && $sdi > 0 && $sdi == (int) $sdi) if (isset($sdi) && is_numeric($sdi) && $sdi > 0 && $sdi == (int) $sdi)
@ -102,8 +107,8 @@ $originalHdrInfo = $hdrInfo;
function slurpmanifest() function slurpmanifest()
{ {
global $baseWorkDir, $workWith, $sdisub, $mfContents, $xht_doc; global $baseWorkDir, $workWith, $sdisub, $mfContents, $xht_doc;
$fmff = $baseWorkDir .'/'. $workWith . '/' . MFFNAME . $sdisub . MFFDEXT;
if (file_exists($fmff = $baseWorkDir . $workWith . '/' . MFFNAME . $sdisub . MFFDEXT)) if (file_exists($fmff))
{ {
if (($mfContents = @fgc($fmff))) if (($mfContents = @fgc($fmff)))
{ {
@ -114,9 +119,15 @@ function slurpmanifest()
unset($mfContents); unset($mfContents);
return get_lang('ManifestSyntax') . ' ' . htmlspecialchars($xht_doc->error); return get_lang('ManifestSyntax') . ' ' . htmlspecialchars($xht_doc->error);
} }
else return get_lang('EmptyManifest'); else
{
return get_lang('EmptyManifest');
}
}
else
{
return get_lang('NoManifest');
} }
else return get_lang('NoManifest');
} }
if (isset($workWith)) // now checked to be a valid path in scormdocument if (isset($workWith)) // now checked to be a valid path in scormdocument

@ -80,21 +80,26 @@ function mdobject($_course, $id)
{ {
global $ieee_dcmap_e, $ieee_dcmap_v; // md_funcs global $ieee_dcmap_e, $ieee_dcmap_v; // md_funcs
$scormdocument = Database::get_course_table(TABLE_SCORMDOC); $scormdocument = Database::get_course_table('lp');
$this->mdo_course = $_course; $this->mdo_type = 'Scorm'; $this->mdo_course = $_course; $this->mdo_type = 'Scorm';
$this->mdo_id = $id; $this->mdo_eid = $this->mdo_type . '.' . $id; $this->mdo_id = $id; $this->mdo_eid = $this->mdo_type . '.' . $id;
$this->mdo_dcmap_e = $ieee_dcmap_e; $this->mdo_dcmap_v = $ieee_dcmap_v; $this->mdo_dcmap_e = $ieee_dcmap_e; $this->mdo_dcmap_v = $ieee_dcmap_v;
$sql = "SELECT path,description,lp_type FROM $scormdocument WHERE id='" . addslashes($id) . "'";
if (($docinfo = @mysql_fetch_array(api_sql_query( if (($docinfo = @mysql_fetch_array(api_sql_query($sql,__FILE__, __LINE__))))
"SELECT path,comment,filetype FROM $scormdocument
WHERE id='" . addslashes($id) . "'",
__FILE__, __LINE__))))
{ {
$this->mdo_path = $docinfo['path']; $this->mdo_path = $docinfo['path'];
$this->mdo_comment = $docinfo['comment']; //Sometimes the new scorm-tool adds '/.' at the end of a directory name, so remove this before continue
$this->mdo_filetype = $docinfo['filetype']; //the process -- bmol
if(substr($this->mdo_path,-2) == '/.')
{
$this->mdo_path = substr($this->mdo_path,0, strlen($this->mdo_path)-2);
}
$this->mdo_comment = $docinfo['description'];
//Don't think the next line is correct. There used to be a 'type' field in the scormdocument table.
//This metadata tool only works on folder types -- bmol
$this->mdo_filetype = ($docinfo['lp_type'] == 2 ? 'folder' : 'xxx');
$this->mdo_url = get_course_web() . $this->mdo_course['path'] . $this->mdo_url = get_course_web() . $this->mdo_course['path'] .
'/scorm' . $this->mdo_path . '/index.php'; '/scorm' . $this->mdo_path . '/index.php';

Loading…
Cancel
Save