Subversion Repositories wimsdev

Rev

Rev 17097 | Rev 17145 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
17070 guerimand 1
!! -------- check user
2
user=$wims_user
3
test=!fileexists wimshome/log/classes/$wims_class/swork
4
!sh mkdir -p $wims_home/log/classes/$wims_class/swork
5
clsfile=wimshome/log/classes/$wims_class/swork/averagescore
6
Clsfile=$wims_home/log/classes/$wims_class/swork/averagescore
7
ufile=wimshome/log/classes/$wims_class/swork/averagescore.$user
8
Ufile=$wims_home/log/classes/$wims_class/swork/averagescore.$user
9
time1=!record 0 of $ufile
17097 guerimand 10
time1=!line 1 of $time1
17070 guerimand 11
!distribute word $time1 into time1,majdate,bl
12
!default time1=0
17097 guerimand 13
!if $[$wims_nowseconds-$time1]<3600*$swork_refreshtiming or ($swork_allowrefresh=1 and $refresh!=1)
17070 guerimand 14
  !exit
15
!endif
16
time2=!record 0 of $clsfile
17
time2=!word 1 of $time2
18
!default time2=0
19
!if $[$wims_nowseconds-$time2]<3600
20
  userlist=$user
21
!else
22
  !reset userlist
23
  !for k=1 to $nbuser
24
    d=!record $k of wimshome/log/classes/$wims_class/.userlist
25
    userlist=!append item $(d[3]) to $userlist
26
  !next k
27
  !writefile $clsfile $wims_nowseconds $wims_now
28
  time2=yes
29
!endif
30
!writefile $ufile $wims_nowseconds $wims_now 100000
31
majdate=$wims_now
32
nbuser=!recordcnt wimshome/log/classes/$wims_class/.userlist
33
!for sh=1 to $nbsheet
17097 guerimand 34
  dtsh=!record $sh of wimshome/log/classes/$wims_class/sheets/.sheets
17070 guerimand 35
  stat=!line 1 of $dtsh
36
  !if $stat!=0
37
    nbexo=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sh
38
    average=!values 0 for v=1 to $nbexo
39
    max=$average
17097 guerimand 40
    lsev=!line $[$sh+1] of $severity
17070 guerimand 41
    !distribute word $lsev into swei,rule,indic
17097 guerimand 42
    formula=!item $rule of $formulas
17070 guerimand 43
    wei=!getscoreweight user=$user sheet=$sh
44
    wei=!words2items $wei
45
    totwei=!replace internal , by + in $wei
46
    totwei=$[$totwei]
47
    !reset useraverage
48
    !for dtu in $userlist
17097 guerimand 49
      lq=!getscoremean user=$dtu sheet=$sh
17070 guerimand 50
      !if $indic=0
51
        li=!getscore user=$dtu sheet=$sh
52
      !else
53
        !if $indic=1
17097 guerimand 54
          li=!getscorebest user=$dtu sheet=$sh
17070 guerimand 55
        !else
56
          li=!getscorelevel user=$dtu sheet=$sh
57
        !endif
58
      !endif
59
      !!calcul du score pour chaque exo
60
      !reset lave lmax
61
      !for k=1 to $nbexo
62
        ewei=!word $k of $wei
63
        elq=!word $k of $lq
64
        eli=!word $k of $li
17097 guerimand 65
        ave=!replace internal I by $[$eli/10] in $formula
66
        ave=!replace internal Q by $[$elq/10] in $ave
67
        ave=$[rint($ave*1000)]
17070 guerimand 68
        !if $dtu=$user
69
          useraverage=!append item $ave to $useraverage
70
        !endif
71
        lmax=!append item $[max($ave,$(max[$k]))] to $lmax
72
        ave=$[$(ave)+$(average[$k])]
73
        lave=!append item $ave to $lave
74
      !next k
75
      average=$lave
76
      max=$lmax
77
    !next dtu
78
    !reset tmp tmp2
79
    !if $time2!=yes
80
      tmp=!record $sh of $clsfile
81
    !endif
82
    !for k=1 to $nbexo
83
      !if $time2=yes
17097 guerimand 84
        ave=$[rint($(average[$k])/$nbuser)]
85
        m=$[rint($(max[$k]))]
17070 guerimand 86
        tmp=!append line $sh $k $ave $m to $tmp
87
      !else
88
        ave=!line $k of $tmp
89
        m=!word 4 of $ave
90
        ave=!word 3 of $ave
91
      !endif
92
      !if $(wei[$k])!=0 and $swei!=0
17097 guerimand 93
        val=$[rint($ave - $(useraverage[$k]))]
94
        val=$[rint($val * $swei * $(wei[$k])/$totwei )]   
95
        !if $val<=0
17070 guerimand 96
          val=-1000
97
        !endif
98
      !else
99
        !if $swei!=0
100
          val=$[-10000*$swei]
101
        !else
102
          val=-10000
103
        !endif
104
      !endif
17097 guerimand 105
      m2=$[rint($m-$(useraverage[$k]))]
106
      !appendfile $ufile :$sh $k $val $m2 $ave $m
17070 guerimand 107
    !next k
108
    !if $time2=yes
109
      !appendfile $clsfile :$tmp
110
    !endif
111
  !else
112
    !if $time2=yes
113
      !appendfile $clsfile : 
114
    !endif
115
  !endif
116
!next sh
117
 
118
!sh sort -n -r -k 3 -k 4 $Ufile > $wims_home/sessions/$wimss_session/tmp.swork;\
119
    mv -f $wims_home/sessions/$wimss_session/tmp.swork $Ufile
120