Rev 20 | Blame | Compare with Previous | Last modification | View Log | RSS feed
!! Example of method definition file.
!! Title of the method, to be shown in the method menu. So must be short!
!set methtit=Multiply an inequality by a number
!! Title2 can be a bit longer than methtit, intended for exercise authors.
!! It defaults to methtit.
!set methtit2=Multiply an inequality by a non-zero number
!! Allowed environments.
!set methenv=ZZ QQ RR
!! Types of each parameter. Details in the source code of mathexp.
!set methparmtype=number,parm inequality
!! Help message. It is one definition, so all the lines must be escaped.
!set methhelp=This method transforms an inequality like \(A > B) to\
the equivalent inequality \(A*n > B*n), where \(n) is a number\
that must be non-zero in order to guarantee the equivalence between the\
original inequality and the transformed one.
!if $wims_read_parm iswordof form check
!goto $wims_read_parm
!endif
!! You can add more preliminary processing code here.
!exit
!! The content of the input form.
:form
Multiply the inequality
!read deduc/methparm.phtml 2
by the number
!read deduc/methparm.phtml 1,10
!exit
!! Main method processing code. Many parameter verifications are
!! already done automatically.
:check
!distribute items $methparmobj2 into data,left,sign,right
!if $methparm1=0
error=Multiply an inequality by 0 makes you lose information, and is therefore\
prohibited.
!advance penalty
!exit
!endif
!! methexp is the explanation of the method in the history list.
methexp=Multiply \($left $sign $right) by \($methparm1)
!! call a standard script in deduc/sub.
!read deduc/sub/simplify ($left) * ($methparm1)\
($right) * ($methparm1)
!distribute lines $out into newleft,newright
!if $newleft=$empty or $newright=$empty
error=bad_data
!exit
!endif
!if $methparm1<0
newsign=!translate internal <> to >< in $sign
!else
newsign=$sign
!endif
!! oldobject=2 means that the new object can replace the second parameter
!! object, whenever possible.
newobject2=$newleft $newsign $newright
oldobject=2
!! These lines are used to ask the user for the good context.
!! Optional.
!! The first line must be the good choice.
contextlist=$ct_Onlywhen the multiplier is non-zero,\
$ct_Onlywhen the multiplier is positive,\
$ct_Onlywhen the two sides are positive,\
$ct_Onlywhen the two sides are of the same sign,\
$ct_Onlywhen the inequality is strict
badsign=!translate internal <> to >< in $newsign
!! These lines are used to ask the user for the good result.
!! Optional.
!! The first line must be the good choice.
resultlist=$newobject2,\
$newright $newsign $newleft,\
$newleft $badsign $newright
!exit