Skip to content

Commit

Permalink
OAI-PMH Fix creation of educational LOM metadata table
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed May 16, 2023
1 parent b9f98c0 commit af889fb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions oai-pmh/management/educational.php
Expand Up @@ -21,17 +21,17 @@
foreach ($nodes as $node) {
$row = [];
$c = $node->children($ns['vdex']);
$row[label] = (string)$c->caption->langstring;
$row[ID] = (string)$c->termIdentifier;
$row['label'] = (string)$c->caption->langstring;
$row['ID'] = (string)$c->termIdentifier;
foreach ($relations as $relation){
$relationChild = $relation->children($ns['vdex']);
if ((string)$relationChild->sourceTerm == $row[ID] and (string)$relationChild->relationshipType == "BT") {
$row[parent] = (string)$relationChild->targetTerm;
$lookup[$row[ID]] = $row;
if ((string)$relationChild->sourceTerm == $row['ID'] and (string)$relationChild->relationshipType == "BT") {
$row['parent'] = (string)$relationChild->targetTerm;
$lookup[$row['ID']] = $row;
break;
}
}
$lookup[$row[ID]] = $row;
$lookup[$row['ID']] = $row;
}
insertEducational($lookup);

Expand All @@ -43,7 +43,7 @@ function createEducationalTable() {
$q = "CREATE TABLE IF NOT EXISTS {$prefix}oai_education(
education_id INT(11) PRIMARY KEY NOT NULL,
term_id VARCHAR(63) NOT NULL,
label VARCHAR(255) NOT NULL
label VARCHAR(255) NOT NULL,
parent_id INT(11))";

db_query($q);
Expand All @@ -67,17 +67,17 @@ function insertEducational($lookup, $termID = null, $label = null, $parent = nul
foreach ($lookup as $i => $row){
//generate serversideID populate both tables
$q = "INSERT INTO {$prefix}educationlevel(educationlevel_name) VALUES (?)";
$serverside_id = db_query_one($q,array($row[label]));
$lookup[$i][serverID] = $serverside_id;
$serverside_id = db_query_one($q,array($row['label']));
$lookup[$i]['serverID'] = $serverside_id;
$q2 = "INSERT INTO {$prefix}oai_education(education_id,term_id,label) VALUES (?,?,?)";
$params = array($serverside_id, $row[ID], $row[label]);
$params = array($serverside_id, $row['ID'], $row['label']);
$res = db_query($q2, $params);
}
foreach ($lookup as $row){
if (!is_null($row[parent])){
if (isset($row['parent'])){
$q3 = "update {$prefix}educationlevel SET parent_id = ? WHERE educationlevel_id = ?";
$parent_id = $lookup[$row[parent]][serverID];
$params = array($parent_id, $row[serverID]);
$parent_id = $lookup[$row['parent']]['serverID'];
$params = array($parent_id, $row['serverID']);
$res = db_query($q3, $params);
$q4 = "update {$prefix}oai_education SET parent_id = ? WHERE education_id = ?";
$res = db_query($q4, $params);
Expand Down

0 comments on commit af889fb

Please sign in to comment.