!set tmp=!defof DF_SEVERITY in wimshome/public_html/bases/sys/define.conf
!distribute words $tmp into tmp_w,tmp_s,tmp_ss
!read adm/title.phtml 1\
$classname\
$name_workdetail $name_studentloc

<div class="center"><span class="wims_emph">
  !if $wims_user=supervisor
    !reset css_connected
    !if $getuser isitemof $wims_connectedlogin
      !set css_connected=class="wims_connected"
      !set wims_ref_title=connected
    !endif
    <span $css_connected>
      !href module=adm/class/usermanage/&job=userprop&getuser=$getuser $name_studentloc
    </span>
  !endif
  </span><br><span class="small">$wims_name_Login: <span class="tt">$getuser</span>
  !if $user_external_auth!=$empty
    (<span class="tt">$user_external_auth</span>)
  !endif
  !if $user_email!=$empty
    <br>
    $wims_name_email: <a href="mailto:$user_email">$user_email</a>
  !endif
</span></div>

!let testphoto=!filexists wimshome/sessions/$wims_session/getfile/photoboard/$getuser
!if $testphoto=yes
  <div id="userlogo" class="float_right">
    <img src="$wims_ref_name?session=$wims_session&cmd=getfile&special_parm=photoboard/$getuser" style="position:absolute;top:50px;right:5%;" alt="$name_student2">
  </div>
  !reset testphoto
!else
  !if $user_photourl!=
    <img src="$user_photourl" style="width:100px;position:absolute;top:50px;right:5%;" alt="$name_student2">
  !endif
!endif
!if $eremain>0
  <br class="spacer">
  $name_activesession:
  !href cmd=reply&job=userexam&getuser=$getuser $esession
  !!!else
  !! ----- transfere dans usermanage (il s'agit d'un lien de transfert de score pour deplacer des eleves d'une classe a l'autre (dans un portail ou un groupement)
  !! !if $wims_user=supervisor and $wims_supertype iswordof 2 4
  !!  !readproc adm/gateway/transfer $getuser test
  !!  !if $transfer_test>0
  !!   !href module=adm/class/usermanage&job=transfer&getuser=$getuser $name_transfer
  !!  !endif
  !! !endif
!endif

<br class="spacer">

!if $manual>0 and $gcnt>0 and $teacher!=$empty
  !if $class_hideaverage!=yes
    $table_header
    <caption><span class="small">
    $name_minmax:
    $min_glob/$mean_glob/$max_glob</span></caption>
    <thead>
    $table_hdtr<th>$wims_name_name</th><th>$(wims_name_thsheet[6])</th><th>$(wims_name_thsheet[9])</th></tr>
    </thead><tbody>
    $table_tr<th>$name_manualscore</th>
       <td>$manual%</td>
       !read adm/class/colors $[ceil(10*$mav/$scoremax)]
       <td style=$style_note>$mav</td></tr>
    $table_tr<th>$name_autoscore</th>
       <td>$[100-$manual]%</td>
       !read adm/class/colors $[ceil(10*$per/$scoremax)]
       <td style=$style_note>$per</td></tr>
    $table_tr<th>$name_globalaverage / $scoremax</th>
       <td>100%</td>
       !read adm/class/colors $[ceil(10*$globalav/$scoremax)]
       <td style=$style_note>$globalav</td></tr>
    </tbody>
    $table_end
  !endif

  !set table_id=TABLE_manual
  !set table_class=sortable
  $table_header
  <thead>
    <tr><th colspan="3">$name_manualscore
    !if $wims_user=supervisor
      <br>
      !href lang=$lang&module=adm/class/grades&method=user&un=$getuser $wims_name_change
    !endif
    </th></tr>
    $table_hdtr<th>$(wims_name_thsheet[2])</th><th>$(wims_name_thsheet[4])</th><th>$(wims_name_thsheet[9])</th></tr>
  </thead>
  !set v_=0
  <tbody>
  !for i=1 to $gcnt
    $table_tr<td>$(titles[2+$i])</td><td>$(w$i)</td>
    !read adm/class/colors $[10*ceil($(g_$i))/$scoremax]
    <td style=$style_note>$(g_$i)</td></tr>
  !next i
  </tbody>
  <tfoot>
    $table_hdtr<th colspan="2">$name_Average</th>
    !read adm/class/colors $[ceil(10*$mav/$scoremax)]
    <td style=$style_note>$mav</td></tr>
  </tfood>
  $table_end
  !read tablesort.phtml
!else
  !if $class_hideaverage!=yes
    <div class="wimscenter">
    $name_globalaverage: <b>$per</b> / $scoremax.
    !if $min_glob<$scoremax
      <br><span class="small">$name_minmax:
      $min_glob/$mean_glob/$max_glob</span>
    !endif
    </div>
  !endif
!endif

!!readdef wimshome/log/classes/$wims_class/.def
!!default class_topscores=0
!if $class_topscores>0 and $class_hideaverage!=yes

  $table_header$table_hdtr<th colspan="2">$name_topten</td></tr>
  !for i=1 to $class_topscores
    !set L=!line $i of $TT
    !if $class_anonymtopscores=yes
      !set name=$i
    !else
      !set name=!item 1 of $L
      !set firstname=!item 2 of $L
      !set name=$name $firstname
    !endif
    !set avg=!item 4 of $L
    $table_tr
      <td class="small" style="text-align:right;font-weight:bold">
      $name &nbsp;</td>
      <td style="text-align:left" class="small">&nbsp;$avg</td>
    </tr>
  !next i
  $table_end

!endif

!! ---------------- display table for each exam session
!if $eactivecnt>0
  !set table_id=TABLE_exam
  !set table_class=sortable
  $table_header
  <thead>
  <caption>$name_examnote</caption>
  $table_hdtr
    <th scope="col">$(wims_name_thsheet[1])</th>
    <th scope="col">$(wims_name_thsheet[2])</th>
    <th scope="col">$(wims_name_thsheet[9])/$scoremax</th>
  </tr>
  </thead>
  <tbody>
  !for i in $activexams
    !set l=!record $i of wimshome/log/classes/$wims_class/exams/.exams
    !set t=!line 4 of $l
    !set st=!line 1 of $l
    !set ew=!line $i of $examweights
    !! ------test if sheet is hidden for this user
    !reset hidden_sheet
    !if $wims_user!=supervisor
      !set h_=!line 8 of $l
      !if $h_!=$empty
        !readproc adm/vfilter/ishiddensheet.proc $h_
      !endif
    !endif
    !! -----end test
    !if ($st<=2 or $ew>0) and $hidden_sheet!=1
     $table_tr
      <td>$i</td>
      <td>$t</td>
      !if $[rint(10*$(es_$i)*$scoremax)/100]>0
        !read adm/class/colors $[ceil($(es_$i))]
        <td style=$style_note>$[rint(10*$(es_$i)*$scoremax)/100]</td>
      !else
        <td>--</td>
      !endif
     </tr>
    !endif
  !next i
  </tbody>
  $table_end
  !read tablesort.phtml
!endif

!! ------------------ display table for freeworks
!if $allowed_freework=yes

  !! In the student score page we list only freeworks for which the
  !! student has been doing some work (for some types this can simply
  !! mean opening the freework). Visibility (of student work and of
  !! score) is set according to freework status.
  !!
  !! If scoring is available it is advisable to disable manual scoring
  !! interface, otherwise students can see scores befeore due date.
  !!
  !if $nbfreeworks > 0
    !set table_id=TABLE_freew
    !set table_class=sortable
    !set name_fwcols=$(wims_name_thsheet[1]),$(wims_name_thsheet[2]),$name_handedin,$name_deadline,$(wims_name_thsheet[9])
    !if $wims_user=supervisor
      !set name_fwcols=$name_fwcols,$name_codownload,$name_fwscoring,$name_putiworkco
    !endif
    $table_header
    <thead>
    <caption>$wims_name_Freeworks</caption>
    $table_hdtr
    !for l_ in $name_fwcols
      <th scope="col">$l_</th>
    !next
    </tr>
    </thead>
    <tbody>
    !for fwi_ in $activefreew
      !reset loadwork codownload seealltime putiworkco scoring
      !readproc adm/freework/mkfwglobvar.proc $fwi_
      !! l'output di questo è in "output" (!!!!)
      !readproc adm/freework/finduserwork.proc $fwi_,$getuser
      $table_tr
      <td>$fwi_</td>
      <td>$title</td>
      !if ($wims_user=supervisor and $loadwork>0) or $wims_user!=supervisor
        <td>
        !if $fwtype=3
          !href module=adm/class/freework&+job=viewuser3&+freework=$fwi_&+userv=$getuser $output
        !else
          !href module=adm/class/freework&+job=viewuser&+freework=$fwi_ $output
        !endif
        </td>
      !else
        <td style="background-image:url(gifs/bg/crossgrey.gif)">$output</td>
      !endif
      <td>$deadline $timedeadline</td>

!! for visibility of scores, cfr. freework/student3.phtml
      !if $scoring>0 and ($codownload>0 or $wims_user=supervisor or $activetest>=2)
        !read adm/class/colors $[10*ceil($(g_$scoring))/$scoremax]
        <td style=$style_note>$(g_$scoring)</td>
      !else
        <td style="background-image:url(gifs/bg/crossgrey.gif)">&nbsp;</td>
      !endif
      !if $wims_user=supervisor
        <td>
        !if $codownload=1
          $wims_name_yes
        !else
          $wims_name_no
        !endif
        !set fwseetest=!defof freework_seeco_$getuser in wimshome/log/classes/$wims_class/freeworksdata/$fwi_/.seeco
        !if $fwseetest!=$empty
           &#x2705;
          !reset fwseetest
        !endif
        </td><td>
        !if $scoring=0 or $scoring=no
          $wims_name_no
        !else
          $(titles[2+$scoring])
        !endif
        </td><td>
        !if $putiworkco=1
          $wims_name_yes
        !else
          $wims_name_no
        !endif
        </td>
      !endif
      </tr>
    !next fwi_
    </tbody>
    $table_end
    !read tablesort.phtml
  !endif
!endif

!! ------------------ display table for each sheet
!set tmp=!defof DF_SEVERITY in wimshome/public_html/bases/sys/define.conf
!distribute words $tmp into tmp_w,tmp_s,tmp_ss
!for i=1 to $activecnt
  !set exonumber=0
  !set l_=!line $i of $activesheets
  !distribute items $l_ into n_,e_,indtechvar
  !set L_=!line $n_ of $defaultformula
  !reset A_ B_ C_
  !distribute word $L_ into A_,B_,C_
  !default A_=$tmp_w
  !default B_=$tmp_s
  !default C_=$tmp_ss
  !set t_=!item 4 to -1 of $l_
  !set t_=!char 1 to $title_limit of $t_
  !set v_=!getscorerequire sheet=$n_ user=$getuser
  !set w_=!wordcnt $v_
  !set S_=0
  !for k=1 to $w_
    !set a_=!word $k of $v_
    !set S_=$[$S_+$a_]
  !next k
  !if $S_<=0
    !goto next
  !endif
  !set sw=!line $[$n_+1] of $shweights
  !set q=!word 2 of $sw
  !set sw=!word 3 of $sw
  !bound sw between integer 0 and 2 default $tmp_ss
  !bound q between integer 0 and 6 default $tmp_s
  !set seq_open=!defof sequence_open in wimshome/log/classes/$wims_class/seq/.def
  !if $indtechvar!=$empty
    !let pos_=!positionof item $indtechvar in $tv_listcode
    !let nametechvar=!item $pos_ of $tv_listname
    !set pos=!positionof item $nametechvar in $(user_vars[;1])
    !set indtechvarvalue=!item $pos of $(user_vars[;2])
    !set listvalue=!record $n_ of wimshome/log/classes/$wims_class/sheets/.vars
    !set listvalue=!word 3 to -1 of $listvalue
    !set listvalue=!words2items $listvalue
    !bound indtechvarvalue within $empty,$listvalue default $empty
    !if $indtechvarvalue=$empty
        !reset tmp
    !else
        !set tmp= - $nametechvar $indtechvarvalue
    !endif
  !else
    !reset tmp
  !endif
  !if $seq_open!=yes
    !set hat=$name_Sheet $n_$(tmp)&nbsp; : $t_
  !else
    !set hat=$wims_name_sequence $(t_[1])$tmp&nbsp; : $(t_[2..-1])
  !endif

  <br class="spacer">
  !if $wims_user=supervisor
    !set nb_indic=5
  !else
    !set nb_indic=3
  !endif
  !set P_=!line $n_ of $percents
  !distribute words $P_ into p1,p2,p3,p4
  !if $p2!=$empty
    !distribute item $[$p1/100],$[$p2/10],$[$p3/100],$[$p4/100] into x0_,y_,x1_,x2_
    !set ff_$n_=!mathsubst Q=$y_ in $(f_$n_)
    !for sev=0 to 2
      !set ff_$n_=!mathsubst I$sev=$(x$(sev)_) in $(ff_$n_)
    !next
    !! home/sequence.phtml
    !! adm/class/userscore/csv/download.proc
    !! themes/_widgets/usersheet.phtml
    !set p_=$[rint(100*$scoremax*$(ff_$n_))/100]
  !endif
  !set table_id=TABLE_sheet$i
  !set table_class=sortable
  !set tmp_sheetstatus=!getsheetstatus sheet=$n_ user=$getuser
  !set tmp_sheetstatusgen=!getsheetstatus sheet=$n_ user=no
  $table_header
  <thead id="sheet$n_">
  <tr><th colspan="$[$nb_indic+5]" style="text-align:left">
  !if $p2!=$empty
    <div class="float_left">
    !if ($seq_open!=yes or $(listshowseq[$(t_[1])])=1) and $tmp_sheetstatus < 3
      !href module=adm/sheet&sh=$n_ $hat
    !else
      $hat
    !endif
    <ul>
      <li>
      !set tmp=$[$tmp_sheetstatus+1]
      !if $tmp_sheetstatus > $tmp_sheetstatusgen
!! hidden for this student
        !increase tmp
      !endif
      $(wims_name_shstatus[$tmp])</li>
      <li>$(wims_name_thsheet[4]): $A_</li>
      !if $wims_user=supervisor
        <li>$(wims_name_thsheet[8]):
        !lowercase $(f_$n_)
        </li>
      !endif
      !!global note
      !if $(min_$n_)<$scoremax
           <li>$name_minmax: $(min_$n_)/$(mean_$n_)/$(max_$n_)</li>
      !endif
      </ul>
      </div>
      !reset tmp_ss
      <ul class="float_right">
      !! score
      <li>$(wims_name_thsheet[9]):
        $p_
      / $scoremax
      !if $wims_user!=supervisor
        !set wims_ref_class=wims_button_help
        !href cmd=help&special_parm=$n_ $(wims_name_help)
      !endif
      </li>
      !! quality
      !if $wims_user=supervisor or $q!=1
        <li>$(wims_name_thsheet[7]):
          $p2
        /10</li>
      !endif
      !! Cumul
      !if $wims_user=supervisor or $sw=0
        <li>$(wims_name_thsheet[5]):
             $p1
         %</li>
      !endif
      !! Best score
      !if $wims_user=supervisor or $sw=1
        <li>$(wims_name_thsheet[10]):
             $p3
        %</li>
      !endif
      !! Acquired
      !if $wims_user=supervisor or $sw=2
        <li>$(wims_name_thsheet[13]):
             $[$p4/10]
        /10</li>
      !endif
    </ul>
  !else
    !href module=adm/sheet&sh=$n_ $hat
  !endif
  </th></tr>
  $table_hdtr
    <th scope="col" data-sort-method="number">$(wims_name_thsheet[1])</th>
    <th scope="col">$(wims_name_thsheet[2])</th>
    <th scope="col" data-sort-method="number">$(wims_name_thsheet[3])</th>
    <th scope="col" data-sort-method="number">$(wims_name_thsheet[4])</th>
    !!qualite
    <th scope="col" data-sort-method="number">$(wims_name_thsheet[7])</th>
    !if $wims_user=supervisor or $sw=0
      !!I0: percentage work (related to cumul)
      <th scope="col" data-sort-method="number">$(wims_name_thsheet[5])</th>
    !endif
    !if $wims_user=supervisor or $sw=1
      !!I1: best percentage
      <th scope="col" data-sort-method="number">$(wims_name_thsheet[10])</th>
    !endif
    !if $wims_user=supervisor or $sw=2
      !!I2: level
      <th scope="col" data-sort-method="number">$(wims_name_thsheet[13])</th>
    !endif
    !!last
    <th scope="col" data-sort-method="number">$(wims_name_thsheet[12])</th>
    !!number try
    <th scope="col" data-sort-method="number">
      <div class="wims_tooltip">$(wims_name_thsheet[11])
        <div class="wims_tooltiptext left" style="width:50em">
          $name_tryhelp
        </div>
      </div>
    </th>
  </tr>
  </thead>
  <tbody>
  !for j=1 to $e_
    !let d=!record $j of wimshome/log/classes/$wims_class/sheets/.sheet$n_
    !distribute line $d into t,t,t,t,title_,t,t,t,t,t,indiv_
    !if $indtechvar=$empty or $(user_techvar_$indtechvar)=$empty or $(user_techvar_$indtechvar) isitemof $indiv_
      !increase exonumber
      $table_tr
        <td>$exonumber</td>
        <td>$(title_)</td>
        <td>
          !let req_=!getscorerequire user=$getuser sheet=$n_ work=$j
          $(req_)
        </td><td>
          !getscoreweight user=$getuser sheet=$n_ work=$j
        </td>
        !set try=!getscoretry user=$getuser sheet=$n_ work=$j
        !set alltry=!getscorealltries user=$getuser sheet=$n_ work=$j
        !if $alltry<=0
          !set makelist=!makelist <td>--</td> for j=1 to $nb_indic+1
          !replace , by in $makelist
        !else
          !!!quality in exercise will always appear.
          !set d_=!getscorequality user=$getuser sheet=$n_ work=$j
          !default d_=0
          !read adm/class/colors $[ceil($d_)]
          <td style=$style_note>$d_</td>
          !!cumul
          !if $wims_user=supervisor or $sw=0
            !set d_=!getscore user=$getuser sheet=$n_ work=$j
            !default d_=0
            !!percentage
            !if $(req_)>0
              !read adm/class/colors $[ceil(10*$d_/$(req_))]
              <td style=$style_note>$[ceil(100*$d_/$(req_))]%</td>
            !else
              <td>--</td>
            !endif
          !endif
          !if $wims_user=supervisor or $sw=1
            !!best percentage
            !set best=!getscorebest user=$getuser sheet=$n_ work=$j
            !if $(req_)>0
              !read adm/class/colors $[ceil(10*$best/$req_)]
              <td style=$style_note>$[ceil($[$best*100/$req_])]%</td>
            !else
              <td>--</td>
            !endif
          !endif
          !if $wims_user=supervisor or $sw=2
            !!level
            !set level=!getscorelevel user=$getuser sheet=$n_ work=$j
            !read adm/class/colors $[min(ceil($level+0.1),10)]
            <td style=$style_note>$level</td>
          !endif
          !!last
          !set last=!getscorelast user=$getuser sheet=$n_ work=$j
          !read adm/class/colors $[ceil($last)]
          <td style=$style_note>$last</td>
          !!try
          <td>
            !set tmp=!record $j of wimshome/log/classes/$wims_class/sheets/.sheet$n_
            !distribute lines $tmp into di,pa
            !read getparm $pa, seedrepeat, exotrymax
            !set tmp=!getseedscores user=$getuser sheet=$n_ work=$j
            !set tmp=!declosing $tmp
            !set tmp=!select $tmp where column 2 > -2
            !set tmp_cnt=!itemcnt $(tmp[;1])
            !if $get_seedrepeat>0
              !set tmp_width=width:$[ceil($tmp_cnt/$get_seedrepeat)+1]em;
            !else
              !set tmp_width=width:$[$tmp_cnt+1]em;
            !endif
            <div class="wims_tooltip">
              !if $get_exotrymax=$empty
                $try + $[$alltry-$try]
              !else
                ($try + $[$alltry-$try]) | $get_exotrymax
              !endif
              <div class="wims_tooltiptext left" style="$tmp_width">
                !read adm/class/seedscore.phtml [$tmp],$get_seedrepeat
              </div>
            </div>
            !reset tmp get_seedrepeat tmp_width
          </td>
        !endif try
      </tr>
    !endif
  !next j
  </tbody>
  $table_end
  !read tablesort.phtml
  :next
!next i

!read wimshome/public_html/themes/_widgets/topback.phtml

!if $exologs!=$empty
  !set wims_menu_items=!append line itemsep,0,\
 reg_ex,1,module=adm/class/exolog&cmd=new&job=list&checkuser=$getuser\
 to $wims_menu_items
!endif
!set wims_menu_items=!append line rawdata,1,cmd=reply&job=getraw&getraw=$getuser\
to $wims_menu_items
!if $wims_user=supervisor or ($class_examshow!=no and $eactivecnt>0)
  !set wims_name_title_examdetail=$name_exam_expl
  !set wims_menu_items=!append line examdetail,1,cmd=reply&job=examcheck&checkuser=$getuser\
to $wims_menu_items
!endif

!if $wims_user=supervisor
  !set wims_menu_items=!append line \
account,1,module=adm/class/usermanage&job=userprop&getuser=$getuser\
to $wims_menu_items
  !if (($wims_supertype<3 and $wims_typename=class) or ($wims_supertype=4 and $wims_typename=course)) and $wims_showlivret!=no
    !set wims_menu_items=!append line livret1,1,module=adm/class/livret&job=user&user=$getuser\
to $wims_menu_items
    !set wims_menu_items=!append line activity1,1,module=adm/class/activity&job=exobyday&user=$getuser\
to $wims_menu_items
  !endif
  !set wims_menu_items=!append line itemsep,0, \
part_list,1,cmd=resume\
to $wims_menu_items
  !read adm/class/getnextuser $wims_class,$getuser,getuser,getuser
!else
  !if $wims_showlivret!=no
    !set livret_nbcomp=!recordcnt wimshome/log/classes/$wims_class/livret/.comps
    !if $livret_nbcomp >0
      !set wims_menu_items=!append line livret,1,module=adm/class/livret to $wims_menu_items
    !endif
  !endif
!endif
<br class="spacer">

!reset tmp tmp_w tmp_s tmp_ss
