<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <!-- =============================================================== -->
  <!-- node-list-edit.xsl (v001) -                                     -->
  <!-- opprettet 11.03.05 - oddmund.mogedal@usit.uio.no                -->
  <!-- =============================================================== -->

  <!-- =============================================================== -->
  <!-- Dokumenttypens hovedelement blir matchet i system-edit.xsl.     -->
  <!-- =============================================================== -->
  <xsl:import href="../../../system/system-edit-v001.xsl"/>

  <xsl:import href="../../../common/components/structuredtext/v002/structuredtext-edit.xsl" />
  <xsl:import href="../../components/image-node/v001/image-node-edit.xsl" />
  <xsl:import href="../../components/node-list-ref/v001/node-list-ref-edit.xsl" />

  <!-- =============================================================== -->
  <!-- Templates som kalles i system-edit.xsl og som kan overstyres.   -->
  <!-- Se avsnitt "Template name API" i system-edit.xsl for oversikt   -->
  <!-- over disse.                                                     -->
  <!-- =============================================================== -->

  <!-- Definer det statiske elementet rett før de flyttbare elementene -->
  <xsl:variable name="movable-or-deletable-elements-after" select="'number-of-questions'" />

  <!-- DTD-syntaks for flyttbare og slettbare elementer (men ikke bruk mellomrom)-->
  <xsl:variable name="movable-or-deletable-elements" select="'(question-choice|question-open)*'" />

  <!-- css-klasser kan som brukes i denne dok. typen kan legges inn her -->
  <xsl:template name="css-classes" />
 
  <xsl:template name="shortcutlinks-put-bottom" />

  <!-- =============================================================== -->
  <!-- Templater for visning og redigering legges her.                 -->
  <!-- Elementene som skal redigeres må ha: mode="edit"                -->
  <!-- =============================================================== -->

  <xsl:template match="title|author|number-of-questions|instruction|response|validity">
    <div>
      <b><xsl:value-of select="name()" />:</b>&#160;<xsl:value-of select="." /> 
      <xsl:call-template name="insert-edit-link" /> 
    </div>
  </xsl:template>

  <xsl:template match="title|author|number-of-questions|instruction|response|validity" mode="edit">
    <xsl:call-template name="insert-inputfield" />
  </xsl:template>

  <xsl:template match="quiz-mode|ordering|type">
    <div>
      <b><xsl:value-of select="name()" />:</b>&#160;<xsl:value-of select="." /> 
      <xsl:call-template name="insert-edit-link" /> 
    </div>
  </xsl:template>

<!-- TODO: quiz-mode, ordering, type need mode="edit" -->

<!-- TODO: quiz-mode, ordering, type need mode="edit" -->

  <!-- Structuredtext with other names, need label -->
  <xsl:template match="feedback|followup|description|structuredtext">
    <b><xsl:value-of select="name()" />:</b>&#160;<xsl:call-template name="insert-edit-link" /><xsl:apply-templates />
  </xsl:template>

  <!-- Structuredtext with other names mode="edit" -->
  <xsl:template match="feedback|followup|description" mode="edit">
     <xsl:call-template name="insert-textarea" />
  </xsl:template>


  <!-- brukes for å lage knapper -->
  <xsl:template name="choice-subelements">
      <xsl:choose>
        <xsl:when test="name()='alternatives'">
          <xsl:value-of select="'answer'" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="''" /> <!-- returnerer tom verdi, brukes ikke (så vidt jeg husker) -->
        </xsl:otherwise>
      </xsl:choose>
  </xsl:template>

  <xsl:template match="question-choice|question-open">
    <b><xsl:value-of select="name()" />:</b>&#160;<xsl:call-template name="insert-edit-link" /> <br />
    <xsl:apply-templates select="@*" />
    <div style="padding-left: 1em;"><xsl:apply-templates select="*" /></div>
  </xsl:template>

  <xsl:template match="answer">
    <b><xsl:value-of select="name()" />:</b>&#160;<xsl:call-template name="insert-edit-link" /> <br />
    <xsl:apply-templates select="@*" />
    <div style="padding-left: 1em;"><xsl:apply-templates select="*" /></div>
  </xsl:template>

  <xsl:template match="alternatives">
    <b><xsl:value-of select="name()" />:</b>
    <xsl:apply-templates select="@*" />
    <div style="padding-left: 1em;"><xsl:apply-templates select="*" /></div>
  </xsl:template>


  <xsl:template match="question-choice|question-open|content|answer" mode="edit">
    <xsl:call-template name="sequence-edit" />
  </xsl:template>

  <xsl:template match="alternatives" mode="edit">
    <xsl:call-template name="choice-edit" />
  </xsl:template>

  <xsl:template match="content">
    <b><xsl:value-of select="name()" />:</b><br />
    <xsl:apply-templates select="@*" />
    <div style="padding-left: 1em;"><xsl:apply-templates select="*" /></div>
  </xsl:template>

</xsl:stylesheet>
