Commit c853c8cc authored by Aghiles's avatar Aghiles
Browse files

Merge branch 'master' of https://gitlab.utc.fr/crozatst/hdoc

parents 2ea5f2f6 16fe948d
......@@ -42,8 +42,8 @@ var removeDocument = function(db, collection, json) {
MongoClient.connect(url, function(err, db) {
assert.equal(null, err);
fs.readdir(outputFolder, (err, files) => {
files.forEach(file => {
fs.readdir(outputFolder, function(err, files) {
files.forEach(function(file) {
var json = JSON.parse(fs.readFileSync(outputFolder + "/" + file));
if(config.request === 'insert') {
insertDocument(db, config.collection, json);
......
#!/bin/sh
#!/bin/bash
lib="lib"
ant="hdoc_to_mongo.ant"
antparam="-Dprogram.param=$1"
......@@ -31,6 +31,4 @@ fi
#Lancer la commande
scJarList="$lib/*"
npm link mongodb
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam
rm -rf node_modules
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam
\ No newline at end of file
{
"url" : "http://localhost:28017/test",
"collection" : "nf29"
}
\ No newline at end of file
var config = {"url" : "http://localhost:28017/test","collection" : "nf29"}
\ No newline at end of file
......@@ -2,34 +2,34 @@
<head>
<title>page principale</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js" ></script>
<script type="text/javascript" src="config.jsonp"></script>
<script type="text/javascript">
jQuery("document").ready(function () {
$.getJSON('config.json', function (config) {
$.ajax({
url: config.url + "/" + config.collection + "/",
type: 'get',
dataType: 'jsonp',
jsonp: 'jsonp', // mongod is expecting the parameter name to be called "jsonp"
cache: false,
success: function (myData) {
for (var item in myData.rows) {
var model = jQuery("div[name='toFill']").first().clone();
model.find("a[name='link']").attr("href", "title.html#" + encodeURI(JSON.stringify(myData.rows[item])));
model.find("span[name='title']").text(myData.rows[item].title);
model.css("display", "block")
model.appendTo(jQuery("body").first());
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log('error', errorThrown + " " + textStatus);
function request() {
$.ajax({
url: config.url + "/" + config.collection + "/?" + decodeURI(document.location.href.split('#')[1]),
type: 'get',
dataType: 'jsonp',
jsonp: 'jsonp', // mongod is expecting the parameter name to be called "jsonp"
cache: false,
success: function (myData) {
for (var item in myData.rows) {
var model = jQuery("div[name='toFill']").first().clone();
model.find("a[name='link']").attr("href", "title.html#" + encodeURI(JSON.stringify(myData.rows[item])));
model.find("span[name='title']").text(myData.rows[item].title);
model.css("display", "block")
model.appendTo(jQuery("body").first());
}
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log('error', errorThrown + " " + textStatus);
}
});
});
}
jQuery("document").ready(request);
</script>
</head>
<body>
<input type="text" id="search" style="width:100%"/>
<form onsubmit="document.location.href = document.location.href.split('#')[0] + '#' + encodeURI($('#search').val()); document.location.reload(); return false;"><input type="text" id="search" style="width:100%" /></form>
<div name="toFill" style="display:none;">
<a href="" name="link">
<div style="width:100%; text-align: center; border: solid 1px black; padding: 5px; margin: 3px;">
......
#!/bin/bash
npm link mongodb
......@@ -1852,16 +1852,16 @@
<p id="spData">
</p>
<div style="text-align:center;"><a href="#todo">Lien de tlchargement</a></div>
<div style="text-align:center;"><a href="javascript:void()">Lien de tlchargement</a></div>
</div>
<div id="rwData" style="width: 35%; margin-top:0px; float:right;%">
<div id="rwData" style="width: 35%; margin-top:0px; float:right;">
<h2>Tags</h2>
</div>
</div>
<div id="preview" style="clear:both">
<div id="introduction" ></div>
<div style="text-align:center;">
<a href="#" onclick="loadFullText()">Lire plus ...</a>
<a href="javascript:void()" onclick="loadFullText()">Lire plus ...</a>
</div>
</div>
</div>
......
......@@ -6,7 +6,9 @@
<xsl:template name="config-main">
<xsl:param name="fileName"/>
<xsl:param name="inputPath"/>
"link" : <xsl:value-of select="h2m:escape-string(document('C:\Users\Kapil\Documents\Projets\github\hdoc\hdoc_to_mongo/input/config.xml')/config/file[@name = $fileName]/link)" />,
<xsl:if test="document('../../input/config.xml')/config/file[@name = $fileName]/link">
"link" : <xsl:value-of select="h2m:escape-string(document('../../input/config.xml')/config/file[@name = $fileName]/link)" />,
</xsl:if>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
......@@ -29,7 +29,7 @@
}
</xsl:template>
<xsl:template match="div[@data-hdoc-type='question']" >
<xsl:template match="div[@data-hdoc-type='question' and position() != last()]" >
{
<xsl:apply-templates select="div[@data-hdoc-type='description']"/>
<xsl:apply-templates select="div[@data-hdoc-type='solution']"/>
......
......@@ -4,6 +4,6 @@
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:function name="h2m:escape-string">
<xsl:param name="value"/>
"<xsl:value-of select="replace($value, '&quot;', '\\&quot;')"/>"
"<xsl:value-of select="translate(replace($value, '&quot;', '\\&quot;'), '&#13;&#10;&#x9;', ' ')"/>"
</xsl:function>
</xsl:stylesheet>
\ No newline at end of file
......@@ -22,8 +22,15 @@ Dependance
----------
This project can be used alone if you only want to convert an HDOC into a Neo4j requests file.
This project can be used alone if you only want to convert an HDOC into a Neo4j requests file or directly insert data in neo4j local database.
WARNINGS:
1) If you want to insert data automatically in a database, you need to have nodeJS installed!
Windows: https://nodejs.org/en/ and download + install the last stable version
Linux: install with your distribution's package manager
2) You need to configure the node/config.json file properly to fit with the parameters of the dabase you want to insert in. (host, db and password).
User documentation
------------------
......@@ -34,17 +41,16 @@ You have to respect the following steps :
2 - Modifier le fichier config.json (dans le dossier node) avec la base de données locale et le mot de passe personnel (base publique à venir)
3 - En ligne de commande, executer "npm install" pour installer les packages nodes (en attendant une automatisation future de la tache)
3 - Lancer le fichier runWithNode (choisissez l'extension selon votre OS)
4 - Lancer le fichier runWithNode (choisissez l'extension selon votre OS)
5 - Admirez le graph créé avec neo4j dans votre navigateur (sur localhost:7474)
4 - Admirez le graph créé avec neo4j dans votre navigateur (sur localhost:7474)
Unsupported
-----------
There is no shared public database for now.
The "References" links are not fully supported yet. The opale_to_hdoc part is done, but needs an implementation in hdoc_to_neo4j.
Known bugs
----------
......
......@@ -31,12 +31,12 @@
</xsl:template>
<!-- Traitement spécial pour les objectifs, ils ont parfois la même longueur -->
<xsl:template match="body/section/section/section[@data-hdoc-type='aims']">
<xsl:template match="body/section/section/section[@data-hdoc-type='aims' or @data-hdoc-type='synthesis']">
MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="concat(./header/h1,' - ', parent::section/header/h1, ' (',string-length(.), ')')"/>"});
MATCH (l1 {title:"<xsl:value-of select="concat(./header/h1,' - ', parent::section/header/h1, ' (',string-length(.), ')')"/>"}), (l2 {title:"<xsl:value-of select="concat(parent::section/header/h1,' (',string-length(parent::section), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
</xsl:template>
<xsl:template match="body/section/section/section[not(@data-hdoc-type='aims')]">
<xsl:template match="body/section/section/section[not(@data-hdoc-type='aims' or @data-hdoc-type='synthesis')]">
MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
MATCH (l1 {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2 {title:"<xsl:value-of select="concat(parent::section/header/h1,' (',string-length(parent::section), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
</xsl:template>
......
......@@ -445,7 +445,7 @@
<xsl:choose>
<!-- If it is directly included in a div, we have to add Opale's text markups -->
<xsl:when test="parent::*[name() = 'div']">
<xsl:when test="parent::*[name() = 'div'] and not(parent::*[@data-hdoc-type = 'gapText']) and not(parent::*[@data-hdoc-type = 'label']) and not(parent::*[@data-hdoc-type = 'target'])">
<sp:txt>
<op:txt>
<xsl:call-template name="blockloop"/>
......@@ -630,6 +630,118 @@
</sp:listing>
</xsl:template>
<!-- Match exercise -->
<xsl:template match="h:section[@data-hdoc-type = 'match']" priority="2">
<sp:trainUcMatch>
<op:match>
<op:exeM>
<sp:title><xsl:value-of select="h:header/h:h1"/></sp:title>
</op:exeM>
<xsl:apply-templates select="h:div[@data-hdoc-type = 'question']"/>
<xsl:apply-templates select="h:section[@data-hdoc-type = 'group']"/>
<sc:globalExplanation>
<op:res>
<xsl:apply-templates select="./h:div[@data-hdoc-type = 'explanation']/h:p"/>
</op:res>
</sc:globalExplanation>
</op:match>
</sp:trainUcMatch>
</xsl:template>
<xsl:template match="h:section[@data-hdoc-type = 'group']" priority="2">
<sc:group>
<xsl:apply-templates select="h:div[@data-hdoc-type = 'target']"/>
<xsl:apply-templates select="h:div[@data-hdoc-type = 'label']"/>
</sc:group>
</xsl:template>
<xsl:template match="h:section[@data-hdoc-type = 'group']/h:div[@data-hdoc-type = 'label']" priority="2">
<sc:label>
<op:label>
<sp:txt>
<op:labelTxt>
<xsl:apply-templates select="./*"/>
</op:labelTxt>
</sp:txt>
</op:label>
</sc:label>
</xsl:template>
<xsl:template match="h:div[@data-hdoc-type = 'target']">
<sc:target>
<op:label>
<sp:txt>
<op:labelTxt>
<xsl:apply-templates select="./*"/>
</op:labelTxt>
</sp:txt>
</op:label>
</sc:target>
</xsl:template>
<!-- Order exercise -->
<xsl:template match="h:section[@data-hdoc-type = 'order']" priority="2">
<sp:trainUcOrdWord>
<op:ordWord>
<op:exeM>
<sp:title><xsl:value-of select="h:header/h:h1"/></sp:title>
</op:exeM>
<xsl:apply-templates select="h:div[@data-hdoc-type='question']"/>
<xsl:apply-templates select="h:div[@data-hdoc-type= 'label']"/>
<sc:globalExplanation>
<op:res>
<xsl:apply-templates select="./h:div[@data-hdoc-type = 'explanation']/h:p"/>
</op:res>
</sc:globalExplanation>
</op:ordWord>
</sp:trainUcOrdWord>
</xsl:template>
<xsl:template match="h:div[@data-hdoc-type = 'label']">
<sc:label>
<op:labelTxt>
<xsl:apply-templates select="./*"/>
</op:labelTxt>
</sc:label>
</xsl:template>
<!-- Fill-in-the-blank -->
<xsl:template match="h:section[@data-hdoc-type = 'fill-in-the-blank']" priority="2">
<sp:trainUcCloze>
<op:cloze>
<op:exeM>
<sp:title><xsl:value-of select="h:header/h:h1"/></sp:title>
</op:exeM>
<xsl:apply-templates select="h:div[@data-hdoc-type = 'question']"/>
<xsl:apply-templates select="h:div[@data-hdoc-type = 'gapText']"/>
<sc:globalExplanation>
<op:res>
<xsl:apply-templates select="./h:div[@data-hdoc-type = 'explanation']/h:p"/>
</op:res>
</sc:globalExplanation>
</op:cloze>
</sp:trainUcCloze>
</xsl:template>
<xsl:template match="h:div[@data-hdoc-type = 'gapText']">
<sc:gapText>
<op:clozeTxt>
<xsl:apply-templates select="./*"/>
</op:clozeTxt>
</sc:gapText>
</xsl:template>
<xsl:template match="h:span[@data-hdoc-type = 'blank']">
<sc:textLeaf role="gap">
<xsl:apply-templates select="./* | ./text()"/>
</sc:textLeaf>
</xsl:template>
<!-- Open Question -->
<xsl:template match="h:section[@data-hdoc-type = 'exercise']">
<sp:practUc>
......
<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:utc.fr:ics:hdoc:container">
<rootfiles>
<rootfile full-path="content.xml" media-type="text/xml" />
</rootfiles>
</container>
This diff is collapsed.
application/x-hdoc+zip
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment