Commit c853c8cc authored by Aghiles's avatar Aghiles

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.
......@@ -35,4 +38,5 @@ Un utilisateur a cr
- Handle multiple files conversion
- Add all other type of exercices
- Handle other kind of paragraph
- Handle resources (images for example)
\ No newline at end of file
- 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.
......
......@@ -3,6 +3,10 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
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">
......@@ -37,4 +41,4 @@
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
......@@ -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,10 +18,18 @@
<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()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
......@@ -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).
Follow the instructions in the script, and then execute it.
- 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
......@@ -3,4 +3,4 @@ log=${basedir}/log
xsl=${basedir}/xsl
in=${basedir}/input
out=${basedir}/output
tmp=${basedir}/tmp
\ No newline at end of file
tmp=${basedir}/tmp
......@@ -7,6 +7,7 @@
<target name="convert">
<!-- Preparation for the file transformation : delete old folders and create new folders -->
<delete dir="${tmp}" failonerror="false"/>
<mkdir dir="${tmp}"/>
<delete dir="${out}" failonerror="false"/>
<mkdir dir="${out}"/>
......
......@@ -10,9 +10,9 @@
</xsl:template>
<xsl:template match="h:head" mode="title">
<titre>
<title>
<xsl:value-of select="./h:title"/>
</titre>
</title>
<xsl:apply-templates select="./h:meta"/>
</xsl:template>
......@@ -44,29 +44,32 @@
<xsl:template match="h:section">
<section>
<titresection>
<typesection>
<xsl:value-of select="@data-hdoc-type"/>
</typesection>
<titlesection>
<xsl:value-of select="./h:header/h:h1"/>
</titresection>
<contenu>
<paragraphes>
</titlesection>
<content>
<paragraphs>
<xsl:apply-templates select="h:div"/>
</paragraphes>
</paragraphs>
<xsl:apply-templates select="h:section" mode="soussect"/>
</contenu>
</content>
</section>
</xsl:template>
<xsl:template match="h:section" mode="soussect">
<soussection></soussection>
</xsl:template>
<xsl:template match="h:div" >
<xsl:if test="h:p">
<paragraphe>
<paragraph>
<xsl:value-of select="."/>
</paragraphe>
</paragraph>
</xsl:if>
<xsl:if test="h:ul">
<xsl:apply-templates select="h:ul"></xsl:apply-templates>
......@@ -75,9 +78,9 @@
</xsl:template>
<xsl:template match="h:ul">
<xsl:for-each select="h:li">
<paragraphe>
<paragraph>
<xsl:value-of select="h:p"/>
</paragraphe>
</paragraph>
</xsl:for-each>
</xsl:template>
......
......@@ -22,7 +22,7 @@ There's no particular dependencies needed to run the converter.
Conditions particulières
---
Pour le moment, il ne faut pas utilisé les "sous-Division" de Opale. Les divisions à la racine sont autorisées.
Pour le moment, il ne faut pas utiliser les "sous-Division" de Opale. Les divisions à la racine sont autorisées.
User Story
---
......@@ -31,3 +31,39 @@ User Story
* Put the `.hdoc` files in the input folder
* Run `run.bat` or `run.sh` according to your operating system
* The output files are in the output folder
DONE
---
Opale Hdoc Canoprof
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Module fichier hdoc Programme
Objectif / Introduction / Conclusion du module Section contenant une div avec un header et du texte Séance contenant une activité de type description courte
Division ou activité Section Séance
Grain opale Section contenant une section Activité Texte et multimédia
Parties et sous-partie d’un grain section/section/section... Activité Texte et multimédia
Définition div avec un attribut data-hdoc-type = definiton Définition
Exemple div avec un attribut data-hdoc-type = example Exemple
Remarque div avec un attribut data-hdoc-type = remark Hypothèse (information?)
Conseil div avec un attribut data-hdoc-type = advice Conseil
Attention div avec un attribut data-hdoc-type = warning Attention
Complément div avec un attribut data-hdoc-type = complement Complément
Fondamental div avec un attribut data-hdoc-type = emphasis Méthode
Remarque : le texte, les listes, les tableaux fonctionnent.
TODO
---
Points particuliers de Canoprof :
Questions avec corrigé
Consigne élève
Remarque prof
Blocs :
Information Pas traité (à faire dans Opale_to_Hdoc et Hdoc_to_canoprof)
Méthode Pas traité (à faire dans Opale_to_Hdoc et Hdoc_to_canoprof)
Rappel Pas traité (à faire dans Opale_to_Hdoc et Hdoc_to_canoprof)
Syntaxe Pas traité Pas traité (à faire dans Opale_to_Hdoc et Hdoc_to_canoprof)
Texte légal Pas traité Pas traité (à faire dans Opale_to_Hdoc et Hdoc_to_canoprof)
Simulation Pas traité Pas traité (à faire dans Opale_to_Hdoc et Hdoc_to_canoprof)
\ No newline at end of file
......@@ -77,6 +77,17 @@
<xsl:if test="not(./h:header/h:h1/text())"> Untitled </xsl:if>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
<!-- If a SOLO section have a div; this div become a Canoprof's resume of the current seance.
<xsl:if test="./h:div/*">
<sp:abstract>
<cp:txtDesc>
<xsl:apply-templates select="./h:div/*" mode="resume"/>
</cp:txtDesc>
</sp:abstract>
</xsl:if>
-->
</cp:sessionM>
<xsl:apply-templates select="./*"/>
</cp:session>
......@@ -144,10 +155,38 @@
</xsl:template>
<!-- CanoProf's Activite TetM (section) = hdoc's body/Section/Section/(Section...) = Opale's Grain (partie) -->
<!-- TODO -->
<xsl:template match="h:section" mode="CanoprofSection">
<sp:section>
<cp:textActivity>
<cp:activityM>
<sp:title>
<xsl:if test="not(./h:header/h:h1/text())"> Untitled </xsl:if>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
<xsl:if test="(./h:header/h:div[@data-hdoc-type = 'introduction']/text())">
<xsl:apply-templates
select="./h:header/h:div[@data-hdoc-type = 'introduction']"/>
</xsl:if>
</cp:activityM>
<xsl:if test="./h:div/*">
<sp:body>
<cp:blocks>
<xsl:apply-templates select="./h:div"/>
</cp:blocks>
</sp:body>
</xsl:if>
<xsl:if test="./h:section/*">
<xsl:apply-templates select="./h:section" mode="CanoprofSection"/>
</xsl:if>
</cp:textActivity>
</sp:section>
</xsl:template>
<!-- TODO : intro/conlcusion/obj d'une activité....
<xsl:template match="h:section[@data-hdoc-type = 'introduction'] | h:section[@data-hdoc-type = 'conclusion']">
</xsl:template>
-->
<!-- Div related templates -->
<!-- Formatting content based on @data-hdoc-type -->
<xsl:template match="h:div">
......@@ -359,6 +398,18 @@
</xsl:if>
</xsl:template>
<!--
<xsl:template match="h:p | h:ul | h:ol" mode="resume">
<xsl:if test="not(preceding-sibling::h:p)">
<xsl:if test="not(preceding-sibling::h:ul)">
<xsl:if test="not(preceding-sibling::h:ol)">
<xsl:call-template name="blockloop"/>
</xsl:if>
</xsl:if>