#include "console.h" #include "s1000d_manager.h" #include #include #include using namespace std; // -SCORM -p "FULL, 2p" E:\C++\Test\01\auk-01_mi-38.lyx E:\C++\Test\01 // -SCORM -p "FULL" E:\C++\Test\AUK-01\01_mi-38.lyx E:\C++\Test\AUK-01 // -SCORM E:\C++\Test\AUK02_Mi38\auk-02_mi-38.lyx E:\C++\Test\AUK02_Mi38 console::console() { } int console::exec(int argc, char *argv[]) { //Q_UNUSED(argc) if(QString(argv[1]) == "-?" || QString(argv[1]) == "-h" || QString(argv[1]) == "/h" || argc < 3) { printHelp(); return 0; } exportSCORM = exportS1000D = exportSingleSCORM = false; for(int i = 1; i < argc-2; i++) { if(QString(argv[i]).toUpper() == "-SCORM") exportSCORM = true; if(QString(argv[i]).toUpper() == "-SINGLESCORM") exportSingleSCORM = true; if(QString(argv[i]).toUpper() == "-S1000D") exportS1000D = true; if(QString(argv[i]).toLower() == "-p" && (i+1 HTML (%d sec) .. ", SM.timeConvert); std::cout << std::flush; QElapsedTimer timer; timer.start(); if(!lyx.Import(&SM, lyxFile, NULL)) { printf("ОШИБКА импорта LyX.\n"); return 1; } SM.LoadPackagesXML(); if(!isCodingFilled()) { // printf("Ошибка: кодирование S1000D не заполнено.\n"); // return 1; fillDefaultCoding(); } html.Generate(&SM, false, NULL); SM.LoadPackagesXML(); SM.timeConvert = (int)timer.elapsed()/1000; SM.SaveProject(); printf("Ok\n"); if(exportSCORM) { printf(" SCORM (%d sec):\n", SM.timeSCORM*packageNames.count()); if(packageNames.count() == 0) printf("Пакеты не заданы. Пропущено.\n"); else foreach(S1000D_Manager::PackageStruct pack, SM.packages) if(packageNames.contains(pack.cfgName)) { for(int i=0;i "+pack.exportFileName+"_SCORM"+".zip .. " ; printf("%s", s.toLocal8Bit().toStdString().c_str()); std::cout << std::flush; QApplication::processEvents(); bool res = SM.exportSCORM(dstPath, pack.exportFileName, pack.title, NULL); if(res) printf("Ok\n"); else printf("ОШИБКА экспорта\n"); } } if(exportSingleSCORM) { printf(" Single SCORM (%d sec):\n", SM.timeSingleSCORM*packageNames.count()); if(packageNames.count() == 0) printf("Пакеты не заданы. Пропущено.\n"); else { for(int i=0;i "+pack.exportFileName+".zip .. "; printf("%s", s.toLocal8Bit().toStdString().c_str()); std::cout << std::flush; QApplication::processEvents(); bool res = SM.exportS1000D(dstPath, pack.exportFileName, pack.title, NULL); if(res) printf("Ok\n"); else printf("ОШИБКА экспорта\n"); } } SM.SaveProject(); //SM.SavePackagesXML(); return 0; } void console::printHelp() { setlocale(LC_ALL,"Russian"); qDebug() << "Конвертер АУК с формата LyX в пакеты стандартов S1000D и SCORM\n"; qDebug() << "Для запуска в оконном режиме запустите без параметров."; qDebug() << "Формирование пакетов в консольном режиме выполняется со следующими параметрами:"; qDebug() << "CONVERTER [-SCORM] [-S1000D] [-p \"package1, ...\"] lyxfile destpath\n"; qDebug() << " -SCORM - тип формируемого пакета - SCORM;"; qDebug() << " -SingleSCORM - тип формируемого пакета - единый пакет SCORM по всем категориям (пакетам);"; qDebug() << " -S1000D - тип формируемого пакета - S1000D, без явного указания формируются оба типа; "; qDebug() << " -p - сформировать пакеты с именами package1,... (список через запятую в \"кавычках\");"; qDebug() << " без данной опции формируются все созданные в оконном режиме пакеты;"; qDebug() << " lyxfile - путь и имя файла LyX;"; qDebug() << " dstpath - путь для размещения сформировнных пакетов."; } QString console::delYYY(QString st) { return st.replace("X", "").replace("Y", "").replace("N", ""); } bool console::isCodingFilled() { tmpStrList.clear(); tmpIntList.clear(); if(SM.items.count() == 0) return false; for(int i=0;imoduleType == mtPM) { QString pmTitle, modelIdentCode, pmIssuer, pmNumber, pmVolume; title = pmTitle = SM.getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle"); modelIdentCode = SM.getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode"); pmIssuer = SM.getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer"); pmNumber = SM.getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber"); pmVolume = SM.getNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume"); if(pmTitle.isEmpty() || delYYY(pmIssuer).isEmpty() || delYYY(pmNumber).isEmpty() || delYYY(pmVolume).isEmpty()) { return false; } fCode = SM.pmIdentString("identAndStatusSection.pmAddress.pmIdent"); } if(SM.item->moduleType == mtDM) { QString modelIdentCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode"); QString systemDiffCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode"); QString systemCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode"); QString subSystemCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode"); QString subSubSystemCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode"); QString assyCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode"); QString disassyCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode"); QString disassyCodeVariant = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant"); QString infoCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode"); QString infoCodeVariant = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant"); QString itemLocationCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode"); QString learnCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode"); QString learnEventCode = SM.getNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode"); QString techName = SM.getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName"); //QString infoName = SM.getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.infoName"); if(delYYY(modelIdentCode).isEmpty() || delYYY(systemDiffCode).isEmpty() || delYYY(systemCode).isEmpty() || delYYY(subSystemCode).isEmpty() || delYYY(subSubSystemCode).isEmpty() || delYYY(assyCode).isEmpty() || delYYY(disassyCode).isEmpty() || delYYY(disassyCodeVariant).isEmpty() || delYYY(infoCode).isEmpty() || delYYY(infoCodeVariant).isEmpty() || delYYY(itemLocationCode).isEmpty() || delYYY(learnCode).isEmpty() || delYYY(learnEventCode).isEmpty() || delYYY(techName).isEmpty() ) { return false; } title = techName; fCode = SM.dmIdentString("identAndStatusSection.dmAddress.dmIdent"); } int tmpInd = tmpStrList.indexOf(fCode); if(tmpInd != -1) { SM.setCurItem(tmpIntList[tmpInd]); QString title2; if(SM.item->moduleType == mtDM) title2 = SM.getNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName"); else title2 = SM.getNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle"); return false; } tmpStrList.append(fCode); tmpIntList.append(ind); for(int i=0;imoduleType == mtPM) { SM.setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "modelIdentCode", QString::number(pmCnt++)); SM.setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmIssuer", "ORIG"); SM.setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmNumber", "GTC00"); SM.setNodeAttr("identAndStatusSection.pmAddress.pmIdent.pmCode", "pmVolume", "00"); SM.item->fileCode = SM.pmIdentString("identAndStatusSection.pmAddress.pmIdent"); } if (SM.item->moduleType == mtDM) { SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "modelIdentCode", "DinamikaEDoc"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemDiffCode", "A"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "systemCode", "00"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSystemCode", "0"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "subSubSystemCode", QString::number(dmCnt++)); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "assyCode", "00"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCode", "00"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "disassyCodeVariant", "A"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCode", "010"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "infoCodeVariant", "A"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "itemLocationCode", "A"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnCode", "T40"); SM.setNodeAttr("identAndStatusSection.dmAddress.dmIdent.dmCode", "learnEventCode", "C"); SM.item->fileCode = SM.dmIdentString("identAndStatusSection.dmAddress.dmIdent"); } for (int i = 0; i < SM.items[ind].child.count(); i++) fillDefaultCodingRecurs(SM.items[ind].child[i]); }