Subversion Repositories wimsdev

Rev

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