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