Commit c853c8cc authored by Aghiles's avatar Aghiles

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

parents 2ea5f2f6 16fe948d
*/input/* */input/*
*/tmp/* */tmp/*
*/output/* */output/*
!*/input/.gitkeep
!*/tmp/.gitkeep
!*/output/.gitkeep
*/node_modules*/ */node_modules*/
*.DS_Store* *.DS_Store*
...@@ -25,6 +25,9 @@ Un utilisateur a cr ...@@ -25,6 +25,9 @@ Un utilisateur a cr
- Method and Remind fully functional. - Method and Remind fully functional.
- Add QCU and QCM. Transclusion of them available too. Need to fix a schema validation error when putting a title to a question, without filling the question content. - Add QCU and QCM. Transclusion of them available too. Need to fix a schema validation error when putting a title to a question, without filling the question content.
- Add "Exercice redactionnel" and transclusion. - Add "Exercice redactionnel" and transclusion.
- Fill-in-the blank (and transclusion)
- Order exercise (and transclusion)
- Match exercise (and transclusion)
## Known bugs ## Known bugs
- You can have an exercice with no question but a solution. We should add a if statement to handle this. - You can have an exercice with no question but a solution. We should add a if statement to handle this.
...@@ -35,4 +38,5 @@ Un utilisateur a cr ...@@ -35,4 +38,5 @@ Un utilisateur a cr
- Handle multiple files conversion - Handle multiple files conversion
- Add all other type of exercices - Add all other type of exercices
- Handle other kind of paragraph - Handle other kind of paragraph
- Handle resources (images for example) - Handle resources (images for example)
\ No newline at end of file - Handle sub-level transclusion
\ No newline at end of file
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
<!-- Initialize folders --> <!-- Initialize folders -->
<target name="init"> <target name="init">
<!-- create folders (to be sure) --> <!-- create folders (to be sure) -->
<delete>
<fileset file="${out}/*.hdoc"/>
</delete>
<mkdir dir="${unzipfolder}"/> <mkdir dir="${unzipfolder}"/>
<mkdir dir="${tmp}"/> <mkdir dir="${tmp}"/>
<mkdir dir="${out}"/> <mkdir dir="${out}"/>
...@@ -60,6 +63,9 @@ ...@@ -60,6 +63,9 @@
<target name="process_canoscar" depends="check_scar" if="${canoprof.is_canoprof_scar}"> <target name="process_canoscar" depends="check_scar" if="${canoprof.is_canoprof_scar}">
<!-- TODO change test.xml to the temporary file created while fusioning all the xml files --> <!-- TODO change test.xml to the temporary file created while fusioning all the xml files -->
<copy tofile="${unzipfolder}/Test.programme">
<fileset file="${unzipfolder}/*.programme"/>
</copy>
<xslt style="xsl/programmation.xsl" in="${unzipfolder}/Test.programme" out="${hdoc}/content.xml" classpath="./lib/saxon9he.jar"> <xslt style="xsl/programmation.xsl" in="${unzipfolder}/Test.programme" out="${hdoc}/content.xml" classpath="./lib/saxon9he.jar">
<factory name="net.sf.saxon.TransformerFactoryImpl"/> <factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt> </xslt>
......
...@@ -160,6 +160,13 @@ ...@@ -160,6 +160,13 @@
<xsl:value-of select="." /> <xsl:value-of select="." />
</span> </span>
</xsl:template> </xsl:template>
<xsl:template match="sc:para/sc:textLeaf[@role='gap']" priority = "2">
<span data-hdoc-type="blank">
<xsl:value-of select="."/>
</span>
</xsl:template>
<!-- default behaviour for other balises --> <!-- default behaviour for other balises -->
<xsl:template match="sc:para/sc:inlineStyle|sc:para/sc:textLeaf" priority="1"> <xsl:template match="sc:para/sc:inlineStyle|sc:para/sc:textLeaf" priority="1">
<xsl:value-of select="." /> <xsl:value-of select="." />
...@@ -332,7 +339,144 @@ ...@@ -332,7 +339,144 @@
<!-- ******** FIN ACTIVITE TETM ********** --> <!-- ******** FIN ACTIVITE TETM ********** -->
<!-- ******** EXERCICE AVEC CORRIGE ******** --> <!-- ******** EXERCICE AVEC ET SANS CORRIGE ******** -->
<xsl:template match="sc:item/cp:match">
<xsl:param name="withoutExplanation"/>
<section data-hdoc-type='match'>
<header>
<h1><xsl:value-of select='cp:questionM/sp:title'/></h1>
</header>
<div data-hdoc-type = 'question'>
<xsl:apply-templates select='sc:question/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para'/>
</div>
<xsl:apply-templates select='//sc:group'/>
<xsl:if test="$withoutExplanation = 'sp:question'">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</xsl:template>
<!-- Categorisation -->
<xsl:template match='sp:question/cp:match | sp:exercice/cp:match'>
<section data-hdoc-type='match'>
<header>
<h1><xsl:value-of select='cp:questionM/sp:title'/></h1>
</header>
<div data-hdoc-type = 'question'>
<xsl:apply-templates select='sc:question/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para'/>
</div>
<xsl:apply-templates select='//sc:group'/>
<xsl:if test="../name() = 'sp:question'">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</xsl:template>
<xsl:template match='sc:group'>
<xsl:if test="sc:target/cp:label/sp:txt/cp:txtLabel/sc:para">
<section data-hdoc-type = 'group'>
<header>
<h1/>
</header>
<div data-hdoc-type='target'><xsl:apply-templates select='sc:target/cp:label/sp:txt/cp:txtLabel/sc:para'/></div>
<xsl:apply-templates select='sc:label'/>
</section>
</xsl:if>
</xsl:template>
<!-- Ordonnancement -->
<xsl:template match='sp:question/cp:order | sp:exercice/cp:order'>
<section data-hdoc-type='order'>
<header>
<h1><xsl:value-of select='cp:questionM/sp:title'/></h1>
</header>
<div data-hdoc-type='question'>
<xsl:apply-templates select='sc:question/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para'/>
</div>
<xsl:apply-templates select="//sc:label"/>
<xsl:if test="../name() = 'sp:question'">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</xsl:template>
<xsl:template match='sc:item/cp:order'>
<xsl:param name="withoutExplanation"/>
<section data-hdoc-type='order'>
<header>
<h1><xsl:value-of select='cp:questionM/sp:title'/></h1>
</header>
<div data-hdoc-type='question'>
<xsl:apply-templates select='sc:question/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para'/>
</div>
<xsl:apply-templates select="//sc:label"/>
<xsl:if test="$withoutExplanation = 'sp:question'">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</xsl:template>
<xsl:template match="sc:label">
<div data-hdoc-type = 'label'>
<xsl:apply-templates select='cp:label/sp:txt/cp:txtLabel/sc:para'/>
</div>
</xsl:template>
<!-- Texte à trou -->
<xsl:template match="sp:question/cp:cloze | sp:exercice/cp:cloze">
<section data-hdoc-type='fill-in-the-blank'>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
</header>
<div data-hdoc-type='question'>
<xsl:apply-templates select="sc:question/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
<div data-hdoc-type='gapText'>
<xsl:apply-templates select="sc:gapText/cp:txtCloze/sc:para"/>
</div>
<xsl:if test="../name() = 'sp:question'">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</xsl:template>
<xsl:template match="sc:item/cp:cloze">
<xsl:param name="withoutExplanation"/>
<section data-hdoc-type='fill-in-the-blank'>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
</header>
<div data-hdoc-type='question'>
<xsl:apply-templates select="sc:question/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
<div data-hdoc-type='gapText'>
<xsl:apply-templates select="sc:gapText/cp:txtCloze/sc:para"/>
</div>
<xsl:if test="$withoutExplanation = 'sp:question'">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</xsl:template>
<!-- Questionnement --> <!-- Questionnement -->
......
...@@ -27,6 +27,9 @@ A .scar example is already in the input folder. ...@@ -27,6 +27,9 @@ A .scar example is already in the input folder.
- Method and Remind fully functional - Method and Remind fully functional
- QCM and QCU working, even with transclusion. - QCM and QCU working, even with transclusion.
- Add "Exercice redactionnel" and transclusion. - Add "Exercice redactionnel" and transclusion.
- Fill-in-the-blank with transclusion.
- Order exercise (and transclusion)
- Match exercise (and transclusion)
## Known bugs ## Known bugs
- You can have an exercice with no question but a solution. We should add a if statement to handle this. - You can have an exercice with no question but a solution. We should add a if statement to handle this.
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
xmlns="http://www.utc.fr/ics/hdoc/xhtml" version="2.0"> xmlns="http://www.utc.fr/ics/hdoc/xhtml" version="2.0">
<xsl:output method="xml" indent="yes"/> <xsl:output method="xml" indent="yes"/>
<xsl:template match="//li[parent::p]" priority="1">
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="p[child::ul or child::ol]" priority="1"> <xsl:template match="p[child::ul or child::ol]" priority="1">
...@@ -37,4 +41,4 @@ ...@@ -37,4 +41,4 @@
</xsl:copy> </xsl:copy>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
\ No newline at end of file
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
<xsl:output method="xml" indent="yes"/> <xsl:output method="xml" indent="yes"/>
<xsl:key name="bits" match="p/node()[not(self::br)]" use="generate-id((..|preceding-sibling::br[1])[last()])"/> <xsl:key name="bits" match="p/node()[not(self::br)]" use="generate-id((..|preceding-sibling::br[1])[last()])"/>
<xsl:template match="ul[@class='indent']">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="ul"> <xsl:template match="ul">
<ul> <ul>
<xsl:apply-templates select="*"/> <xsl:apply-templates select="*"/>
...@@ -13,10 +18,18 @@ ...@@ -13,10 +18,18 @@
<xsl:apply-templates select="*"/> <xsl:apply-templates select="*"/>
</ol> </ol>
</xsl:template> </xsl:template>
<xsl:template match="code">
Code (non pris en compte pour l'instant) :<br/>
<xsl:apply-templates select="@*|node()"/>
<br/>
</xsl:template>
<xsl:template match="code[preceding-sibling::code]">
<xsl:apply-templates select="@*|node()"/>
<br/>
</xsl:template>
<xsl:template match="@*|node()"> <xsl:template match="@*|node()">
<xsl:copy> <xsl:copy>
<xsl:apply-templates select="@*|node()"/> <xsl:apply-templates select="@*|node()"/>
</xsl:copy> </xsl:copy>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
\ No newline at end of file
...@@ -52,10 +52,7 @@ ...@@ -52,10 +52,7 @@
Titre (non pris en compte pour l'instant) : Titre (non pris en compte pour l'instant) :
<xsl:apply-templates select="@*|node()"/> <xsl:apply-templates select="@*|node()"/>
</xsl:template> </xsl:template>
<xsl:template match="code">
Code (non pris en compte pour l'instant) :
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="page"> <xsl:template match="page">
<xsl:apply-templates select="@*|node()"/> <xsl:apply-templates select="@*|node()"/>
</xsl:template> </xsl:template>
......
File mode changed from 100644 to 100755
...@@ -22,31 +22,50 @@ Dependance ...@@ -22,31 +22,50 @@ Dependance
This project can be used alone if you want to import an HDOC file into basex. This project can be used alone if you want to import an HDOC file into basex.
## User stories User stories
------------------ ------------------
- Among a group of courses, user can search by title, author or keywords of the course. - Among a group of courses, user can search by title, author or keywords of the course.
- By searching a certain keyword, user can obtain the sections that contain it with their hierarchy levels in the course. - By searching a certain keyword, user can obtain the sections that contain it with their hierarchy levels in the course.
- In a certain section, by searching a key word, user can obtain paragraphes that contain it. - In a certain section, by searching a key word, user can obtain paragraphs that contain it.
- User can get definitions related to a keyword - User can get definitions related to a keyword
- User can get examples whose titles contain a keyword - User can get examples whose titles contain a keyword
Step by step : Step by step :
[Step 1 : File transformation]
- Put the files .hdoc you want to deal with in the folder [input](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex/input) [`Step 1 : File transformation`]
- Put the files .hdoc you want to deal with in the folder [`input`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex/input)
- Run the transformation progam (Win : double click run.bat, Linux : execute run.sh) - Run the transformation progam (Win : double click run.bat, Linux : execute run.sh)
- This transformation includes :
* Title, authors, keywords
* First Level section : title, type, paragraphs
[Step 2 : Create data base in basex] [`Step 2 : Create data base in basex`]
- Download and install [BaseX](http://basex.org/products/download/all-downloads/) - Download and install [BaseX](http://basex.org/products/download/all-downloads/)
- Run BasexGui - Run BasexGui
- In the Text Editor of BaseX, open the command script "createbd.bxs" in folder [`basex/command`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex/basex/command). - In the Text Editor of BaseX, open the command script "createbd.bxs" in folder [`command`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex/basex/command).
Follow the instructions in the script, and then execute it. Follow the instructions in the script, and then execute it.
[Step 3 : Make XQuery request] [`Step 3 : Make XQuery request`]
- In the Text Editor of BaseX, you can open and execute xquery script "main.xq" in folder [`basex/xquery`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex/basex/xquery). - In the Text Editor of BaseX, you can open and execute xquery script "main.xq" in folder [`xquery`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex/basex/xquery).
It's in this main module that we call predefined functions and execute script It's in this main module that we call predefined functions and execute script
- .xqm files are library modules where we have defined functions, we can go to these files for more detailed using instructions - .xqm files are library modules where we have defined functions, we can go to these files for more detailed using instructions
Available library modules : Available library modules :
* searchDocByAuthor.xqm * searchDocByAuthor.xqm
* searchDocByTitle.xqm * searchDocByTitle.xqm
* searchDocByTitle.xqm * searchSectionByTitle.xqm
\ No newline at end of file
P.S. the symbols "(: :)" are used for adding comments in xQuery files
TODO List
------------------
- xlst Transformation :
* Remove text formats
* Sub sections
* Exercices
* Resources : images, ...
- XQuery requests :
* Search keywords in text
* Search sub sections by keywords in their titles
* Search exercices by keywords in their titles
\ No newline at end of file
(: this script with .xq as suffix is the main module :) (: this script with .xq as suffix is the main module :)
(: all functions defined in .xqm files (library modules) can be called here :) (: all functions defined in .xqm files (library modules) can be called here :)
import module namespace myNs = "https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex" at "searchSectionByTitle.xqm", "searchSectionByTitle.xqm", "searchDocByAuthor.xqm"; import module namespace myNs = "https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex" at "searchSectionByTitle.xqm", "searchDocByTitle.xqm", "searchDocByAuthor.xqm";
(: myNs:searchDocByTitle('^NF29_HdocEtherpad$', //document ):) (: myNs:searchDocByTitle('^NF29_HdocEtherpad$', //document ) :)
(: myNs:searchSectionByTitle('contenu', //document) :) (: myNs:searchSectionByTitle('contenu', //document) :)
(: myNs:searchDocByAuthor('montangé', //document) :) (: myNs:searchDocByAuthor('montangé', //document) :)
......
...@@ -12,9 +12,9 @@ declare function myNs:searchDocByAuthor($name as xs:string, $docs as node()*) as ...@@ -12,9 +12,9 @@ declare function myNs:searchDocByAuthor($name as xs:string, $docs as node()*) as
for $doc in $docs for $doc in $docs
return return
for $author in $doc/authors/author for $author in $doc/authors/author
let $titre := $doc/titre let $title := $doc/title
let $author_noAcc := translate($author, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz') let $author_noAcc := translate($author, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
where matches($author_noAcc, $name_noAcc) where matches($author_noAcc, $name_noAcc)
group by $titre (: Avoid duplications of documents by their titre:) group by $title (: Avoid duplications of documents by their titre:)
return $doc return $doc
}; };
\ No newline at end of file
...@@ -8,6 +8,6 @@ module namespace myNs = "https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to ...@@ -8,6 +8,6 @@ module namespace myNs = "https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to
declare function myNs:searchDocByTitle($name as xs:string, $docs as node()*) as node()* declare function myNs:searchDocByTitle($name as xs:string, $docs as node()*) as node()*
{ {
for $doc in $docs for $doc in $docs
where matches($doc/titre, $name, "i") where matches($doc/title, $name, "i")
return $doc return $doc
}; };
\ No newline at end of file
...@@ -12,7 +12,7 @@ declare function myNs:searchSectionByTitle($keyword as xs:string, $docs as node( ...@@ -12,7 +12,7 @@ declare function myNs:searchSectionByTitle($keyword as xs:string, $docs as node(
for $doc in $docs for $doc in $docs
return return
for $section in $doc/sections/section for $section in $doc/sections/section
let $title_noAcc := translate($section/titresection, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz') let $title_noAcc := translate($section/titlesection, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
where matches($title_noAcc, $keyword_noAcc) where matches($title_noAcc, $keyword_noAcc)
return $section return $section
}; };
\ No newline at end of file
...@@ -3,4 +3,4 @@ log=${basedir}/log ...@@ -3,4 +3,4 @@ log=${basedir}/log
xsl=${basedir}/xsl xsl=${basedir}/xsl
in=${basedir}/input in=${basedir}/input
out=${basedir}/output out=${basedir}/output
tmp=${basedir}/tmp tmp=${basedir}/tmp
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<target name="convert"> <target name="convert">
<!-- Preparation for the file transformation : delete old folders and create new folders --> <!-- Preparation for the file transformation : delete old folders and create new folders -->
<delete dir="${tmp}" failonerror="false"/>
<mkdir dir="${tmp}"/> <mkdir dir="${tmp}"/>
<delete dir="${out}" failonerror="false"/> <delete dir="${out}" failonerror="false"/>
<mkdir dir="${out}"/> <mkdir dir="${out}"/>
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
</xsl:template> </xsl:template>
<xsl:template match="h:head" mode="title"> <xsl:template match="h:head" mode="title">
<titre> <title>
<xsl:value-of select="./h:title"/> <xsl:value-of select="./h:title"/>
</titre> </title>
<xsl:apply-templates select="./h:meta"/>