Subversion Repositories wimsdev

Rev

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