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