14.06.2023

This commit is contained in:
Plotnikov
2023-06-14 18:08:32 +03:00
parent b0a0566f19
commit bdf6eab9ec
221 changed files with 203557 additions and 585 deletions

View File

@@ -554,23 +554,6 @@ QString S1000D_Manager::dmIdentString(QString dmIdentPath) {
//resStr += getNodeAttr(dmIdentPath+".issueInfo", "inWork");
return resStr;
}
QString S1000D_Manager::dmCodeIdentString(QDomNode node) {
QString resStr = "";
resStr += node.toElement().attribute("modelIdentCode")+"-";
resStr += node.toElement().attribute("systemDiffCode")+"-";
resStr += node.toElement().attribute("systemCode")+"-";
resStr += node.toElement().attribute("subSystemCode");
resStr += node.toElement().attribute("subSubSystemCode")+"-";
resStr += node.toElement().attribute("assyCode")+"-";
resStr += node.toElement().attribute("disassyCode");
resStr += node.toElement().attribute("disassyCodeVariant")+"-";
resStr += node.toElement().attribute("infoCode");
resStr += node.toElement().attribute("infoCodeVariant")+"-";
resStr += node.toElement().attribute("itemLocationCode");
QString learnStr = "-"+node.toElement().attribute("learnCode")+node.toElement().attribute("learnEventCode");
if(learnStr != "-") resStr += learnStr;
return resStr;
}
QString S1000D_Manager::pmIdentString(QString pmIdentPath) {
QString resStr = "";
@@ -1545,20 +1528,6 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
// }
resetICN();
for(int i=0;i<items.count();i++) {
setCurItem(i);
QString _issueInfo = "identAndStatusSection.dmAddress.dmIdent.issueInfo";
QString _language = "identAndStatusSection.dmAddress.dmIdent.language";
if(item->schemeType == stLEARNING) {
item->SCORM_fileName = "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
if(QFile::exists(SCORMpath+"/" + item->SCORM_fileName)) QFile::remove(SCORMpath+"/" + item->SCORM_fileName);
if(!QFile::copy(projectPath+"/"+item->fileName, SCORMpath+"/" + item->SCORM_fileName))
if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+item->fileName << "to" << SCORMpath+"/" + item->SCORM_fileName;
continue;
}
item->SCORM_fileName = "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".html";
}
for(int i=0;i<items.count();i++)
if(items[i].toExport && items[i].moduleType == mtDM) {
if(!isConsole) {
@@ -1575,7 +1544,9 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
}
return false;
}
QString htmlFileName = projectPath + "/" + item->fileName; htmlFileName.replace(".xml", ".html");
QString htmlFileName = projectPath + "/" + item->fileName;
if (item->schemeType != stLEARNING)
htmlFileName.replace(".xml", ".html");
if (item->moduleType == mtDM && !QFile::exists(htmlFileName) && item->schemeType != stLEARNING) {
if(!isConsole) {
splash->hide();
@@ -1584,6 +1555,16 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
}
return false;
}
QString _issueInfo = "identAndStatusSection.dmAddress.dmIdent.issueInfo";
QString _language = "identAndStatusSection.dmAddress.dmIdent.language";
if(item->schemeType == stLEARNING) {
item->SCORM_fileName = SCORMpath+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
if(QFile::exists(item->SCORM_fileName)) QFile::remove(item->SCORM_fileName);
if(!QFile::copy(projectPath+"/"+item->fileName, item->SCORM_fileName))
if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+item->fileName << "to" << item->SCORM_fileName;
continue;
}
item->SCORM_fileName = SCORMpath+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".html";
QFile htmlFile(htmlFileName);
if (!htmlFile.open(QFile::ReadOnly | QFile::Text)){
@@ -1646,35 +1627,19 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
if(k > -1) {
QString fn = htmlText[j].mid(k+s.length(), htmlText[j].indexOf("\"",k+s.length())-k-s.length());
if(!fn.startsWith("#")) {
if(fn.contains(".html#")) { // межмодульная ссылка
fn = fn.left(fn.indexOf("#"));
QString name;
for(int n=0;n<items.count();n++) {
name = items[n].fileName;
name = name.replace(".xml", ".html");
if(fn == name) {
htmlText[j].replace(fn, items[n].SCORM_fileName);
name = "Ok"; break;
QDir dir(projectPath+"/"+fn.split("/")[0]);
QDir dir2(SCORMpath+"/"+fn.split("/")[0]);
if(dir.exists() && !dir2.exists())
if(!copyDir(projectPath+"/"+fn.split("/")[0], SCORMpath+"/"+fn.split("/")[0]))
{
if(!isConsole) {
splash->hide();
splash->ErrMessage("Ошибка", "href: Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+SCORMpath+"/"+fn.split("/")[0]+"'");
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
return false;
}
if(name != "Ok")
qDebug() << "HTML->SCORM - <a href: cant find DM "+fn;
}
else { // папки с Docs и т.д.
QDir dir(projectPath+"/"+fn.split("/")[0]);
QDir dir2(SCORMpath+"/"+fn.split("/")[0]);
if(dir.exists() && !dir2.exists())
if(!copyDir(projectPath+"/"+fn.split("/")[0], SCORMpath+"/"+fn.split("/")[0]))
{
if(!isConsole) {
splash->hide();
splash->ErrMessage("Ошибка", "href: Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+SCORMpath+"/"+fn.split("/")[0]+"'");
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
return false;
}
}
} //#
}
} //<a href=
//s = "<iframe ";
@@ -1722,8 +1687,8 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
// onmousemove="showTooltipImg(evt, 'inline.svg');"
// <iframe src="fuselage/index.html" width="100%" height="580px" align="center">
if(QFile::exists(SCORMpath+"/" + item->SCORM_fileName)) QFile::remove(SCORMpath+"/" + item->SCORM_fileName);
QFile htmlOutFile(SCORMpath+"/" + item->SCORM_fileName);
if(QFile::exists(item->SCORM_fileName)) QFile::remove(item->SCORM_fileName);
QFile htmlOutFile(item->SCORM_fileName);
if (htmlOutFile.open(QFile::WriteOnly | QFile::Text)) {
QTextStream out(&htmlOutFile); out.setCodec("UTF-8");
for(int j=0;j<htmlText.count();j++)
@@ -1816,18 +1781,9 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
params << "a"<<"-r"<<"-y" << QString(packDir+"/"+packName+".zip") << QString(SCORMpath+"/*.*") << ">nul";
QProcess pc;
pc.start(QString(QCoreApplication::applicationDirPath()+"/7z.exe"), params, QIODevice::ReadWrite);
if(pc.waitForStarted(2000))
while(!pc.waitForFinished(50)) {
if(!isConsole) {splash->Step();}
QCoreApplication::processEvents();
}
else {
qDebug() << "Failed to start 7z";
if(!isConsole) {
splash->hide();
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
return false;
while(!pc.waitForFinished(50)) {
if(!isConsole) {splash->Step(); splash->Step(); splash->Step(); }
QCoreApplication::processEvents();
}
}
else
@@ -1835,19 +1791,10 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
params << "a"<<"-r"<<"-y" << QString(packDir+"/"+packName+".zip") << QString(SCORMpath+"/*.*");// << ">nul";
QProcess pc;
pc.start("7z", params, QIODevice::ReadWrite);
if(pc.waitForStarted(2000))
while(!pc.waitForFinished(50))
{
if(!isConsole) {splash->Step();}
QCoreApplication::processEvents();
}
else {
qDebug() << "Failed to start 7z";
if(!isConsole) {
splash->hide();
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
return false;
while(!pc.waitForFinished(50))
{
if(!isConsole) {splash->Step(); splash->Step(); splash->Step(); }
QCoreApplication::processEvents();
}
}
@@ -2276,162 +2223,7 @@ bool S1000D_Manager::exportS1000D(QString dirName, QString packName, QString pac
return true;
}
/*
void S1000D_Manager::searchPrepare() {
item->searchList.clear();
QList<QDomNode> nodeList;
nodeList.append(item->doc.namedItem("dmodule"));
QDomNode node;
while(!nodeList.isEmpty()) {
node = nodeList.takeFirst();
searchListStruct sItem;
sItem.name = node.nodeName(); sItem.node = node;
item->searchList.append(sItem);
for(int k=0;k<node.childNodes().count();k++)
nodeList.append(node.childNodes().at(k));
}
}
QDomNode S1000D_Manager::searchNodeWithTag(QString tag) { //QDomNode startNode,
for(int i=0;i<item->searchList.count();i++)
if(item->searchList[i].name == tag) {
qDebug() << "Found node " + tag;
return item->searchList[i].node;
}
QDomNode nullNode;
return nullNode;
}
QDomNode S1000D_Manager::searchNodeWithAttr(QString attrName, QString attrVal) { //QDomNode startNode,
for(int i=0;i<item->searchList.count();i++) {
if(item->searchList[i].node.toElement().hasAttribute(attrName) && item->searchList[i].node.toElement().attribute(attrName) == attrVal)
return item->searchList[i].node;
}
QDomNode nullNode;
return nullNode;
}
*/
// targetPath="//lcInstruction/description/levelledPara[attribute::id = 'para-000' and child::levelledPara[fn:position() = 1]]"
QString S1000D_Manager::makeNodeXPath(QDomNode node) {
if(item->doc.namedItem("dmodule").childNodes().count() == 0)
qDebug() << "Empty item: " << itemIndex << item->fileName << item->doc.namedItem("dmodule").nodeName() << item->doc.namedItem("dmodule").childNodes().count();
//else
// qDebug() << itemIndex << "Ok";
QString path="";
QString pos;
int ind=-1, cnt=0;
QDomNode cur = node;
QDomNode chNode;
//if(node.nodeName() == "blankRefNode9")
// qDebug() << "blankRefNode9 debug";
while(1) {
pos = "";
if(!cur.parentNode().isNull()) {
cnt = 0; ind = 0;
for(int i=0;i<cur.parentNode().childNodes().count();i++) {
chNode = cur.parentNode().childNodes().at(i);
if(chNode.nodeName() == cur.nodeName())
cnt++;
if(chNode == cur) {
//if(node.nodeName() == "blankRefNode9")
// qDebug() << "blankRefNode9 debug: " << "cur: " << cur.nodeName() << cnt << " parent: " << cur.parentNode().nodeName();
ind = cnt;
}
}
if(cnt > 1)
pos = "["+QString::number(ind)+"]";
}
path = "/"+cur.nodeName()+pos+path;
if(cur.parentNode().isNull() || cur.parentNode().nodeName() == "#document") {
//if(cur.parentNode().nodeName() != "#document")
// qDebug() << "makeNodeXPath: parentNode("+cur.nodeName()+").isNull";
break;
}
cur = cur.parentNode();
};
QDomNode nd = getNodeFromXPath(path); //, true
if(nd.nodeName() != node.nodeName())
qDebug() << "makeNodeXPath fail: Need "+node.nodeName()+node.nodeType()+" Found "+nd.nodeName()+nd.nodeType()+" Path "+path+"";
//else
// qDebug() << "makeNodeXPath OK";
//if(path.contains("description/para")) {
// qDebug() << "makeNodeXPath: description/para !! " << path << item->fileName;
//}
return path;
}
QDomNode S1000D_Manager::getNodeFromXPath(QString path, bool debugTrace) {
QStringList list = path.mid(1).split("/");
if(debugTrace) qDebug() << "getNodeFromXPath: "+path;
QDomNode node = item->doc.namedItem("dmodule").parentNode(); //namedItem("dmodule").parentNode(); //namedItem("#document")
if(node.isNull()) {
//if(debugTrace)
qDebug() << " node is NULL: item->doc.namedItem(dmodule).parentNode()";
if(debugTrace) qDebug() << " " << itemIndex << item->fileName << item->doc.namedItem("dmodule").nodeName() << item->doc.namedItem("dmodule").childNodes().count();
if(debugTrace)
for(int i=0;i<item->doc.childNodes().count();i++) {
qDebug() << " " << item->doc.childNodes().at(i).nodeName() << item->doc.childNodes().at(i).childNodes().count();
for(int j=0;j<item->doc.childNodes().at(i).childNodes().count();j++) {
qDebug() << " " << item->doc.childNodes().at(i).childNodes().at(j).nodeName() << item->doc.childNodes().at(i).childNodes().at(j).childNodes().count();
for(int k=0;k<item->doc.childNodes().at(i).childNodes().at(j).childNodes().count();k++)
qDebug() << " " << item->doc.childNodes().at(i).childNodes().at(j).childNodes().at(k).nodeName() << item->doc.childNodes().at(i).childNodes().at(j).childNodes().at(k).childNodes().count();
}
}
QDomNode nullNode;
return nullNode;
}
int pos;
if(debugTrace) qDebug() << " ------------------------- ";
while(list.count() > 0) {
if(debugTrace) {
qDebug() << " node: "+node.nodeName()+" child cnt: "+QString::number(node.childNodes().count());
for(int i=0;i<node.childNodes().count();i++)
qDebug() << " "+node.childNodes().at(i).nodeName();
}
QString name = list.takeFirst();
int b = name.indexOf("[");
QString _name = name.mid(0, b);
if(b == -1)
node = node.namedItem(name);
else {
pos = name.mid(b+1, name.indexOf("]")-(b+1)).toInt();
int cnt=0;
bool found = false;
for(int i=0;i<node.childNodes().count();i++) {
if(node.childNodes().at(i).nodeName() == _name)
cnt++;
if(cnt == pos) {
node = node.childNodes().at(i);
found = true;
break;
}
}
if(!found) {
qDebug() << "getNodeFromXPath: node "+_name+" at pos "+name.mid(b+1, name.indexOf("]")-(b+1))+" NOT FOUND ("+path+")";
//for(int i=0;i<node.childNodes().count();i++)
// qDebug() << " "+node.childNodes().at(i).nodeName();
QDomNode nullNode;
return nullNode;
}
}
if(debugTrace) qDebug() << " need: "+name+" found: "+node.nodeName();
}
if(debugTrace) qDebug() << "--Result node: "+node.nodeName();
//if(!node.nodeName().startsWith("blankRefNode"))
// qDebug() << "Rename "+node.nodeName()+" to REF ("+path+")";
return node;
}
/*