Commit 14ec2763 authored by simei.yin's avatar simei.yin
Browse files

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

parents 42f376ba 64c99ecf
......@@ -15,4 +15,5 @@ Un utilisateur a cr
- Activity created in the .programme, transclusion available.
- Information/Warning/Advice/ect...
- 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.
\ No newline at end of file
- 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.
\ No newline at end of file
......@@ -27,8 +27,7 @@
<body>
<xsl:apply-templates select="cp:programM/sp:abstract"/>
<xsl:apply-templates select="child::*[name() != 'cp:programM']"/>
<!-- TODO : apply-templates des exercices -->
<xsl:apply-templates select="descendant::*[sp:question]/sp:question | descendant::*[sp:exercice]/sp:exercice"/>
<xsl:apply-templates select="descendant::*[sp:question and ../name() != 'sp:question']/sp:question | descendant::*[sp:exercice]/sp:exercice"/>
</body>
</html>
</xsl:template>
......@@ -321,29 +320,60 @@
<!-- ******** EXERCICE AVEC CORRIGE ******** -->
<!-- Questionnement -->
<!-- TODO gerer multiple texte, remarque prof, ect... -->
<xsl:template match="sp:question/cp:openQuestion">
<xsl:template match="sp:question/cp:openQuestion | sp:exercice/cp:openQuestion">
<section data-hdoc-type='exercise'>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
</header>
<!-- TODO work with description -->
<xsl:if test="sp:question/cp:flow/*">
<div data-hdoc-type='question'>
<xsl:apply-templates select="sp:question/cp:flow/sp:txt/cp:txt/sc:para"/>
</div>
</xsl:if>
<xsl:if test="sp:solution">
<div data-hdoc-type='solution'>
<xsl:apply-templates select="sp:solution/cp:flow/sp:txt/cp:txt/sc:para"/>
</div>
</xsl:if>
<section>
<header><h1/></header>
<xsl:if test="sp:question/cp:flow/*">
<div data-hdoc-type='openQuestion'>
<xsl:apply-templates select="sp:question/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
<div data-hdoc-type='hint'>
<xsl:apply-templates select="sp:question/cp:flow/sp:profInstruction/cp:txt//sc:para"/>
</div>
</xsl:if>
<xsl:if test="../name() = 'sp:question' and sp:solution">
<div data-hdoc-type='solution'>
<xsl:apply-templates select="sp:solution/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</section>
</xsl:template>
<xsl:template match="sc:item/cp:openQuestion">
<xsl:param name="withoutExplanation"/>
<section data-hdoc-type='exercise'>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
</header>
<section>
<header><h1/></header>
<xsl:if test="sp:question/cp:flow/*">
<div data-hdoc-type='openQuestion'>
<xsl:apply-templates select="sp:question/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
<div data-hdoc-type='hint'>
<xsl:apply-templates select="sp:question/cp:flow/sp:profInstruction/cp:txt//sc:para"/>
</div>
</xsl:if>
<xsl:if test="$withoutExplanation = 'sp:question' and sp:solution">
<div data-hdoc-type='solution'>
<xsl:apply-templates select="sp:solution/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</section>
</xsl:template>
<!-- QCM and QCU-->
<xsl:template match="sp:question/cp:qcm | sp:exercice/cp:qcm | sc:item/cp:qcm">
<!-- TODO Gérer les explications par choix -->
<xsl:template match="sc:item/cp:qcm">
<xsl:param name="withoutExplanation"/>
<section>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
......@@ -352,7 +382,7 @@
<xsl:apply-templates select='sc:question/cp:block'/>
</div>
<xsl:apply-templates select="sc:choices/sc:choice"/>
<xsl:if test="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
<xsl:if test="$withoutExplanation = 'sp:question' and sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
......@@ -360,7 +390,25 @@
</section>
</xsl:template>
<xsl:template match="sp:question/cp:qcu | sp:exercice/cp:qcu | sc:item/cp:qcu">
<xsl:template match="sp:question/cp:qcm | sp:exercice/cp:qcm">
<section>
<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'/>
</div>
<xsl:apply-templates select="sc:choices/sc:choice"/>
<xsl:if test="../name() = 'sp:question' and sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
<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:qcu">
<xsl:param name="withoutExplanation"/>
<section>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
......@@ -370,7 +418,26 @@
</div>
<xsl:apply-templates select="sc:choices//sc:choice"/>
<div data-hdoc-type='solution'><p><xsl:value-of select="sc:solution/@choice"/></p></div>
<xsl:if test="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
<xsl:if test="$withoutExplanation = 'sp:question' and sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
<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="sp:question/cp:qcu | sp:exercice/cp:qcu">
<section>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
</header>
<div data-hdoc-type='singlechoicequestion'>
<xsl:apply-templates select="sc:question/cp:block"/>
</div>
<xsl:apply-templates select="sc:choices//sc:choice"/>
<div data-hdoc-type='solution'><p><xsl:value-of select="sc:solution/@choice"/></p></div>
<xsl:if test="../name() = 'sp:question' and sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
......@@ -412,9 +479,12 @@
</xsl:template>
<xsl:template match="sp:question[@sc:refUri] | sp:exercice[@sc:refUri]">
<xsl:apply-templates select="document(@sc:refUri)"/>
<xsl:apply-templates select="document(@sc:refUri)/sc:item/*">
<xsl:with-param name="withoutExplanation" select="name()"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="sp:question | sp:exercice">
<xsl:apply-templates select="./*"/>
</xsl:template>
......
......@@ -18,6 +18,6 @@ An .scar example is already in the input folder.
- Information/Warning/Advice/ect...
- Method and Remind fully functional
- QCM and QCU working, even with transclusion.
- Add "Exercice redactionnel" and transclusion.
......@@ -30,26 +30,6 @@ Vous êtes un utilisateur de framapad et en créez un pour un projet. Après avo
3. run the `run.[bat|sh]` script of your choice depending on your OS
4. and retrieve the hdoc outputs in the `/output` folder
## Unsupported
- Markdown
- Author paternity
- Etherpad timeline
- Chat
## Known bugs
- Nested lists in lists are not supported
Example :
`<ul>
<li>
<ul>
<li>
Never gonna give you up.
</li>
</ul>
</li>
<ul>`
- As a consequence, etherpad indentation is not supported because it is coded as nested lists.
## Product Backlog
Currently available on: https://framemo.org/framapad_to_opale
......@@ -57,15 +37,13 @@ Currently available on: https://framemo.org/framapad_to_opale
See also : https://bimestriel.framapad.org/p/nf29_framapad_to_opale for the full documentation of our working process.
## TODO
- Nested Lists
- Indentation
- Titles (and therefore Structure of the doc)
- Coloured text
- Code
- Markdown
## Technical notes
### Description of etherpad_to_hdoc.ant
### Description of framapad_to_hdoc.ant
#### Prelude
- Importation of necessary classes (antlib, htmlcleaner, jing)
......
......@@ -10,7 +10,7 @@
- Fecherolle Cecile (2014)
## Presentation
How to transform an framapad document in opale document.
How to transform a framapad document in opale document.
Filepaths in this document are relative to this readme file.
......@@ -19,8 +19,7 @@ Filepaths in this document are relative to this readme file.
- Hdoc2Opale
## User Documentation
1. Download a framapad document in html format.
1. Create or join a framapad document then export it in html format (Import/Export Button) in the `/input` directory (if the directory does not exists, you have to create it).
1. Create a framapad document then export it in html format (Import/Export Button) and put it in the `/input` directory (if the directory does not exists, you have to create it).
2. Execute the file `/run.bat` or `/run.sh` depending on the OS. A `.scar` file is created in the directory `/output`
*If the `/input` directory contains multiple files, they will be all treated.
3. Open the document with Opale
......@@ -29,29 +28,6 @@ Filepaths in this document are relative to this readme file.
3. Import your `.scar` file in the directory.
4. Open the file Main.xml created.
## Unsupported
- MarkDown
- Timeline and author paternity
- Chat
## Known bugs
Nested lists in lists are not supported.
Here's an example :
`<ul>
<li>
<ul>
<li>
Never gonna give you up.
</li>
</ul>
</li>
<ul>`
## TODO
- Work with markdown
- Correct nested lists
## Technical notes
### Description of framapad_to_hdoc.ant
......
......@@ -39,11 +39,19 @@ Image : JPEG; JPG, PNG, SVG (non testé pour SVG)
Gestion du multifichiers en input
Hypertexte
Unsupported
-----------
ODG : non supporté en EPUB => "Élément non supporté en EPUB : <xsl:value-of select="@data"/>"
Problème sur la liseuse vis à vis du CSS (à détailler)
Exercices
Méthode et Rappels (data-hdoc-type)
Known bugs
----------
......@@ -57,8 +65,13 @@ Problème avec les keywords : le hdoc contient des keywords mais nous ne savons
Todo list
---------
Étude compatibilité entre EPUB2 et EPUB3
Trouver une solution pour le dimentionnement des images
Repérer le problème avec le css
Faire l'affichage des exercices
Faire l'affichage des nouveaux types : Méthode et Rappels
Technical Notes
---------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- Namespaces -->
<xsl:stylesheet xmlns="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs" version="2.0" xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:op="utc.fr:ics/opale3">
<xsl:template match="sc:item">
<xsl:apply-templates/>
</xsl:template>
<!-- MODULE -->
<xsl:template match="op:ue">
<!-- RNG -->
<xsl:processing-instruction name="oxygen">
RNGSchema="http://hdoc.crzt.fr/schemas/xhtml/hdoc1-xhtml.rng" type="xml"
</xsl:processing-instruction>
<!-- HTML -->
<html>
<!-- MODULE"s HEADER -->
<head>
<xsl:apply-templates select="op:ueM/sp:title"/>
<meta charset="utf-8"/>
<meta content="HdocConverter/Opale3.4" name="generator"/>
<xsl:apply-templates select="op:ueM/sp:info"/>
</head>
<!-- MODULE's COMPONENTS -->
<body>
<xsl:apply-templates select="child::*[name() != 'op:ueM']"/>
</body>
</html>
</xsl:template>
<!-- Information -->
<xsl:template match="op:ueM/sp:info">
<xsl:apply-templates select="op:info/sp:keywds/op:keywds/sp:keywd"/>
<xsl:apply-templates select="op:info/sp:cc"/>
<xsl:apply-templates select="op:info/sp:cpyrgt/op:sPara/sc:para"/>
</xsl:template>
<!-- Titles -->
<xsl:template match="op:uM/sp:title | op:expUcDivM/sp:title | op:ueDivM/sp:title | op:exeM/sp:title">
<h1>
<xsl:value-of select="."/>
</h1>
</xsl:template>
<xsl:template match="op:ueM/sp:title">
<title>
<xsl:value-of select="."/>
</title>
</xsl:template>
<xsl:template match="op:pbTi/sp:title">
<h6>
<xsl:value-of select="."/>
</h6>
</xsl:template>
<!-- Subtitle -->
<xsl:template match="op:uM/sp:sTitle">
<h2>
<xsl:value-of select="."/>
</h2>
</xsl:template>
<!-- Liscences -->
<xsl:template match="op:ueM/sp:info/op:info/sp:cc">
<meta name="rights" content="{.}"/>
</xsl:template>
<xsl:template match="op:uM/sp:info/op:info/sp:cc">
<div data-hdoc-type="rights">
<xsl:value-of select="."/>
</div>
</xsl:template>
<!-- Keywords -->
<xsl:template match="op:ueM/sp:info/op:info/sp:keywds/op:keywds/sp:keywd">
<meta name="keywords" content="{.}"/>
</xsl:template>
<xsl:template match="op:uM/sp:info/op:info/sp:keywds">
<div data-hdoc-type="tags">
<xsl:apply-templates select="./op:keywds/sp:keywd"/>
</div>
</xsl:template>
<xsl:template match="op:uM/sp:info/op:info/sp:keywds/op:keywds/sp:keywd">
<span>
<xsl:value-of select="."/>
</span>
</xsl:template>
<!-- Author -->
<xsl:template match="op:ueM/sp:info/op:info/sp:cpyrgt/op:sPara/sc:para">
<meta name="author" content="{.}"/>
</xsl:template>
<xsl:template match="op:uM/sp:info/op:info/sp:cpyrgt/op:sPara/sc:para">
<div data-hdoc-type="author">
<xsl:value-of select="."/>
</div>
</xsl:template>
<!-- Division -->
<xsl:template match="op:ue/sp:div | op:ueDiv/sp:div">
<section data-hdoc-type="division">
<header>
<xsl:apply-templates select="./op:ueDiv/op:ueDivM/sp:title"/>
<xsl:apply-templates
select="./op:ueDiv/op:ueDivM/sp:info/op:info/sp:cpyrgt/op:sPara/sc:para"/>
<xsl:apply-templates select="./op:ueDiv/op:ueDivM/sp:info/op:info/sp:cc"/>
</header>
<!-- check for sub-division -->
<xsl:apply-templates select="./op:ueDiv/sp:div"/>
<!-- currently : grain & introduction & conclusion || adding "exercice redactionnel" || adding "actvite d'apprentissage" -->
<xsl:apply-templates select="./op:ueDiv/sp:intro"/>
<xsl:apply-templates select="./op:ueDiv/sp:courseUc"/>
<xsl:apply-templates select="./op:ueDiv/sp:conclu"/>
<xsl:apply-templates select="./op:ueDiv/sp:practUc"/>
<xsl:apply-templates select="./op:ueDiv/sp:courseUa"/>
<footer>
<xsl:apply-templates select="./op:ueDiv/op:ueDivM/sp:info/op:info/sp:keywds"/>
</footer>
</section>
</xsl:template>
<!-- Activity -->
<xsl:template match="sp:courseUa">
<section data-hdoc-type="activity">
<header>
<xsl:apply-templates select="./op:courseUa/op:uM/sp:title"/>
<xsl:apply-templates
select="./op:courseUa/op:uM/sp:info/op:info/sp:cpyrgt/op:sPara/sc:para"/>
<xsl:apply-templates select="./op:courseUa/op:uM/sp:info/op:info/sp:cc"/>
</header>
<!-- currently : grain & introduction & conclusion -->
<xsl:apply-templates select="./op:courseUa/sp:obj"/>
<xsl:apply-templates select="./op:courseUa/sp:intro"/>
<xsl:apply-templates select="./op:courseUa/sp:courseUc"/>
<xsl:apply-templates select="./op:courseUa/sp:conclu"/>
<!-- overview questions : regroup questions into a section-->
<xsl:if test="./op:courseUa/sp:quest">
<section data-hdoc-type="synthesis">
<header>
<h1>Questions de synthèse</h1>
</header>
<!-- a conclusion has only a bloc -->
<div>
<xsl:apply-templates select="./op:courseUa/sp:quest"/>
</div>
</section>
</xsl:if>
<footer>
<xsl:apply-templates select="./op:courseUa/op:uM/sp:info/op:info/sp:keywds"/>
</footer>
</section>
</xsl:template>
<!-- Grain -->
<xsl:template match="sp:courseUc">
<section data-hdoc-type="grain">
<header>
<xsl:apply-templates select="./op:expUc/op:uM/sp:title"/>
<xsl:apply-templates
select="./op:expUc/op:uM/sp:info/op:info/sp:cpyrgt/op:sPara/sc:para"/>
<xsl:apply-templates select="./op:expUc/op:uM/sp:info/op:info/sp:cc"/>
</header>
<!-- call for blocs -->
<xsl:apply-templates select="./op:expUc/sp:pb/op:pb/*"/>
<!-- call for parts -->
<xsl:apply-templates select="./op:expUc/sp:div"/>
<footer>
<xsl:apply-templates select="./op:expUc/op:uM/sp:info/op:info/sp:keywds"/>
</footer>
</section>
</xsl:template>
<!-- Aims (aims don't have metadata) -->
<xsl:template match="sp:obj">
<section data-hdoc-type="aims">
<header>
<h1>Objectifs</h1>
</header>
<div>
<xsl:apply-templates select="./op:sTxt/*"/>
</div>
</section>
</xsl:template>
<!-- Introduction (a introduction doesn't have metadata) -->
<xsl:template match="sp:intro">
<section data-hdoc-type="introduction">
<header>
<h1>Introduction</h1>
</header>
<!-- a introduction has only a bloc -->
<div>
<xsl:apply-templates select="./op:res/*"/>
</div>
</section>
</xsl:template>
<!-- Conclusion (a conclusion doesn't have metadata) -->
<xsl:template match="sp:conclu">
<section data-hdoc-type="conclusion">
<header>
<h1>Conclusion</h1>
</header>
<!-- a conclusion has only a bloc -->
<div>
<xsl:apply-templates select="./op:res/*"/>
</div>
</section>
</xsl:template>
<xsl:template match="sp:filtered">
<xsl:if test="op:filter/sp:exclude/text() = 'short'">
<xsl:apply-templates select="./op:res/*"/>
</xsl:if>
</xsl:template>
<!-- Overview questions (fr : question de synthèse) -->
<xsl:template match="sp:quest">
<xsl:apply-templates select="./op:txt/*"/>
</xsl:template>
<!-- Parts (of a Grain) -->
<xsl:template match="op:expUc/sp:div | op:expUcDiv/sp:div">
<section data-hdoc-type="part">
<header>
<!-- only title - parts don't have other metadata -->
<xsl:apply-templates select="./op:expUcDiv/op:expUcDivM/sp:title"/>
</header>
<!-- call for blocs -->
<xsl:apply-templates select="./op:expUcDiv/sp:pb/op:pb/*"/>
<!-- call for parts -->
<xsl:apply-templates select="./op:expUcDiv/sp:div"/>
</section>
</xsl:template>
<!-- "Exercice redactionnel" -->
<xsl:template match="sp:practUc">
<section data-hdoc-type="exercise">
<header>
<xsl:apply-templates select="op:practUc/op:exeM/sp:title"/>
</header>
<xsl:apply-templates select="op:practUc/sp:desc"/>
<xsl:apply-templates select="op:practUc/sp:quest"/>
</section>
</xsl:template>
<xsl:template match="op:practUc/sp:desc">
<div data-hdoc-type="description">
<xsl:value-of select="*"/>
</div>
</xsl:template>
<xsl:template match="op:practUc/sp:quest">
<div data-hdoc-type="question">
<div data-hdoc-type="description">
<xsl:value-of select="op:practUcQ/sp:desc/*"/>
</div>
<xsl:if test="op:practUcQ/sp:sol">
<div data-hdoc-type="solution">
<xsl:value-of select="op:practUcQ/sp:sol/*"/>
</div>
</xsl:if>
</div>
</xsl:template>
<!-- ***** BLOCS START ***** -->
<xsl:template match="sp:res[op:resInfoM/sp:index/text() = 'img']">
<xsl:variable name="name" select="tokenize(@sc:refUri, '/')[last()]"/>
<xsl:variable name="path" >
<xsl:value-of select="substring-after(@sc:refUri,'file:/')" disable-output-escaping="yes"/>
</xsl:variable>
<!-- <xsl:value-of select="document(@sc:refUri/props.xml)/imgProps/@standardCharSize" disable-output-escaping="yes"/>
<xsl:value-of select="document($path/props.xml)/imgProps/@standardCharSize"/>-->
<img src="re/{$name}" alt="{$name}">
<xsl:attribute name="size">
<xsl:value-of select="$path"/>
</xsl:attribute>
<xsl:attribute name="test">
<xsl:value-of select="if (document($path/props.xml)) then 'OK' else 'NO'"/>