Subversion Repositories wimsdev

Rev

Rev 12236 | 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
76
  idesc=!char 1 to $desc_limit of $idesc
77
  iobs=!singlespace $obs
78
  iobs=!char 1 to $desc_limit of $iobs
79
  ititle=!singlespace $title
80
  ititle=!char 1 to $title_limit of $ititle
81
  !if $scoring=yes
82
    require=$[$require]
83
    weight=$[$weight]
84
    !if NaN isin $require
85
      require=0
86
    !endif
87
    !if NaN isin $weight
88
      weight=0
89
    !endif
90
    !bound require between 0,$[10*$require_limit] default 0
91
    !bound weight between 0,10 default 0
92
  !endif
93
  !for i=1 to $exocnt
94
    e=!record $i of wimshome/log/classes/$wims_class/sheets/.sheet$picksheet
95
    !distribute lines $e into wdi,win
96
    !if $dir=$wdi and $iniparm=$win
97
      test=$picksheet
98
      error=already_exist
99
      !exit
100
    !endif
101
  !next i
7354 bpr 102
####
12238 bpr 103
  iniparm2=!replace internal & by $\
104
$ in $iniparm
105
  !if exotrymax notin $iniparm2 and $newexotrymax>0
106
    iniparm2=exotrymax=$newexotrymax\
107
$iniparm2
108
  !endif
109
  iniparm2_cnt=!linecnt $iniparm2
110
  iniparm2=!replace internal & by $\
111
$ in $iniparm2
7354 bpr 112
  !if $get_random=0
12236 bpr 113
    !for i=1 to $get_qnum
114
      update_order=!append item $(update_ex$i) to $update_order
115
    !next
12238 bpr 116
    get_exo=$(get_exo[$update_order])
117
  !endif
7354 bpr 118
 
12238 bpr 119
  iniparm2_cnt=!linecnt $iniparm2
120
  new_iniparm=
121
  equal==
122
  !for v in $get_exo
123
    new_iniparm=!append item exo=$v to $new_iniparm
124
  !next
125
  !for u=1 to $iniparm2_cnt
126
    l=!line $u of $iniparm2
127
    !if exotrymax isin $l
128
      new_iniparm=!append item exotrymax=$newexotrymax to $new_iniparm
129
    !else
130
      !if exo$equal notin $l =
12236 bpr 131
        new_iniparm=!append item $l to $new_iniparm
132
      !endif
12238 bpr 133
    !endif
134
  !next
135
  new_iniparm=!nospace $new_iniparm
136
  !if $equal notin $(new_iniparm[-1])
137
    new_iniparm=$new_iniparm=
12236 bpr 138
  !endif
12238 bpr 139
  new_iniparm=!replace internal , by & in $new_iniparm
140
  iniparm=$new_iniparm
7354 bpr 141
#####
12236 bpr 142
  !appendfile wimshome/log/classes/$wims_class/sheets/.sheet$picksheet :$dir\
5199 guerimand 143
$iniparm\
144
$require\
145
$weight\
146
$ititle\
9436 bpr 147
$idesc\
148
\
149
$iobs
5199 guerimand 150
 
12236 bpr 151
  exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$picksheet
152
  wims_module_log=class $class: add No$exocnt to worksheet $picksheet
5199 guerimand 153
!endif