!if $(module_title_$moduclass_lang)!=$empty
  !set module_title=$(module_title_$moduclass_lang)
!endif
!if $job=examcheck
  !set wims_help_parm=exam
!endif

!if $job=userexam
  !set wims_html_header=!append line <script src="scripts/js/chronoid.js"></script> to $wims_html_header
!endif
!read adm/css.phtml
!read adm/class/classname.phtml $wims_classname\
$wims_institutionname

!header1

!! not useful ???
!!!if $cmd=help
 !! !read lang/help.phtml
!! !goto end
!!!endif

!if $job!=$empty and $job!=sheets
  !read $job.phtml
  !goto endtail
!endif

!read adm/title.phtml 1\
$classname\
$module_title ($usercnt)

!if $error!=$empty
  <div class="wims_msg alert">
  !read lang/msg.phtml.$moduclass_lang
  </div>
  !set wims_ref_class=wims_button
  !if $wims_class!=$empty
    !href module=home $wims_name_class_home
  !else
    !href module=home $wims_name_home
  !endif
  !goto endtail
!endif

!set typen=!defof class_typename in wimshome/log/classes/$wims_class/.def
!if $usercnt==0
  <div class="wimscenter">
    $name_noyetparticipant
    !if $typen!=level
      &nbsp;
      !set wims_ref_class=wims_button
      !href module=adm/class/reguser&step=1 $wims_name_addstudent
      &nbsp;
    !endif
    !set wims_ref_class=wims_button
    !href cmd=reply&job=csv $wims_name_csv
  </div>
!else -- $usercnt>0
  !! !set wims_ref_class=wims_button
  !! !href cmd=reply&job=csv $wims_name_csv
  !if $seq_cnt=0
  <p>
    $name_warning_no_sequence
  &nbsp;
  !set wims_ref_class=wims_button
  !href module=adm/class/sequence&job=config $wims_name_config
 </p>
!endif
!!test inutile ?
!if $usercnt > 0
  !if $activecnt+$eactivecnt>=1
    !form reply
    <input type="hidden" name="job" value="sheets">
    !set wims_formselect_switch=multiple="multiple" size="$[min($activecnt+$eactivecnt,6)]"

    <fieldset class="property_fields blockcenter">
    <legend>$name_donchoose</legend>

    <div class="field box">
    <label for="showsheet">$name_pickup</label>
    !reset tmp
    !set seq_open=!defof sequence_open in wimshome/log/classes/$wims_class/seq/.def
    !for i=1 to $activecnt
      !set sh=!line $i of $activesheets
      !set se=!item 1 of $sh
      !if $seq_open!=yes
        !set ti=!item 4 to -1 of $sh
        !set ti=!replace internal , by &#44; in $ti
        !set tmp=!append item $se: $ti to $tmp
      !else
        !set ti=!item 5 to -1 of $sh
        !set ti=!replace internal , by &#44; in $ti
        !set seq=!item 4 of $sh
        !set tmp=!append item $seq/$se: $ti to $tmp
      !endif
    !next i
    !set ash=$activesh
    !for i=1 to $eactivecnt
      !set tt=!item $i of $activexams
      !set l=!record $tt of wimshome/log/classes/$wims_class/exams/.exams
      !set l=!line 4 of $l
      !set l=!replace internal , by &#44; in $l
      !set tmp=!append item $name_Exam $tt: $l to $tmp
      !set ash=!append item E$tt to $ash
    !next i
    !formselect showsheet list $ash prompt $tmp
    </div>
    <div class="field box">
    $name_Post
    !if $job_affi=notes or $job_affi=$empty
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=quality $(name_affi[1])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=points $(name_affi[2])
      <span class="wims_button disabled"> $(name_affi[3])</span>
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=best $(name_affi[4])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=level $(name_affi[5])
    !endif
    !if $job_affi=quality
      <span class="wims_button disabled"> $(name_affi[1])</span>
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=points $(name_affi[2])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=notes $(name_affi[3])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=best $(name_affi[4])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=level $(name_affi[5])
      !endif
    !if $job_affi=points
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=quality $(name_affi[1])
       <span class="wims_button disabled"> $(name_affi[2])</span>
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=notes $(name_affi[3])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=best $(name_affi[4])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=level $(name_affi[5])
    !endif
    !if $job_affi=best
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=quality $(name_affi[1])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=points $(name_affi[2])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=notes $(name_affi[3])
      <span class="wims_button disabled"> $(name_affi[4])</span>
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=level $(name_affi[5])
    !endif
    !if $job_affi=level
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=quality $(name_affi[1])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=points $(name_affi[2])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=notes $(name_affi[3])
      !set wims_ref_class=wims_button
      !href cmd=reply&job_affi=best $(name_affi[4])
      <span class="wims_button disabled">$(name_affi[5])</span>
    !endif
    </div>
    !if $tv_listtechvar!=$empty
      !read adm/vfilter/varfilter htmldiv
    !endif
    <div class="wimsform wimscenter">
      <input type="submit" value="$wims_name_Show">
    </div>
    </fieldset>
  !else
    !form reply
    !if $tv_listtechvar!=$empty
      !read adm/vfilter/varfilter html
    !endif
  !endif
  !formend
  !if $wims_typename notwordof group portal program
    <p>$name_sheetdetail</p>
  !endif
  !if $wims_typename notwordof group portal program
    <p>$name_click.</p>
  !endif
!endif
!reset table_center
!set table_id=TABLE_userlist
!set table_class=sortable
$table_header
!if $wims_typename notwordof group portal
  !if $job_affi=notes
    <caption>$name_formula2</caption>
  !else
    !let tmp=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
    !let tmp=!values v for v=1 to $tmp
    !let showsheet=!listintersect $showsheet and $tmp
    !if $job_affi=quality
      <caption>$name_qualitygot</caption>
    !endif
    !if $job_affi=points
      <caption>$name_percentagedone</caption>
    !endif
    !if $job_affi=best
      <caption>$name_percentagebest</caption>
    !endif
  !endif
!endif
<thead>
!if $manual>0 and $job_affi=notes
  $table_hdtr
  <th scope="col">$wims_name_lastname, $wims_name_firstname ($usercnt)</th>
  <th scope="col" class="manual_notes small" data-sort-method="number">
    <div class="wims_tooltip">$(name_manual_notes[1])
      <div class="wims_tooltiptext">$[$manual/100]* $(name_manual_notes[2])
    + $[1-$manual/100]* $(name_manual_notes[3])
      </div>
    </div>
  </th>
  <th scope="col" class="manual_notes small" data-sort-method="number">
  <div class="wims_tooltip">$(name_manual_notes[2])
    <div class="wims_tooltiptext">
    $name_manualscore
  </div></div>
  </th>
  <th scope="col" class="manual_notes small" data-sort-method="number">
    <div class="wims_tooltip">$(name_manual_notes[3])<div class="wims_tooltiptext">$name_auto</div></div>
  </th>
  !if $showsheet=$empty and $job=$empty
    <th scope="col" class="dtexolog">$name_dtexolog</th>
  !endif
  !for j in $showsheet
    !if E isin $j
      !set k=!char 2 to -1 of $j
      <th scope="col" class="name_exam small" data-sort-method="number">$name_Exam $k</th>
    !else
      <th scope="col" class="show_sheet small" data-sort-method="number">
      !set s=!record $j of wimshome/log/classes/$wims_class/sheets/.sheets
      !set s=!line 3 of $s
      !set wims_ref_title=$s
      !href cmd=reply&job=showsheet&numshowsheet=$j $name_Sheet $j
      </th>
    !endif
  !next j
  </tr>
!else
  $table_hdtr<th scope="col">$wims_name_lastname, $wims_name_firstname</th>
  !if $wims_typename iswordof group portal
    !goto endgroup
  !endif
  !if $job_affi=notes
    <th scope="col" class="average" data-sort-method="number">
      <div class="wims_tooltip">$name_Average <div class="wims_tooltiptext">$name_auto</div></div>
    </th>
  !endif
  !if $showsheet=$empty and $job=$empty
    <th scope="col" class="dtexolog" data-sort-method="number">$name_dtexolog</th>
  !endif
  !for j in $showsheet
    !if E isin $j
      !set k=!char 2 to -1 of $j
      <th scope="col" class="name_exam small" data-sort-method="number">$name_Exam $k</th>
    !else
      <th scope="col" class="small" data-sort-method="number">
      !set s=!record $j of wimshome/log/classes/$wims_class/sheets/.sheets
      !set s=!line 3 of $s
      !set wims_ref_title=$s
      !href cmd=reply&job=showsheet&numshowsheet=$j $name_Sheet $j
      </th>
    !endif
  !next j
  </tr>
!endif
:endgroup
</thead>
!distribute item 0,0,0 into mean_tea,mean_auto,mean_glob
!distribute item 0,0,0 into cnt_tea,cnt_auto,cnt_glob
!set trueusercnt=0
<tbody>
!for i=1 to $usercnt
  !set uu=!record $i of wimshome/log/classes/$wims_class/.userlist
  !distribute items $uu into user_lastname,user_firstname,uu
  !if $varfilter_!=$empty
    !reset var_filter_test
    !read adm/vfilter/testfilter $uu\
$varfilter_
    !if $var_filter_test!=1
      !goto enduser
    !endif
  !endif
  !increase trueusercnt
  !set UU=!hex $uu
  $table_tr
  !reset css_connected
  !if $uu isitemof $wims_connectedlogin
    !set css_connected=class="wims_connected"
    !set wims_ref_title=connected
  !endif
  <td><span $css_connected>
  !href cmd=reply&job=getuser&getuser=$uu#sheet$(showsheet[1]) $user_lastname $user_firstname
  </span></td>
  !if $wims_typename iswordof group portal
    !goto enduser
  !endif
  !readproc adm/class/userscore $uu
  !if $manual>0 and $job_affi=notes
    !set glob=$[rint($manual*$(manual_$UU)+(100-$manual)*($per))/100]
    !if $glob>0
      !read adm/class/colors $[ceil($glob*10/$scoremax)]
        <td style=$style_note>$glob
    !else
      <td>--
    !endif
    </td>
    !if $(manual_$UU)>0
      !read adm/class/colors $[ceil($(manual_$UU)*10/$scoremax)]
      <td style=$style_note>$(manual_$UU)
    !else
      <td>--
    !endif
    </td>
    !if $per>0
      !read adm/class/colors $[ceil($per*10/$scoremax)]
        <td style=$style_note>$per
    !else
      <td>--
    !endif
    </td>
    !distribute item $[$mean_glob+$glob],$[$mean_tea+$(manual_$UU)] into mean_glob,mean_tea
    !if $glob>0
      !advance cnt_glob
      !if $(manual_$UU)>0
        !advance cnt_tea
      !endif
      !if $per>0
        !advance cnt_auto
      !endif
    !endif
  !else
    !if $wims_typename iswordof group portal
      </tr>
      !goto enduser
    !endif
    !if $job_affi=notes
      !if $per>0
        !read adm/class/colors $[ceil($per*10/$scoremax)]
        <td style=$style_note>$per
        !advance cnt_auto
        !advance cnt_glob
      !else
        <td>--
      !endif
      </td>
    !endif
  !endif
  !set mean_auto=$[$mean_auto+$per]
  !for j in $showsheet
    !if E isin $j
      !set k=!char 2 to -1 of $j
      !set p_=$[rint(10*$scoremax*$(es_$k))/100]
      !if NaN isin $p_
        !set p_=0
      !endif
      !if $p_>0
        !read adm/class/colors $[ceil($p_*10/$scoremax)]
        <td style=$style_note>$p_
      !else
        <td>$p_
      !endif
      </td>
    !else
      !set p_=!line $j of $percents
      !distribute words $p_ into p1,p2,p3,p4
      !if $job_affi=notes
        !if $p2!=$empty
          !set sev=!line $j of $defaultformula
          !distribute word $(sev) into w_$j,s,ss
          !set tmp=!defof DF_SEVERITY in wimshome/public_html/bases/sys/define.conf
          !distribute words $tmp into bidon,tmp_s,tmp_ss
          !bound s between integer 0 and 6 default $tmp_s
          !bound ss between integer 0 and 2 default $tmp_ss
          !reset tmp tmp_s tmp_ss
          !set f_$j=!item $s+1 of $formula_list
          !set f_$j=!replace internal I by I$ss in $(f_$j)
          !distribute item $[$p1/100],$[$p2/10],$[$p3/100], $[$p4/100] into x0_,y_,x1_,x2_
          !set ff_$j=!mathsubst Q=$y_ in $(f_$j)
          !for sev=0 to 2
            !set ff_$j=!mathsubst I$sev=$(x$(sev)_) in $(ff_$j)
          !next
          !set p_=$[rint(100*$scoremax*$(ff_$j))/100]
        !else
          !set p_=0
        !endif
        !if $p_>0
          !read adm/class/colors $[ceil(10*$p_/$scoremax)]
          <td style=$style_note>$p_
        !else
          <td>--
        !endif
        </td>
      !else
        !if quality iswordof $job_affi
          !set p_=$p2
          !if $p_>0
            !read adm/class/colors $[ceil($p_)]
            <td style=$style_note>$p_
          !else
            <td>--
          !endif
          </td>
        !endif
        !if points iswordof $job_affi
          !set p_=$p1
          !if $p_>0
            !read adm/class/colors $[ceil($p_/10)]
            <td style=$style_note>$p_ %
          !else
            <td>--
          !endif
          </td>
        !endif
        !if best iswordof $job_affi
          !set p_=$p3
          !if $p_>0
            !read adm/class/colors $[ceil($p_/10)]
            <td style=$style_note>$p_ %
          !else
            <td>--
          !endif
          </td>
        !endif
        !if level iswordof $job_affi
          !set p_=$[$p4/10]
          !if $p_>0
            !read adm/class/colors $[ceil($p_)]
            <td style=$style_note>$p_
          !else
            <td>--
          !endif
          </td>
        !endif
        !if $p2=$empty
          !set $p_=0
        !endif
      !endif
    !endif
    !set per_$j=$[$(per_$j)+$p_]
    !if $p_>0
      !advance cnt_$j
    !endif
  !next j
  !if $showsheet=$empty and $job=$empty
    !set exologs=!filelist $wims_home/log/classes/$wims_class/exolog/$uu
    !set dtexologs=!word -1 of $exologs
    !set dtexologs=!char 1 to 8 of $dtexologs
    <td>$dtexologs</td>
    !reset dtexologs
  !endif
  </tr>
:enduser
!next i
</tbody>
!if $wims_typename iswordof group portal
  $table_end
  !read tablesort.phtml
  !goto endtail
!endif
<tfoot>
!distribute item $[rint(100*$mean_auto/$trueusercnt)/100],\
  $[rint(100*$mean_tea/$trueusercnt)/100],\
  $[rint(100*$mean_glob/$trueusercnt)/100] into m_auto,m_tea,m_glob
$table_hdtr<th>$name_groupAverage ($trueusercnt)</th>
!if $job_affi=notes
  !if $manual>0
    !if $m_glob >0
      !read adm/class/colors $[ceil($m_glob*10/$scoremax)]
      <td style=$style_note>$m_glob
    !else
      <td>--
    !endif
    </td>
    !if $m_tea >0
      !read adm/class/colors $[ceil($m_tea*10/$scoremax)]
      <td style=$style_note>$m_tea
    !else
      <td>--
    !endif
    </td>
    !if $m_auto>0
      !read adm/class/colors $[ceil($m_auto*10/$scoremax)]
      <td style=$style_note>$m_auto
    !else
      <td>--
    !endif
    </td>
  !else
    !if $m_auto>0
      !read adm/class/colors $[ceil($m_auto*10/$scoremax)]
      <td style=$style_note>$m_auto
    !else
      <td>--
    !endif
     </td>
  !endif
  !if $showsheet=$empty and $job=$empty
    <td>$showsheet</td>
  !endif
!endif
!for j in $showsheet
  !if $[rint(100*$(per_$j)/max(1,$trueusercnt))/100]>0
    !if $job_affi=points
      !read adm/class/colors $[ceil($(per_$j)/max(1,$trueusercnt)/10)]
      <td style=$style_note>$[rint(100*$(per_$j)/max(1,$trueusercnt))/100] %
    !else
      !read adm/class/colors $[ceil($(per_$j)/max(1,$trueusercnt)*10/$scoremax)]
      <td style=$style_note>$[rint(100*$(per_$j)/max(1,$trueusercnt))/100]
    !endif
  !else
    <td>--
  !endif
  </td>
!next j
!if $cnt_glob>0
  !distribute item $[rint(100*$mean_auto/max(1,$cnt_auto))/100],\
   $[rint(100*$mean_tea/max(1,$cnt_tea))/100],\
   $[rint(100*$mean_glob/max(1,$cnt_glob))/100] into m_auto,m_tea,m_glob
  </tr>
  $table_hdtr<th>$name_posAverage ($cnt_glob)</th>
  !if $manual>0
    !if $m_glob>0
      !read adm/class/colors $[ceil($m_glob*10/$scoremax)]
        <td style=$style_note>$m_glob
    !else
      <td>--
    !endif
    </td>
    !if $m_tea>0
      !read adm/class/colors $[ceil($m_tea*10/$scoremax)]
      <td style=$style_note>$m_tea
    !else
      <td>--
    !endif
    </td>
    !if $m_auto>0
      !read adm/class/colors $[ceil($m_auto*10/$scoremax)]
        <td style=$style_note>$m_auto
      !else
        <td>--
      !endif
      </td>
    !else
      !if $m_auto>0
        !read adm/class/colors $[ceil($m_auto*10/$scoremax)]
        <td style=$style_note>$m_auto
      !else
        <td>--
      !endif
      </td>
    !endif
    !for j in $showsheet
      !if $[rint(100*$(per_$j)/max(1,$(cnt_$j)))/100]>0
        !read adm/class/colors $[ceil($(per_$j)/max(1,$(cnt_$j))*10/$scoremax)]
        <td style=$style_note>$[rint(100*$(per_$j)/max(1,$(cnt_$j)))/100]
      !else
        <td>--
      !endif
       </td>
    !next j
    !if $showsheet=$empty and $job=$empty
      <td></td>
    !endif
  !endif
  </tr>
  </tfoot>
  $table_end
  !read tablesort.phtml
!endif (usercnt=0?)

!set wims_menu_items=!append line itemsep,0,\
csv,1,cmd=reply&job=csv\
grades,1,module=adm/class/grades\
 itemsep,0,\
formula,1,cmd=reply&job=formula&formula=prep\
to $wims_menu_items
!if (($wims_supertype<4 and $wims_typename=class) or ($wims_supertype=4 and $wims_typename iswordof course program)) and $wims_showlivret!=no
  !set wims_menu_items=!append line itemsep,0,$wims_name_Evaluation\
livret,1,module=adm/class/livret\
  to $wims_menu_items
!endif

!if $usercnt!=0
  !set wims_menu_items=!append line activity,1,module=adm/class/activity\
 class_stat,1,module=adm/class/stat\
to $wims_menu_items
!endif

!!!!!if $manual>0
!!!!  <div class="wims_msg info">$wims_name_Explanations
!!!!  <div class="wimscenter">
!!!!  moyenne des notes sur les feuilles et examens pondérée par les poids attribués à chacune de  ces activités.
!!!!  $(name_manual_notes[1]) = $[$manual/100]* $(name_manual_notes[2])
!!!!    + $[1-$manual/100]* $(name_manual_notes[3])
!!!!  </div>
!!!!  </div>
!!!!!endif

:endtail
!tail

!reset job,showsheet,getuser,getraw,delprep,deluser,formula,abandon,reg,\
   passcheck
