Subversion Repositories wimsdev

Rev

Rev 20 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 reyssat 1
!! Example of method definition file.
2
 
3
!! Title of the method, to be shown in the method menu. So must be short!
4
!set methtit=Multiply an inequality by a number
5
 
6
!! Title2 can be a bit longer than methtit, intended for exercise authors.
7
!! It defaults to methtit.
8
!set methtit2=Multiply an inequality by a non-zero number
9
 
10
!! Allowed environments.
11
!set methenv=ZZ QQ RR
12
 
13
!! Types of each parameter. Details in the source code of mathexp.
14
!set methparmtype=number,parm inequality
15
 
16
!! Help message. It is one definition, so all the lines must be escaped.
17
!set methhelp=This method transforms an inequality like \(A > B) to\
18
 the equivalent inequality \(A*n > B*n), where \(n) is a number\
19
 that must be non-zero in order to guarantee the equivalence between the\
20
 original inequality and the transformed one.
21
 
22
!if $wims_read_parm iswordof form check
17066 bpr 23
  !goto $wims_read_parm
20 reyssat 24
!endif
25
 
26
!! You can add more preliminary processing code here.
27
 
28
 
29
!exit
30
 
31
!! The content of the input form.
32
:form
33
 Multiply the inequality
34
 !read deduc/methparm.phtml 2
35
 by the number
36
 !read deduc/methparm.phtml 1,10
37
 
38
!exit
39
 
17066 bpr 40
!! Main method processing code. Many parameter verifications are
20 reyssat 41
!! already done automatically.
42
:check
43
 !distribute items $methparmobj2 into data,left,sign,right
44
 !if $methparm1=0
17066 bpr 45
    error=Multiply an inequality by 0 makes you lose information, and is therefore\
46
    prohibited.
47
    !advance penalty
48
    !exit
20 reyssat 49
 !endif
50
 
51
!! methexp is the explanation of the method in the history list.
52
 methexp=Multiply \($left $sign $right) by \($methparm1)
53
 
54
!! call a standard script in deduc/sub.
17066 bpr 55
!read deduc/sub/simplify ($left) * ($methparm1)\
20 reyssat 56
	($right) * ($methparm1)
17066 bpr 57
!distribute lines $out into newleft,newright
58
!if $newleft=$empty or $newright=$empty
20 reyssat 59
  error=bad_data
60
  !exit
17066 bpr 61
!endif
62
!if $methparm1<0
20 reyssat 63
  newsign=!translate internal <> to >< in $sign
17066 bpr 64
!else
20 reyssat 65
  newsign=$sign
17066 bpr 66
!endif
20 reyssat 67
 
68
!! oldobject=2 means that the new object can replace the second parameter
69
!! object, whenever possible.
70
 newobject2=$newleft $newsign $newright
71
 oldobject=2
72
 
73
!! These lines are used to ask the user for the good context.
74
!! Optional.
75
!! The first line must be the good choice.
76
 contextlist=$ct_Onlywhen the multiplier is non-zero,\
77
	$ct_Onlywhen the multiplier is positive,\
78
	$ct_Onlywhen the two sides are positive,\
79
	$ct_Onlywhen the two sides are of the same sign,\
80
	$ct_Onlywhen the inequality is strict
17066 bpr 81
 
20 reyssat 82
 badsign=!translate internal <> to >< in $newsign
83
 
84
!! These lines are used to ask the user for the good result.
85
!! Optional.
86
!! The first line must be the good choice.
87
 resultlist=$newobject2,\
88
	$newright $newsign $newleft,\
89
	$newleft $badsign $newright
90
!exit