Commit c853c8cc authored by Aghiles's avatar Aghiles
Browse files

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

parents 2ea5f2f6 16fe948d
*/input/*
*/tmp/*
*/output/*
!*/input/.gitkeep
!*/tmp/.gitkeep
!*/output/.gitkeep
*/node_modules*/
*.DS_Store*
......@@ -25,6 +25,9 @@ Un utilisateur a cr
- 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 "Exercice redactionnel" and transclusion.
- Fill-in-the blank (and transclusion)
- Order exercise (and transclusion)
- Match exercise (and transclusion)
## Known bugs
- You can have an exercice with no question but a solution. We should add a if statement to handle this.
......@@ -36,3 +39,4 @@ Un utilisateur a cr
- Add all other type of exercices
- Handle other kind of paragraph
- Handle resources (images for example)
- Handle sub-level transclusion
\ No newline at end of file
......@@ -34,6 +34,9 @@
<!-- Initialize folders -->
<target name="init">
<!-- create folders (to be sure) -->
<delete>
<fileset file="${out}/*.hdoc"/>
</delete>
<mkdir dir="${unzipfolder}"/>
<mkdir dir="${tmp}"/>
<mkdir dir="${out}"/>
......@@ -60,6 +63,9 @@
<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 -->
<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">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
......
......@@ -160,6 +160,13 @@
<xsl:value-of select="." />
</span>
</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 -->
<xsl:template match="sc:para/sc:inlineStyle|sc:para/sc:textLeaf" priority="1">
<xsl:value-of select="." />
......@@ -332,7 +339,144 @@
<!-- ******** 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 -->
......
......@@ -27,6 +27,9 @@ A .scar example is already in the input folder.
- Method and Remind fully functional
- QCM and QCU working, even with transclusion.
- Add "Exercice redactionnel" and transclusion.
- Fill-in-the-blank with transclusion.
- Order exercise (and transclusion)
- Match exercise (and transclusion)
## Known bugs
- You can have an exercice with no question but a solution. We should add a if statement to handle this.
......
......@@ -4,6 +4,10 @@
xmlns="http://www.utc.fr/ics/hdoc/xhtml" version="2.0">
<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:apply-templates select="./ul"/>
......
......@@ -3,6 +3,11 @@
<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:template match="ul[@class='indent']">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="ul">
<ul>
<xsl:apply-templates select="*"/>
......@@ -13,7 +18,15 @@
<xsl:apply-templates select="*"/>
</ol>
</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:copy>
<xsl:apply-templates select="@*|node()"/>
......
......@@ -52,10 +52,7 @@
Titre (non pris en compte pour l'instant) :
<xsl:apply-templates select="@*|node()"/>
</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:apply-templates select="@*|node()"/>
</xsl:template>
......
File mode changed from 100644 to 100755
......@@ -22,31 +22,50 @@ Dependance
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.
- 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 examples whose titles contain a keyword
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)
- 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/)
- 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.
[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).
[`Step 3 : Make XQuery request`]
- 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
- .xqm files are library modules where we have defined functions, we can go to these files for more detailed using instructions
Available library modules :
* searchDocByAuthor.xqm
* searchDocByTitle.xqm
* searchDocByTitle.xqm
\ No newline at end of file
* searchSectionByTitle.xqm
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 :)
(: 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:searchDocByAuthor('montangé', //document) :)
......
......@@ -12,9 +12,9 @@ declare function myNs:searchDocByAuthor($name as xs:string, $docs as node()*) as
for $doc in $docs
return
for $author in $doc/authors/author
let $titre := $doc/titre
let $title := $doc/title
let $author_noAcc := translate($author, 'áàâäéèêëíìîïóòôöúùûüABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaeeeeiiiioooouuuuabcdefghijklmnopqrstuvwxyz')
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
};
\ No newline at end of file
......@@ -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()*
{
for $doc in $docs
where matches($doc/titre, $name, "i")
where matches($doc/title, $name, "i")
return $doc
};
\ No newline at end of file
......@@ -12,7 +12,7 @@ declare function myNs:searchSectionByTitle($keyword as xs:string, $docs as node(
for $doc in $docs
return
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)
return $section
};
\ 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