Subversion Repositories wimsdev

Rev

Rev 10939 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4561 obado 1
# PutExo
2
# Ajoute du contenu (un exercice existant) a la feuille $qsheet de la classe $qclass
3
 
4
#Pour commencer, on verifie la classe
5
!read scripts/check.class
6
!if $error!=$empty
10939 obado 7
  !exit
4561 obado 8
!endif
9
 
3261 obado 10
type=sheets
11
!read scripts/check.proc
12
!if $error!=$empty
10939 obado 13
  !exit
3261 obado 14
!endif
15
 
16
#On verifie que la feuille n'est pas "Active"
17
sheet_status=!line 1 of $qproperties
18
!ifval $sheet_status >0
10939 obado 19
  error=sheet mustn't be active
20
  !exit
3261 obado 21
!endif
22
 
13228 obado 23
exocnt=!recordcnt wimshome/log/classes/$qclass/sheets/.sheet$sheet_id
9963 obado 24
!if $exocnt >= $MAX_EXOS
10939 obado 25
  error=Sorry, a sheet is limited to $MAX_EXOS exercises.
26
  !exit
6628 obado 27
!endif
28
 
3261 obado 29
!if $data1=$empty
10939 obado 30
  error=no data found
31
  !exit
3261 obado 32
!endif
33
 
34
data1=!nonempty lines $data1
35
n1=!linecnt $data1
36
!for i=1 to $n1
10939 obado 37
  v_=$empty
38
  l=!line $i of $data1
39
  #On remplace temporairement les eventuelles virgules pour ne pas interferer avec la suite
40
  l2=!translate , to XTEMPX in $l
41
  l2=!translate = to $,$ in $l2
42
  n_=!item 1 of $l2
43
  v_=!item 2 of $l2
44
  nb_elem=!itemcnt $l2
45
  !if $nb_elem>2
5802 obado 46
  !for j=3 to $nb_elem
3261 obado 47
    courrant=!item $j of $l2
48
    v_=$v_=$courrant
49
  !next j
10939 obado 50
  !endif
51
  # puis on remet en place les virgules
52
  v_=!translate XTEMPX to $,$ in $v_
53
  sh_$n_=$v_
3261 obado 54
!next i
55
 
56
 
4176 obado 57
!for t in sh_module, sh_params
10939 obado 58
  !if $($t) = $empty
59
    error=incomplete data $t
60
    !exit
61
  !endif
3261 obado 62
!next t
63
 
64
!default sh_weight=1
65
!default sh_points=10
4176 obado 66
!default sh_title=Nouvel exercice
67
!default sh_description=$empty
68
!default sh_dep=$empty
69
!default sh_comment=$empty
3261 obado 70
 
4176 obado 71
 
5678 obado 72
# On remplace les eventuels codes URI (%2F, etc..) par les caracteres adequats
73
!read adm/urldecode $sh_module
10939 obado 74
sh_module=$url
5678 obado 75
 
10939 obado 76
!if $sh_module=$empty
77
  error=urldecode failure ! Make sure URI::URL perl module is well installed on the server.
78
  !exit
79
!endif
80
 
3261 obado 81
!appendfile wimshome/log/classes/$qclass/sheets/.sheet$qsheet \
82
:$sh_module\
4176 obado 83
$sh_params\
3261 obado 84
$sh_points\
85
$sh_weight\
86
$sh_title\
4176 obado 87
$sh_description\
88
$sh_dep\
89
$sh_comment\
3996 obado 90
 
91
 
13228 obado 92
exocnt=!recordcnt wimshome/log/classes/$qclass/sheets/.sheet$sheet_id