Subversion Repositories wimsdev

Rev

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