Rev 13760 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5199 | guerimand | 1 | !! add exercise in a sheet |
2 | |||
8255 | bpr | 3 | max_exos=!defof MAX_EXOS in wimshome/public_html/bases/sys/define.conf |
4 | max_sheets=!defof MAX_SHEETS in wimshome/public_html/bases/sys/define.conf |
||
5199 | guerimand | 5 | title_limit=50 |
6 | desc_limit=255 |
||
7 | !if $scoring=yes |
||
12236 | bpr | 8 | !default require=10 |
9 | !default weight=1 |
||
5199 | guerimand | 10 | !else |
12236 | bpr | 11 | require=0 |
12 | weight=0 |
||
5199 | guerimand | 13 | !endif |
14 | |||
15 | !if $cmd=new or $cmd=resume |
||
12236 | bpr | 16 | sheets= |
17 | !for i=1 to $sheettot |
||
18 | sh=!record $i of wimshome/log/classes/$wims_class/sheets/.sheets |
||
19 | !distribute lines $sh into a_,t_,title |
||
20 | !if $a_<1 |
||
21 | sheets=!append line $i,$title to $sheets |
||
22 | !endif |
||
23 | !next i |
||
24 | sheetcnt=!linecnt $sheets |
||
25 | !ifval $sheetcnt=0 |
||
26 | error=no_sheet |
||
27 | !exit |
||
5199 | guerimand | 28 | !endif |
12236 | bpr | 29 | test_transl=!module translation_language $dir |
30 | !if $lang iswordof $test_transl |
||
31 | tr_lang=yes |
||
32 | title=!module title_$lang $dir |
||
33 | desc=!module description_$lang $dir |
||
34 | !endif |
||
16466 | guerimand | 35 | !! ------ print oef version cannot be inserted in a sheet |
36 | tmptest=print=yes |
||
37 | !if $tmptest isin $iniparm |
||
38 | error=printversion |
||
39 | !exit |
||
40 | !endif |
||
12238 | bpr | 41 | !read getparm $iniparm exo exotrymax |
12236 | bpr | 42 | desc=!lookup $get_exo in wimshome/public_html/modules/$dir/Descindex |
43 | obs=!lookup $get_exo in wimshome/public_html/modules/$dir/Obsindex |
||
44 | !default title=!module title $dir |
||
45 | !default desc=!module description $dir |
||
46 | cat=!module category $dir |
||
47 | !if exercise notin $cat and oef notin $cat |
||
48 | error=not_exo |
||
49 | !exit |
||
50 | !endif |
||
5199 | guerimand | 51 | !exit |
52 | !endif |
||
53 | |||
54 | !if $cmd=reply |
||
12236 | bpr | 55 | !if ../adm/ isin ../$dir or $dir=home or \ |
5199 | guerimand | 56 | (../devel/ isin ../$dir and $wims_devel_modules notwordof open) |
12236 | bpr | 57 | error=insert_fail |
58 | !exit |
||
5199 | guerimand | 59 | !endif |
12236 | bpr | 60 | !if $picksheet=$empty |
61 | error=no_pick |
||
62 | !exit |
||
5199 | guerimand | 63 | !endif |
12236 | bpr | 64 | picksheet=$[floor($picksheet)] |
65 | !if $picksheet=NaN or $picksheet<1 or $picksheet>min($max_sheets,$sheettot) |
||
66 | error=bad_sheet |
||
67 | !exit |
||
5199 | guerimand | 68 | !endif |
12236 | bpr | 69 | sh=!record $picksheet of wimshome/log/classes/$wims_class/sheets/.sheets |
70 | a=!line 1 of $sh |
||
71 | !if $a>0 |
||
72 | error=bad_sheet |
||
73 | !exit |
||
74 | !endif |
||
75 | exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$picksheet |
||
76 | !if $exocnt>=$max_exos |
||
77 | error=too_many_exos |
||
78 | !exit |
||
79 | !endif |
||
80 | idesc=!singlespace $new_desc |
||
12316 | bpr | 81 | iattribut=$mod_attribut |
12236 | bpr | 82 | idesc=!char 1 to $desc_limit of $idesc |
83 | iobs=!singlespace $obs |
||
84 | iobs=!char 1 to $desc_limit of $iobs |
||
85 | ititle=!singlespace $title |
||
86 | ititle=!char 1 to $title_limit of $ititle |
||
87 | !if $scoring=yes |
||
88 | require=$[$require] |
||
89 | weight=$[$weight] |
||
90 | !if NaN isin $require |
||
91 | require=0 |
||
92 | !endif |
||
93 | !if NaN isin $weight |
||
94 | weight=0 |
||
95 | !endif |
||
96 | !bound require between 0,$[10*$require_limit] default 0 |
||
97 | !bound weight between 0,10 default 0 |
||
98 | !endif |
||
99 | !for i=1 to $exocnt |
||
100 | e=!record $i of wimshome/log/classes/$wims_class/sheets/.sheet$picksheet |
||
101 | !distribute lines $e into wdi,win |
||
102 | !if $dir=$wdi and $iniparm=$win |
||
103 | test=$picksheet |
||
104 | error=already_exist |
||
105 | !exit |
||
106 | !endif |
||
107 | !next i |
||
7354 | bpr | 108 | #### |
12238 | bpr | 109 | iniparm2=!replace internal & by $\ |
110 | $ in $iniparm |
||
111 | !if exotrymax notin $iniparm2 and $newexotrymax>0 |
||
112 | iniparm2=exotrymax=$newexotrymax\ |
||
113 | $iniparm2 |
||
114 | !endif |
||
115 | iniparm2_cnt=!linecnt $iniparm2 |
||
116 | iniparm2=!replace internal & by $\ |
||
117 | $ in $iniparm2 |
||
7354 | bpr | 118 | !if $get_random=0 |
12236 | bpr | 119 | !for i=1 to $get_qnum |
120 | update_order=!append item $(update_ex$i) to $update_order |
||
121 | !next |
||
12238 | bpr | 122 | get_exo=$(get_exo[$update_order]) |
123 | !endif |
||
7354 | bpr | 124 | |
12238 | bpr | 125 | iniparm2_cnt=!linecnt $iniparm2 |
126 | new_iniparm= |
||
127 | equal== |
||
128 | !for v in $get_exo |
||
13760 | bpr | 129 | new_iniparm=!append line exo=$v to $new_iniparm |
12238 | bpr | 130 | !next |
131 | !for u=1 to $iniparm2_cnt |
||
132 | l=!line $u of $iniparm2 |
||
133 | !if exotrymax isin $l |
||
13760 | bpr | 134 | new_iniparm=!append line exotrymax=$newexotrymax to $new_iniparm |
12238 | bpr | 135 | !else |
136 | !if exo$equal notin $l = |
||
13760 | bpr | 137 | new_iniparm=!append line $l to $new_iniparm |
12236 | bpr | 138 | !endif |
12238 | bpr | 139 | !endif |
140 | !next |
||
141 | !if $equal notin $(new_iniparm[-1]) |
||
142 | new_iniparm=$new_iniparm= |
||
12236 | bpr | 143 | !endif |
13760 | bpr | 144 | new_iniparm=!replace internal $\ |
145 | $ by & in $new_iniparm |
||
146 | new_iniparm=!nospace $new_iniparm |
||
12238 | bpr | 147 | iniparm=$new_iniparm |
13760 | bpr | 148 | ##### |
12236 | bpr | 149 | !appendfile wimshome/log/classes/$wims_class/sheets/.sheet$picksheet :$dir\ |
5199 | guerimand | 150 | $iniparm\ |
151 | $require\ |
||
152 | $weight\ |
||
153 | $ititle\ |
||
9436 | bpr | 154 | $idesc\ |
155 | \ |
||
12316 | bpr | 156 | $iobs\ |
157 | \ |
||
158 | $iattribut |
||
5199 | guerimand | 159 | |
12236 | bpr | 160 | exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$picksheet |
161 | wims_module_log=class $class: add No$exocnt to worksheet $picksheet |
||
5199 | guerimand | 162 | !endif |