Rev 16307 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
16087 | guerimand | 1 | !! add exercise in a freework |
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 |
||
34 | freeworkslist= |
||
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 |
||
38 | !if $stat<1 and $type=4 |
||
39 | freeworkslist=!append line $i,$title to $freeworkslist |
||
40 | !endif |
||
41 | !next i |
||
42 | freeworkscnt=!linecnt $freeworkslist |
||
43 | !ifval $freeworkscnt=0 |
||
44 | error=addexo-nofreework |
||
45 | notallowed=1 |
||
46 | !exit |
||
47 | !endif |
||
48 | test_transl=!module translation_language $dir |
||
49 | !if $lang iswordof $test_transl |
||
50 | tr_lang=yes |
||
51 | title=!module title_$lang $dir |
||
52 | desc=!module description_$lang $dir |
||
53 | !endif |
||
54 | !read getparm $iniparm exo exotrymax |
||
55 | |||
56 | desc=!lookup $get_exo in wimshome/public_html/modules/$dir/Descindex |
||
57 | obs=!lookup $get_exo in wimshome/public_html/modules/$dir/Obsindex |
||
58 | !default title=!module title $dir |
||
59 | !default desc=!module description $dir |
||
60 | cat=!module category $dir |
||
61 | !if exercise notin $cat and oef notin $cat |
||
62 | error=not_exo |
||
63 | !exit |
||
64 | !endif |
||
65 | !exit |
||
66 | !endif |
||
67 | |||
68 | !if $cmd=reply |
||
69 | !if ../adm/ isin ../$dir or $dir=home or \ |
||
70 | (../devel/ isin ../$dir and $wims_devel_modules notwordof open) |
||
71 | error=insert_fail |
||
72 | !exit |
||
73 | !endif |
||
74 | !if $pickfreework=$empty |
||
75 | error=no_pick |
||
76 | !exit |
||
77 | !endif |
||
78 | pickfreework=$[floor($pickfreework)] |
||
79 | !if $pickfreework=NaN or $pickfreework<1 or $picksfreework>min($max_freeworks,$nbfreeworks) |
||
80 | error=bad_freework |
||
81 | !exit |
||
82 | !endif |
||
83 | sh=!record $pickfreework of wimshome/log/classes/$wims_class/freeworks/.freeworks |
||
84 | a=!line 1 of $sh |
||
85 | t=!line 6 of $sh |
||
86 | !if $a>0 or $t!=4 |
||
87 | error=bad_freework |
||
88 | !exit |
||
89 | !endif |
||
90 | exocnt=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$pickfreework |
||
91 | !if $exocnt>=$max_exos |
||
92 | error=too_many_exos |
||
93 | !exit |
||
94 | !endif |
||
95 | idesc=!singlespace $new_desc |
||
96 | iattribut=$mod_attribut |
||
97 | idesc=!char 1 to $desc_limit of $idesc |
||
98 | iobs=!singlespace $obs |
||
99 | iobs=!char 1 to $desc_limit of $iobs |
||
100 | ititle=!singlespace $title |
||
101 | ititle=!char 1 to $title_limit of $ititle |
||
102 | !for i=1 to $exocnt |
||
103 | e=!record $i of wimshome/log/classes/$wims_class/freeworks/.freework$pickfreework |
||
104 | !distribute lines $e into wdi,win |
||
105 | !if $dir=$wdi and $iniparm=$win |
||
106 | test=$pickfreework |
||
107 | error=already_exist |
||
108 | !exit |
||
109 | !endif |
||
110 | !next i |
||
111 | !appendfile wimshome/log/classes/$wims_class/freeworks/.freework$pickfreework :$dir\ |
||
112 | $iniparm\ |
||
113 | $ititle\ |
||
114 | $idesc |
||
115 | success=exo-insert |
||
116 | exocnt=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freework$pickfreework |
||
117 | wims_module_log=class $class: add No$exocnt to freework $pickfreework |
||
118 | !endif |