Field functions in math expressions

Discuss the formula editor
Post Reply
walter55
Posts: 5
Joined: Tue Oct 20, 2009 10:17 am

Field functions in math expressions

Post by walter55 »

Hi all,
I am a math teacher and would like to personalize math tests to prevent excessive copying ;) . So I tried to use serial letter functionality and it works fine as long as no math formula is involved.
Is there a way to use field variables within formulas?

Thanks for help,

Walter.
OpenOffice 3.0.1 on Ubuntu 9.04 / OpenOffice 3.2.1 on Windows Vista
Heading to move my IT-lessons to oO and js-macros replacing MS-Office and VBA, + using oO as my preferred office suite.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Field functions in math expressions

Post by acknak »

Sorry, no. The fields only work in Writer text. In fact, because OOo implements formulas as separate embedded objects, there is no communication between the formulas and the parent document at all. Even settings like fonts or text size do not carry over.

Can you explain exactly what you want to do? Maybe there's some other approach.

You mean that one test paper might have
   y = x + 2; solve for y when x is 3
where another paper has
   m = n + 2; solve for m when n is 3
?
AOO4/LO5 • Linux • Fedora 23
walter55
Posts: 5
Joined: Tue Oct 20, 2009 10:17 am

Re: Field functions in math expressions

Post by walter55 »

Sad that no. We are doing some more advanced math, so something like

Code: Select all

 int from -5 to 10 {{x^b} over {1-x^a} dx} =
with some changes to the polynom in the denominator and to some constants are my target.

Of course there is a way to write equations in single lines, but this is not the professional approach the students would expect.
(copying others isn't professional either, but we all know it is happening.)

Walter
OpenOffice 3.0.1 on Ubuntu 9.04 / OpenOffice 3.2.1 on Windows Vista
Heading to move my IT-lessons to oO and js-macros replacing MS-Office and VBA, + using oO as my preferred office suite.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Field functions in math expressions

Post by acknak »

I think you will just need to make up different test papers. I can't think of any way to automate variations in formulas.

I suppose you could use a master/sub-document to make it a bit easier to create the variations. Each problem could be a sub-document, and you could easily make a master that included different variations and/or in a different order.
AOO4/LO5 • Linux • Fedora 23
User avatar
RGB
Posts: 1456
Joined: Mon Oct 08, 2007 1:34 am

Re: Field functions in math expressions

Post by RGB »

Well, there is a possibility:
1- On Tools -> Customize -> Keyboard tab set a shortcut to insert a Math object
2- Define a text variable with value like x^2 + 1 on Insert -> Fields -> Others -> Variable tab
3- Select the variable and press the shortcut you set on 1...

Of course, you will need to change the variable value before you convert it into a Math object.
There are two types of people: those who believe that there are two types of people and those who do not.

openSUSE Leap with KDE Plasma / LibreOffice
walter55
Posts: 5
Joined: Tue Oct 20, 2009 10:17 am

Re: Field functions in math expressions

Post by walter55 »

Thank you for your tipps.
I think I will look into including text blocks rather than single values. This is not what I was heading for, but it is a step into the right direction. I really would prefer having the variables in calc to allow also the creation of the solutions paper as serial letter using the same set of variables..... Regards Walter.
OpenOffice 3.0.1 on Ubuntu 9.04 / OpenOffice 3.2.1 on Windows Vista
Heading to move my IT-lessons to oO and js-macros replacing MS-Office and VBA, + using oO as my preferred office suite.
User avatar
Zizi64
Volunteer
Posts: 11495
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Field functions in math expressions

Post by Zizi64 »

I try to show another way, with Basic macro:
Math_basic.odt
(11.49 KiB) Downloaded 453 times
The example file contains Basic macro. You need to enable the macro running option.

The example macro based on Andrew Pitonyak's macro examples.
http://www.pitonyak.org/oo.php
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11495
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Field functions in math expressions

Post by Zizi64 »

There is an another code snippet, to modify equation named "object1".

Code: Select all

Sub my_ModifyEquation

	dim oDoc as object
	dim My_math as object
	dim My_formula, a_str, b_str as string
	
	odoc = Thiscomponent
	'define the range of constants (a and b) and convert them to string format
	a_str = CStr(Int((5 * Rnd)+2))
	b_str = CStr(Int((5 * Rnd)+2))
	
	'set the formula string:
	My_formula = "int from -5 to 10 {{x^" & b_str & "} over {1-x^" & a_str & "} dx} ={}"

	My_Math = oDoc.EmbeddedObjects.GetByName("Object1")
	My_Math.model.formula = My_formula

end sub
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
walter55
Posts: 5
Joined: Tue Oct 20, 2009 10:17 am

Re: Field functions in math expressions

Post by walter55 »

Thank you very much for providing the basic macros.

I now do understand how to create / modify a math expression inside a document.
This is very helpful, as it shows a way to create the content of a math expression from a macro. (creation seems to be a little complicated, but the modification example looks pretty and straight forward.)

I did not fully try to implement it, and am already stuck again:
--> Is there a way to get a macro executed right after every new dataset is loaded into the seriel letter fields and before the print is created? (I would like to still use the serial letter mechanics, as there are also standard text fields changed.)
--> How do I get the content of the field variables rather than the "definition" when I try to read the content?

regards,

Walter.
OpenOffice 3.0.1 on Ubuntu 9.04 / OpenOffice 3.2.1 on Windows Vista
Heading to move my IT-lessons to oO and js-macros replacing MS-Office and VBA, + using oO as my preferred office suite.
Post Reply