Rev 8817 | Rev 12236 | Go to most recent revision | 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 |
||
8 | !default require=10 |
||
9 | !default weight=1 |
||
10 | !else |
||
11 | require=0 |
||
12 | weight=0 |
||
13 | !endif |
||
14 | |||
15 | !if $cmd=new or $cmd=resume |
||
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 |
||
28 | !endif |
||
6431 | 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 |
||
9436 | bpr | 35 | !read getparm $iniparm exo |
36 | desc=!lookup $get_exo in wimshome/public_html/modules/$dir/Descindex |
||
37 | obs=!lookup $get_exo in wimshome/public_html/modules/$dir/Obsindex |
||
6431 | bpr | 38 | !default title=!module title $dir |
39 | !default desc=!module description $dir |
||
5210 | guerimand | 40 | cat=!module category $dir |
41 | !if exercise notin $cat and oef notin $cat |
||
42 | error=not_exo |
||
43 | !exit |
||
44 | !endif |
||
5199 | guerimand | 45 | !exit |
46 | !endif |
||
47 | |||
48 | !if $cmd=reply |
||
49 | !if ../adm/ isin ../$dir or $dir=home or \ |
||
50 | (../devel/ isin ../$dir and $wims_devel_modules notwordof open) |
||
51 | error=insert_fail |
||
52 | !exit |
||
53 | !endif |
||
54 | !if $picksheet=$empty |
||
55 | error=no_pick |
||
56 | !exit |
||
57 | !endif |
||
58 | picksheet=$[floor($picksheet)] |
||
8255 | bpr | 59 | !if $picksheet=NaN or $picksheet<1 or $picksheet>min($max_sheets,$sheettot) |
5199 | guerimand | 60 | error=bad_sheet |
61 | !exit |
||
62 | !endif |
||
63 | sh=!record $picksheet of wimshome/log/classes/$wims_class/sheets/.sheets |
||
64 | a=!line 1 of $sh |
||
65 | !if $a>0 |
||
66 | error=bad_sheet |
||
67 | !exit |
||
68 | !endif |
||
69 | exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$picksheet |
||
8255 | bpr | 70 | !if $exocnt>=$max_exos |
5199 | guerimand | 71 | error=too_many_exos |
72 | !exit |
||
73 | !endif |
||
74 | idesc=!singlespace $new_desc |
||
75 | idesc=!char 1 to $desc_limit of $idesc |
||
9436 | bpr | 76 | iobs=!singlespace $obs |
77 | iobs=!char 1 to $desc_limit of $iobs |
||
5199 | guerimand | 78 | ititle=!singlespace $title |
79 | ititle=!char 1 to $title_limit of $ititle |
||
80 | !if $scoring=yes |
||
81 | require=$[$require] |
||
82 | weight=$[$weight] |
||
83 | !if NaN isin $require |
||
84 | require=0 |
||
85 | !endif |
||
86 | !if NaN isin $weight |
||
87 | weight=0 |
||
88 | !endif |
||
8255 | bpr | 89 | !bound require between 0,$[10*$require_limit] default 0 |
5199 | guerimand | 90 | !bound weight between 0,10 default 0 |
91 | !endif |
||
92 | !for i=1 to $exocnt |
||
93 | e=!record $i of wimshome/log/classes/$wims_class/sheets/.sheet$picksheet |
||
94 | !distribute lines $e into wdi,win |
||
95 | !if $dir=$wdi and $iniparm=$win |
||
96 | test=$picksheet |
||
97 | error=already_exist |
||
98 | !exit |
||
99 | !endif |
||
100 | !next i |
||
7354 | bpr | 101 | #### |
102 | !if $get_random=0 |
||
103 | !for i=1 to $get_qnum |
||
104 | update_order=!append item $(update_ex$i) to $update_order |
||
105 | !next |
||
106 | |||
107 | get_exo=$(get_exo[$update_order]) |
||
108 | iniparm2=!replace internal & by $\ |
||
109 | $ in $iniparm |
||
110 | iniparm2_cnt=!linecnt $iniparm2 |
||
111 | new_iniparm= |
||
112 | equal== |
||
113 | !for v in $get_exo |
||
114 | new_iniparm=!append item exo=$v to $new_iniparm |
||
115 | !next |
||
116 | !for u=1 to $iniparm2_cnt |
||
117 | l=!line $u of $iniparm2 |
||
118 | !if exo$equal notin $l |
||
119 | new_iniparm=!append item $l to $new_iniparm |
||
120 | !endif |
||
121 | !next |
||
122 | new_iniparm=!nospace $new_iniparm |
||
123 | new_iniparm=!replace internal , by & in $new_iniparm= |
||
124 | iniparm=$new_iniparm |
||
125 | !endif |
||
126 | ##### |
||
5199 | guerimand | 127 | !appendfile wimshome/log/classes/$wims_class/sheets/.sheet$picksheet :$dir\ |
128 | $iniparm\ |
||
129 | $require\ |
||
130 | $weight\ |
||
131 | $ititle\ |
||
9436 | bpr | 132 | $idesc\ |
133 | \ |
||
134 | $iobs |
||
5199 | guerimand | 135 | |
136 | exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$picksheet |
||
137 | wims_module_log=class $class: add No$exocnt to worksheet $picksheet |
||
138 | !endif |