!! this file explain how to make a new type of zone. You can duplicate it and adapt to your case
!! the name of the file is the name code of the type and you have to add it to variable listfilename_ztype in var.proc file (if you want the module use it)
!! the name should use only alpha character (not numeric, no punctuation)

!! process to manage .... zone
!! firstline 
!! word 1 : type of process to read (parahtml/pararead/parasave/displayhtml/displaysave/displayread)
!! word 2 : keyword teacher or student (teacher is used when the zone is in the statement of the freework and student in the answer of the freework)
!! word 3 : identification number of the zone
!! word 4 : 1 (activated) 0 (notactivated)
!! word 5 : login of the user (only needed when word2 is student).
!!
!! the group of process paraX is interface to make htmlform/save/read parameters of the zone (max 5 parameters)
!! the group of process displayX is interface to make htmlform/save/read data written by participant (teacher or participant according to word 2 keyword)
!! 

!set p_=!line 1 of $wims_read_parm
!distribute word $p_ into proc_,stype_,zone_,activated_,user_
!bound activated_ within 1,0 default 0
!goto $proc_
!exit

:parahtml
!! form html interface for choose parameters of the zone (use only by supervisor when he make the freework)
!! only 5 parameters are allowed
!! in general the first is title and second is description (but it is not obligatory)
!!
  !! ----- first parameter (title)
  !let num_=$[($zone_-1)*5+1]
  <div class="field box">
    !if $activated_=1
       <label for="param$(stype_)$num_"> $(name_titlezone)</label>
       <input type="text" id="param$(stype_)$num_" name="param$(stype_)$(num_)" value="$(param$(stype_)$(num_))" />
       <div class="formHelp">$name_desc_title</div>
    !else
      <strong>$(name_titlezone)</strong>
      <p>$(param$(stype_)$(num_))</p>
    !endif
  </div>
  !! ----- second parameter - description
  !let num_=$[($zone_-1)*5+2]
  <div class="field box">
    !if $activated_=1
       <label for="param$(stype_)$num_"> $(name_desczone)</label>
       <textarea name="param$(stype_)$(num_)" id="param$(stype_)$(num_)" rows="10" cols="100" class="iEdit" maxlength="$desc_limit">$(param$(stype_)$(num_))</textarea>
       <div class="formHelp">$name_desc_desc</div>
    !else
      <strong>$(name_desczone)</strong>
      <div>$(param$(stype_)$(num_))</div>
    !endif
  </div>
  !! ---- third parameter ...

!exit

:pararead
  !! parameters reading interface
  !! parameters is saving in a multiline variable named script_data (saving is doing by another file)
  !! each line of script_data is a parameters
  !! you have to dispatch each parameters in variable param$(stype_)$[$zone_-1)*5+XX] (where XX is the number of the parameter).
  !! you have to check conform values for each parameters.
  !! --- parameter read 1 (title)
  param$(stype_)$[($zone_-1)*5+1]=!line 1 of $script_data
  param$(stype_)$[($zone_-1)*5+1]=!detag $(param$(stype_)$[($zone_-1)*5+1])
  param$(stype_)$[($zone_-1)*5+1]=!char 1 to $title_limit of $(param$(stype_)$[($zone_-1)*5+1])
  !! --- parameter read 2 (description)
  param$(stype_)$[($zone_-1)*5+2]=!line 2 of $script_data
  param$(stype_)$[($zone_-1)*5+2]=!char 1 to $desc_limit of $(param$(stype_)$[($zone_-1)*5+2])
  !! -- parameter read 3 (...)

!exit

:parasave
  !! inverse process of pararead.
  !! you have to construct the multiline variable, named output_data, to preparing parameters data to be save
  !! --- parameter save 1 (title)
  output_data=!replace internal $\
$ by ; in $(param$(stype_)$[($zone_-1)*5+1])
  output_data=!detag $output_data
  output_data=!char 1 to $title_limit of $output_data
  !! --- parameter save 2 (description)
  tmpdata_=!replace internal $\
$ by ; in $(param$(stype_)$[($zone_-1)*5+2])
  tmpdata_=!char 1 to $desc_limit of $tmpdata_
  output_data=$output_data\
$tmpdata_
 !! --- parameter save 3 (...)

!exit

:displayhtml
!! this process construct the html form for the zone (teacher if $stype_=teacher or participant ifnot)
!! you have to take care of two case choosing by the value of activated_ variable (if activated_=1 the form is modifiable by teacher/participant and if activated_=0 not modifiable)
!! for some zone the display for supervisor (when he build the freework) is not the same of the display for participant. In this case, you have to use job=configfw 
!! when you are in the case of freework building
!! answer have to be put in variable freepar_applet$zone_ (see existing zone file to have exemple)
!! you can read older answer file (see process displaysave for more details)

<div class="field box">
  !if $job!=configfw
    !if $activated_=1

    !else

    !endif
  !else
    !if $activated_=1

    !else

    !endif
  !endif
</div>
!exit

:displayread
  !! this part is read by the .proc process before reading displayhtml. You can preparing somes action.
  !! evenif you put nothing you mustn't delete this section.
  
!exit

:displaysave
  !! section to save the data of the zone in a file. To respect compatibility with other zone you have to respect rules :
  !! filename is : .$user_-XXX.$zone_ for participant zone or .teacher-XX$zone_ for teacher zone (distinction is make with variable $stype_)
  !! XX is the code name of the zone you have choose
  !! dirname is $wims_class/freeworks/$freework for teacher zone and $wims_class/freeworksdata/$freework/work for participant zone
  !! you can make some verification of data before saving
  !! ------- put verification of variable here

  !! ------ data saving (replace XXX by the code name of the zone you choose)
  !if $(freepar_applet$zone_)!=$empty
    !if $stype_=teacher
      file_=wimshome/log/classes/$wims_class/freeworks/$freework/.teacher-XXX$zone_
    !else
      file_=wimshome/log/classes/$wims_class/freeworksdata/$freework/work/$user_-XXX.$zone_
    !endif
    !writefile $file_ $(freepar_applet$zone_)
  !endif
!exit
