# IRC log for #webwork, 2013-03-23

All times shown according to UTC.

Time Nick Message
00:49 mgage_ joined #webwork
01:27 mgage_ joined #webwork
03:30 mgage_ joined #webwork
09:21 mgage joined #webwork
12:21 mgage_ joined #webwork
15:02 Tim2 joined #webwork
15:12 Tim2 Within a PG problem I have been trying to label a dynamic image/graph (init_graph etc) with LaTeX characters as well as strings involving named scalars (like $a etc). Might anyone have a reference or example? If this is not the proper place to be asking questions such as this, please do let me know...Thanks. 15:48 Tim2 joined #webwork 16:40 mgage_ joined #webwork 17:53 mgage_ joined #webwork 18:16 mgage_ joined #webwork 18:17 pbelley joined #webwork 18:48 mgage_ pbelly: around? 18:49 Tim2 Hi...Does anyone happen to have any advice regarding my question earlier today? 18:52 mgage_ http://webwork.maa.org/wiki/DynamicImages gives an overview of creating dynamic graphs -- is this the type of thing you are starting with? 18:56 Tim2 Indeed...I have read through that already, but I wish to add LaTeX and "dynamic" labels to the diagrams...For example draw a triangle, label angle with \theta, or graph a line of the form$ax+5 and label the line with it's equation.
18:58 mgage_ I don't know for sure whether this will work, but you could try $graph->lb(EV3("$$\theta$$) )$.   This creates the url for a picture of an equation (or the jsl/css code in the case of mathjax) -- but whether that will embed in the .png that is being created for $graph is a bit doubtful. Try both mathjax and image mode however since one of them might work. 18:58 mgage_ if you ask this question on the forum you might get a more insightful answer from Davide Cervone 19:00 Tim2 For the scalar labels, I have (inelegantly) worked around it by using say$a = random(3,9,1); $x="x";$ftex = "$a$x+1"; $label1= new Label(.23 ,1.5 ,$ftex  ,'black');
19:01 Tim2 Thank you for the advice.
19:02 mgage_ this looks about right.  you might get more elegant TeX however with something like     $ftex = Compute("x^2+1/x")->TeX 19:02 mgage_ see if something like that works 19:03 pbelley hi mgage_ 19:04 pbelley finally I've found solution. Thanks for your help! It was realy helpfull 19:04 mgage_ Hi Patrick -- I'm around this afternoon and have some time now (sorry I was so rushed yesterday ) -- 19:04 mgage_ so tell me a bit more what you want the web service to do 19:05 Tim2 Thanks again for your help. 19:05 mgage_ Tim2: did it actually work? 19:05 mgage_ using Compute? 19:05 pbelley no 19:05 Tim2 hold on.. 19:05 mgage_ pbelly: so what you end up doing 19:06 pbelley It render equation 19:06 pbelley with pg code 19:06 pbelley by translating from PG to Latex 19:06 pbelley with the pg library AlgParser 19:07 pbelley in last version, it used Parser but now, it only render answer 19:07 mgage_ ok -- that is an older parser that we used before 19:07 pbelley ok 19:07 mgage_ Could you email me a copy of the code that you used for the translator web service feature -- what you are describing doesn't seem quite right 19:08 pbelley no problem 19:08 pbelley using skype? 19:08 mgage_ no reason not to use AlgParser now if it works -- 19:09 mgage_ can you just email me the code snippet -- let me fool with it for half an hour or so and then I can get back to you on Skype. 19:09 mgage_ my email is gagemath.rochester.edu 19:09 mgage_ my idea was something like sub translator { my$input_string = "x^2 +3";
19:10 mgage_ $output_string = Compute($input_string)->TeX; return $output_string; } 19:11 mgage_ I believe$output_stirng = "$$x^2 +3$$"
19:11 pbelley it's sending
19:11 mgage_ better example:  "x^2+3/x" would become "x^2+\frac{3}{x}"
19:11 pbelley It's a PM file
19:12 mgage_ got it
19:12 pbelley ok
19:16 pbelley what do you think about that?
19:17 Tim2 mgage: Using compute did not work for me... it displayed the actual TeX code as labels, though it does include the scalars.
19:19 WhyThePlatypus joined #webwork
19:20 mgage_ pbelley:  can you send me a piece of code (perhaps javaScript? ) that you use to call it?    I was thinking that you'd like to insert the call into WebworkWebservice/MathTranslators.pm
19:20 mgage_ Using https://hosted2.webwork.rochester.edu/webwork2/wikiExamples/MathObjectsLabs2/2/
19:20 mgage_ and input  TEXT(Compute("x^2+3/x")->TeX)
19:20 mgage_ I get output:    x^{2}+\frac{3}{x}
19:20 mgage_ Is that the kind of output you would want?
19:22 mgage_ whytheplatypus:  do you already use a service that takes PG equation as input and just returns the latex version of that equation somewhere in your library code?
19:22 WhyThePlatypus I don't think I do, not sure if anyone else added it
19:23 pbelley mgage_: Will you be here in an hour? just let me finalize insertion and show you VIA skype?
19:23 mgage_ yes -- I'll be around
19:23 pbelley okay
19:23 pbelley I'll try to do it fast
19:24 mgage_ no hurry -- I'm working -- first is the output I just showed you what you are looking for? or do you want something else?
19:25 mgage_ that is  if you send the service   "x^2+3/x"  do you want  x^{2}+\frac{3}{x}  in return? or something else.
19:25 mgage_ ?
19:26 mgage_ if you want the above translation then I think $self->{result}=Compute($PGcode)->TeX will give it to you.
19:26 mgage_ where \$PGcode =  "x^2+3/x"
19:36 pbelley ok I'll try
19:40 pbelley Wich module I have to import for compute?
19:42 mgage_ "MathObjects.pl"     pg/macros  and a bunch of the libraries under pg/lib/
19:42 mgage_ Parser and Value directories should do it
19:44 mgage_ It may turn out that you need to load too many files to make this work easily and that using AlgParser will actually work better.
19:45 mgage_ The MathObjects code does a better job of parsing the student's input and sending useful error messages but you may not need that for the equation editor.
19:46 pbelley ok
19:46 mgage_ or if you do we could add that later after you get the equation editor working with Algparser
19:46 pbelley it's already working with AlgParser
19:47 pbelley but it's won't work with abs()
19:48 pbelley but I think it's normal
19:48 mgage_ that might be missing from AlgParser.
19:48 pbelley possible
19:49 pbelley MathObject can translate from "abs()" to "|{}|" ?
19:49 mgage_ yes
19:49 pbelley oh nice
19:49 pbelley ok
19:49 mgage_ it will also read  |x|   directly as input
19:50 mgage_ to use MathObjects you will need to load in at least some of the modules used by WeBWorK::Utils::Tasks qw(renderProblems)
19:51 mgage_ that might not be quite as quick as what you are doing.  I'll take a look  -- if I create a translate()  and you send me
19:52 mgage_ "x^2 +1/x)"  then the translate service should return "x^{2} +\frac{1}{x}"    -- is that correct?
19:52 mgage_ "x^2+1/x"  should be the input
19:54 pbelley yes it's correct
19:54 mgage_ kk -- I'll try to write something that does that using MathObjects and the renderProblem() subroutine
19:54 pbelley But I have some difficult about finding mathobject
19:55 pbelley for compute
19:55 mgage_ Compute() is usually called from within a PG problem.
19:58 mgage_ for example:  http://webwork.maa.org/wiki/DifferentiateFunction1   although you should use Compute() instead of Formula() to get more control over what the output looks like.
19:59 mgage_ In particular you need to have loaded the MathObjects.pl file,  but that also requires a bunch of other libraries
20:01 mgage_ afk
20:11 mgage_ back
20:12 pbelley hi back
20:13 pbelley mgage_ : I don't know how use Compute if I'm develloping module and don't editing question?
20:16 pbelley mgage_ : the code I sent to you was a .PM file
20:16 pbelley created for the module
20:21 mgage_ I'm trying to figure out whether you have to build a little PG file and submit it to renderProblem() or whether there is a more streamlined way to call Compute()
20:23 pbelley ok I see
20:25 mgage_ you will need to       require "pg/macros/Parser.pl" --- that defines Compute
20:30 mgage_ also Value.pl and PGcommonFunctions.pl  and then you have to "use Values" and "use Parser"   I don't know if that will call in all of the other modules in the Values and Parser directories -- it might
20:33 pbelley ok
20:39 pbelley I'm too taken by time to do that now (Because I have to solve it before monday, but It's noted to use into a second version
20:40 mgage_ that sounds fine to me -- I'm looking at how Tasks::renderProblem() could be used for this for a second version -- I'll send it to you if I get it working
20:43 pbelley ok thank's
20:45 Tim2 joined #webwork
21:35 pbelley I have finish for today
21:36 pbelley it was nice to talk with you mgage . thanks for all. Have a nice week-end
21:55 mgage_ joined #webwork
23:12 Tim2 joined #webwork
23:20 WhyThePlatypus joined #webwork
23:34 WhyThePlatypus joined #webwork
23:43 WhyThePlatypus joined #webwork
23:54 mgage_ joined #webwork