Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
16307 guerimand 1
!! add exercise in a freework type=3 ; zonetype=wimsexo
16087 guerimand 2
 
3
max_exos=!defof MAX_EXOS in wimshome/public_html/bases/sys/define.conf
4
desc_limit=255
5
 
16467 guerimand 6
tmptest=print=yes
7
!if $tmptest isin $iniparm
8
  error=printversion
9
  notallowed=1
10
  !exit
11
!endif
12
 
16087 guerimand 13
!! ----------- delete intro_sol>0 in iniparm
14
!if intro_expert isin $iniparm or intro_sol isin $iniparm 
15
    t=$ 
16
    tmp=!replace internal & by $t in $iniparm
17
    !if intro_sol isin $iniparm
18
      tmp2=!getopt intro_sol in $tmp
19
      !if $tmp2!=0
20
        ctmp=intro_sol=$tmp2
21
        iniparm=!replace internal $ctmp by intro_sol=0 in $iniparm
22
      !endif
23
    !else
24
      iniparm=$iniparm&intro_sol=0
25
    !endif 
26
    !if intro_expert isin $iniparm
27
      tmp2=!getopt intro_expert in $tmp
28
      !if $tmp2!=yes
29
        ctmp=intro_expert=$tmp2
30
        iniparm=!replace internal $ctmp by intro_expert=yes in $iniparm
31
      !endif
32
    !else
33
      iniparm=$iniparm&intro_expert=yes
34
    !endif
35
!else
36
     iniparm=$iniparm&intro_expert=yes&intro_sol=0
37
!endif 
38
!! --------- end
39
 
40
!if $cmd=new or $cmd=resume
16307 guerimand 41
  freeworkslist=$empty
16087 guerimand 42
  !for i=1 to $nbfreework
43
    sh=!record $i of wimshome/log/classes/$wims_class/freeworks/.freeworks
44
    !distribute lines $sh into stat,t_,title,t_,t_,type
16307 guerimand 45
    !if $stat<1 and $type=3
46
      nb_=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$i
47
      j=1
48
      test=0
49
      !while $j<=$nb_ and $test=0
50
        dt=!record $j of wimshome/log/classes/$wims_class/freeworks/.freework$i
51
        dt=!word 1 of $dt
52
        !if wimsexo isin $dt
53
          test=1
54
        !endif
55
        !increase j
56
      !endwhile
57
      !if $test=1
58
        freeworkslist=!append line $i,$title to $freeworkslist
59
      !endif
16087 guerimand 60
    !endif
61
  !next i
16307 guerimand 62
  !if $freeworkslist=$empty
63
    freeworkscnt=0
64
  !else
65
    freeworkscnt=!linecnt $freeworkslist
66
  !endif
16087 guerimand 67
  !ifval $freeworkscnt=0
68
    error=addexo-nofreework
69
    notallowed=1
70
    !exit
71
  !endif
72
  test_transl=!module translation_language $dir
73
  !if $lang iswordof $test_transl
74
    tr_lang=yes
75
    title=!module title_$lang $dir
76
    desc=!module description_$lang $dir
77
  !endif
78
  !read getparm $iniparm exo exotrymax
79
 
80
  desc=!lookup $get_exo in wimshome/public_html/modules/$dir/Descindex
81
  obs=!lookup $get_exo in wimshome/public_html/modules/$dir/Obsindex
82
  !default title=!module title $dir
83
  !default desc=!module description $dir
84
  cat=!module category $dir
85
  !if exercise notin $cat and oef notin $cat
86
    error=not_exo
87
    !exit
88
  !endif
89
  !exit
90
!endif
91
 
92
!if $cmd=reply
93
  !if ../adm/ isin ../$dir or $dir=home or \
94
   (../devel/ isin ../$dir and $wims_devel_modules notwordof open)
95
    error=insert_fail
96
    !exit
97
  !endif
98
  !if $pickfreework=$empty
99
    error=no_pick
100
    !exit
101
  !endif
102
  pickfreework=$[floor($pickfreework)]
103
  !if $pickfreework=NaN or $pickfreework<1 or $picksfreework>min($max_freeworks,$nbfreeworks)
104
    error=bad_freework
105
    !exit
106
  !endif
107
  sh=!record $pickfreework of wimshome/log/classes/$wims_class/freeworks/.freeworks
108
  a=!line 1 of $sh
109
  t=!line 6 of $sh
16307 guerimand 110
  !if $a>0 or $t!=3
111
    nb_=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$pickfreework
112
    j=1
113
    test=0
114
    !while $j<=$nb_ and $test=0
115
        dt=!record $j of wimshome/log/classes/$wims_class/freeworks/.freework$pickfreework
116
        dt=!word 1 of $dt
117
        !if wimsexo isin $dt
118
          test=1
119
        !endif
120
        !increase j
121
    !endwhile
122
    !if $test=0
123
      error=bad_freework
124
      !exit
125
    !endif
16087 guerimand 126
  !endif
16307 guerimand 127
  exocnt=!recordcnt wimshome/log/classes/$wims_class/freeworks/.Wfreework$pickfreework
16087 guerimand 128
  !if $exocnt>=$max_exos
129
    error=too_many_exos
130
    !exit
131
  !endif
132
  idesc=!singlespace $new_desc
133
  iattribut=$mod_attribut
134
  idesc=!char 1 to $desc_limit of $idesc
135
  iobs=!singlespace $obs
136
  iobs=!char 1 to $desc_limit of $iobs
137
  ititle=!singlespace $title
138
  ititle=!char 1 to $title_limit of $ititle
139
  !for i=1 to $exocnt
16307 guerimand 140
    e=!record $i of wimshome/log/classes/$wims_class/freeworks/.Wfreework$pickfreework
16087 guerimand 141
    !distribute lines $e into wdi,win
142
    !if $dir=$wdi and $iniparm=$win
143
      test=$pickfreework
144
      error=already_exist
145
      !exit
146
    !endif
147
  !next i
16307 guerimand 148
  !appendfile wimshome/log/classes/$wims_class/freeworks/.Wfreework$pickfreework :$dir\
16087 guerimand 149
$iniparm\
150
$ititle\
151
$idesc
152
  success=exo-insert
16307 guerimand 153
  exocnt=!recordcnt wimshome/log/classes/$wims_class/freeworks/.Wfreework$pickfreework
16087 guerimand 154
  wims_module_log=class $class: add No$exocnt to freework $pickfreework
155
!endif