﻿
7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS
41
Figure 18: Result of Variables in the Text Block
$a = -3.0;$b = &sin($a);$c = &pow(3.0, &abs($a)); Figure 19: Some Function Calls If you are generating numbers using a formula which includes a division operation, it is advisable to format your output. For example, if$variable=1/3, it will display with too
many digits. You can adjust the format using the num output tag described in the Output
Tags section 15.6
7.4.3 Variables in the Answer Block
You can use variables in the Answer part of the question. This means you can compute an
answer to a question. If you set the answer of the question to be $variable, Save Changes and View it, you’ll see that LON-CAPA is now expecting “3.0” as the answer, plus or minus 5%. 7.5 Calling Functions With variables, you can store strings or numbers. Functions allow you to manipulate these strings or numbers. Functions work like mathematical functions: They take some number of arguments in, and return one argument, usually a number or a string for our purposes. There are a lot of functions available in LON-CAPA. You can see a complete list in the Script section 16.1 and LON-CAPA function section 16.3. For now, let’s just look at some simple examples. In the Script block, function names start with &. Some example function calls are shown above. You can see that functions can take either variables, numbers, or the results of other function calls as parameters. The &sin function returns the sine of an angle expressed in radians. &pow raises the ﬁrst parameter to the power of the second parameter. &abs returns the absolute value of the argument. Pdf form save in reader - C# PDF Field Edit Library: insert, delete, update pdf form field in C#.net, ASP.NET, MVC, Ajax, WPF Online C# Tutorial to Insert, Delete and Update Fields in PDF Document add email button to pdf form; adding text to pdf form Pdf form save in reader - VB.NET PDF Field Edit library: insert, delete, update pdf form field in vb.net, ASP.NET, MVC, Ajax, WPF How to Insert, Delete and Update Fields in PDF Document with VB.NET Demo Code best way to make pdf forms; create a pdf form in word 7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS 42 Figure 20: Formula Response Problem 7.5.1 Numerical Response Randomization If you’re following this material and creating an example, click the button for a new random seed to generate other problem presentations. 7.6 Authoring Formula Response Problems Formula Response problems authoring is illustrated by Figure 20. Note how the function is randomly generated, as well as the answer. Note that sampling is also available for evaluating answers. Sampling is a good alternative when students may give several equivalent forms that are diﬃcult to compare in text. Clicking the help box next to the Sample Points ﬁeld describes how to use sample points instead of a text comparison. C# PDF: PDF Document Viewer & Reader SDK for Windows Forms SaveFile(String filePath): Save PDF document file to a specified path form (Here, we take a blank form as an open a file dialog and load your PDF document in add photo to pdf form; add form fields to pdf VB.NET Image: How to Save Image & Print Image Using VB.NET printing multi-page document files, like PDF and Word is used to illustrate how to save a sample RE__Test Public Partial Class Form1 Inherits Form Public Sub New pdf create fillable form; create pdf forms 7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS 43 Figure 21: Slope Problem Parameters 7.7 Dynamic, Randomized Problems: Putting It All Together Now you have all the tools to create those wonderful dynamic, randomized problems that you’ve seen in LON-CAPA. Consider a Numerical Response problem where the equations for two lines are randomly generated and the students are asked to ﬁnd the intercept. Try ﬁlling out your problem with the parameters shown in Figure 21. When creating randomized problems, you want to make sure that the problems always have an answer. Consider what might happen if two slopes are chosen, both with the ex- pression &random(-1.0,1.0,.2). One out of ten students would get a problem where both slopes were equal, which has either no solution (for unequal y-intercepts) or an inﬁnite num- ber of solutions (for equal slopes and y-intercepts). Both of these cause a division-by-zero error on the division that computes the answer. There are many ways to avoid this, one of the easiest of which is picking one slope negative and one positive. This same problem can show up in many other places as well, so be careful. 7.8 Units, Format Numerical Response problems can require units. In the problem editing form, place the desired unit in the Unit ﬁeld. A complete list of units is in the Physical Units section (20). The computer will accept the answer in any of its accepted unit formats. For example, if the answer to a problem is “1ft”, the computer will accept “12in” as correct. Additional units can be deﬁned using the “customunits” parameter, which is a comma- separated list of unit conversions. For example peck=2*gallon,bushel=8*gallon,gallon=4.4*L would deﬁne the new units peck, bushel, and gallon. The last entry in a conversion chain always needs to be a unit that LON-CAPA already supports. C# PDF File Merge Library: Merge, append PDF files in C#.net, ASP. Merge Microsoft Office Word, Excel and PowerPoint data to PDF form. Append one PDF file to the end of another and save to a single PDF file. add editable fields to pdf; add print button to pdf form VB.NET PDF Page Delete Library: remove PDF pages in vb.net, ASP. this RasterEdge XDoc.PDF SDK, you can simply delete a single page from a PDF document using VB.NET or remove any page from a PDF document and save to local adding form fields to pdf; add text field to pdf acrobat 7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS 44 You can format the number displayed by the computer as the answer. For instance, if the answer is one-third, the computer will display that it computed “.333333333” as the answer. If you’d like to shorten that, you can use the Format ﬁeld. Format strings like “2E” (without the quotes) will display three signiﬁcant digits in scientiﬁc notation. Format strings like “2f” will display two digits after the decimal point. Format strings like “2s” will round a number to 2 signiﬁcant digits. For a summary of numerical format statements, see the num tag item in the Output Tags section (15.6). 7.9 For More Information The full power of Perl is well outside the scope of this document. Looking in the function list in the section 16.3 can give you some ideas. O’Reilly has some good Perl books. Enter ”perl” in the search box at http://search.oreilly.com. If you need help, you might search the listserv at http://mail.lon-capa.org/mailman/swish.cgi or consider joining the users listserv to ask other users for advice at http://mail.loncapa.org, or use the Help link to contact the Help desk. Often other users are quick to provide help. Our advanced users often come to prefer the XML interface for the problems, available through the EditXML buttons. Covering the XML format is beyond the scope of this manual, but you can learn a lot by using the editor tomake changes and seeing what happens to the XML. Supported XML tags are discussed in the Tags Used in XML Authoring section (15). 7.10 Formula Response Formula Response problems have the same capabilities as Numerical Response problems, and add the ability to ask the student for a symbolic formula as an answer, instead of a simple number. 7.10.1 Sample Speciﬁcations As you may know, it is extremely diﬃcult to determine whether a given expression is exactly equal to another expression in general. For example, is sin2x = 2sinxcosx? LON-CAPA has two ways of ﬁnding out if it is: • algebraically, using a symbolic algebra system • numerically, using sampling points You need to determine which way is the safest in a given situation. If you don’t specify sampling points, the symbolic algebra system is used. If you do specify sampling points, LON-CAPA uses them. If your answer and the stu- dent’s answer agree at the sampling points within your given tolerance factor, the student’s answer will be accepted. If the student’s answer does not agree at the sampling points within your given tolerance factor, it will be rejected. C# PDF Page Extract Library: copy, paste, cut PDF pages in C#.net to extract single or multiple pages from adobe PDF file and save into a The portable document format, known as PDF document, is a widely-used form of file change pdf to fillable form; change font size in pdf form C# Image: Save or Print Document and Image in Web Viewer or image, you can easily save the changes to DLL Library, including documents TIFF, PDF, Excel, Word string fileName = Request.Form["saveFileName"]; string fid adding text fields to pdf; acrobat create pdf form 7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS 45 To specify where to sample the formulas for determining whether the student’s answer is correct, you need to put a sampling speciﬁcation in the Sample Points ﬁeld. The sampling speciﬁcations take the following format: 1. A comma-separated list of the variables you wish to interpret, 2. followed by “@” (not in quotes), 3. followed by any number of the following two things, separated by semi-colons: (a) a comma-separated list of as many numbers as there are variables, which speciﬁes one sampling point, OR (b) a comma-separated list of as many numbers as there are variables, followed by a colon, followed by another list of as many numbers as there are variables, followed by a #, followed by an integer. The ﬁrst form speciﬁes one point to sample. The second form speciﬁes a range for each variable, and the system will take as many random samples from that range as the number after the #. For 2x 2 +4, with one variable “x”, one could specify: • “x@2”, which will sample the answers only at 2. (This is generally a bad idea, as the student could get lucky and match at that point) • “x@1:5#4” will takes 4 samples from somewhere between 1 and 5. • “x@1:5#4;10” will takes 4 samples from somewhere between 1 and 5, and also sample at 10. For 2x 2 +3y 3 +z, which has three variables, one could specify: • “x,y,z@4,5,3:10,12,8#4;0,0,0”, which take four samples from the box determined by the points (4, 5, 3) and (10, 12, 8), and also sample the point (0, 0, 0). 7.10.2 Formula Notes • The formula evaluator can not handle things of the form “x + - y”. If you have a random variable that may be positive or negative (as in the example following this section), you can try wrapping the references to that variable in parentheses. As always, it is a good idea to try out several randomized versions of your problems to make sure everything works correctly. • Never use relative tolerance in Formula Response problems. Relative toler- ance is poorly deﬁned in Formula Response problems. Always use absolute tolerance. C# PDF Convert to Tiff SDK: Convert PDF to tiff images in C#.net Description: Convert to DOCX/TIFF with specified zoom value and save it into stream. Parameters: zoomValue, The magnification of the original PDF page size. pdf add signature field; change font in pdf form C# Create PDF from Tiff Library to convert tif images to PDF in C# Description: Convert to PDF and save it on the disk. Parameters: Name, Description, Valid Value. Description: Convert to PDF and save it into stream. Parameters: pdf forms save; pdf form creation 7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS 46 7.10.3 Example Formula Response Avery simple formula response problem: • In the Script, place the following:$slope = &random(-5.0,5.0,.5);
$yint = &random(-5.0,5.0,.5);$answer = "$slope*x + ($yint)";
• In the Text Block, place the following: “For a line with slope $slope and y-intercept$yint, what is y equal to?”
• In the Answer, place the following: $answer • Set the Tolerance to .000001. • Set the Sample Points to x@0;1;2;3 . 7.11 Authoring Math Response Problems Math response problems use a cas system to evaluate the student response. Which computer algebra system is to be used is speciﬁed in the cas argument of the mathresponse tag; both Maxima and R are supported. Maxima and R are also powerful stand-alone programs that can be installed on most operating systems. If you are interested in writing Maxima or Rproblems, it is a good idea to install a copy on your operating system to access help, learn syntax, and test your expected responses outside the LON-CAPA environment. See http://maxima.sourceforge.net/ or http://www.r-project.org/. LON-CAPA will accept two pre-named arrays inside the answerblock for the computer algebra system: RESPONSE and LONCAPALIST. RESPONSE contains the student input by comman-separated entities, for example, if ”3,42,17” is entered by the student, RE- SPONSE[2] would be 42. LONCAPALIST is built from the arguments passed in an array args which is assigned a array value from the script. The answer tag contains the Maxima command (and syntax) that are passed to Maxima aftertheRESPONSE and LONCAPALISTvaluesare substituted. (See examplebelow). The answerdisplay variable contains what is displayed when the problem is in ”Show Answer” mode. You will want to include this ﬁeld so that the students can see the correct answer after the ”Show Answer Date” conﬁgured when the problem is assigned in the course space. Also note the description in the postanswerdate tag that is displayed after the answer date. The following example illustrates this. <problem> <script type="loncapa/perl">$a1 = random(-6,6,4);
$a2 = random(-6,6,4);$n1 = random(3,11,2);
$n2 = random(2,10,2); C# PDF Convert to Word SDK: Convert PDF to Word library in C#.net key. Quick to remove watermark and save PDF text, image, table, hyperlink and bookmark to Word without losing format. Powerful components add image to pdf form; changing font size in a pdf form C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF Description: Convert to PDF/TIFF and save it on the disk. Parameters: Description: Convert to PDF/TIFF and save it into stream. Parameters: change font size in pdf form field; can reader edit pdf forms 7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS 47$function = "$a1*cos($n1*x)+$a2*sin($n2*x)";
# reformat next two lines as single line if you copy/paste into a script
$example=&xmlparse(’An example would be <m eval="on">$(sin($n1\cdot x)+cos($n2\cdot x))/\sqrt{2}$</m>’); </script> <startouttext /> Give an example of a function <ol> <li> which is orthogonal to <algebra>$function</algebra> with respect to the
scalar product
<m>
$<g \mid h> = \frac{1}{\pi} \int_{-\pi}^{\pi}dx g(x) \cdot h(x)$
</m>
</li>
<li>
whose norm is 1.
</li>
</ol>
<endouttext />
<mathresponse answerdisplay="$example" cas="maxima" args="$function">
overlap:integrate((RESPONSE[1])*(LONCAPALIST[1]),x,-%pi,%pi)/%pi;
norm:integrate((RESPONSE[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
is(overlap=0 and norm=1);
<hintgroup showoncorrect="no">
<mathhint name="ortho" args="$function" cas="maxima"> <answer> overlap: integrate((LONCAPALIST[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi; is(not overlap = 0); </answer> </mathhint> <mathhint name="norm" args="$function" cas="maxima">
norm: integrate((RESPONSE[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
is(not norm = 1);
</mathhint>
<hintpart on="norm">
<startouttext />
7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS
48
The function you have provided does not have a norm of one.
<endouttext />
</hintpart>
<hintpart on="ortho">
<startouttext />
The function you have provided is not orthogonal.
<endouttext />
</hintpart>
</hintgroup>
</mathresponse>
<startouttext />
<p>
Note that with respect to the above norm, <m>$\cos(nx)$</m> is perpendicular
to <m>$\sin(nx)$</m> and perpendicular to <m>$\cos(mx)$</m> for
<m>$n\ne m$</m>.
</p>
<endouttext />
</problem>
7.12 Custom Response Problems
Custom Response is a way to have a problem graded based on an algorithm. The use of
this response type is generally discouraged, since the responses will not be analyzable by the
LON-CAPA statistics tools.
For a single textﬁeld, the student’s answer will be in a variable $submission. If the Custom Response has multiple textﬁelds, the answers will be in an array reference, and can be accessed as $$submission[0],$$submission[1], etc. The student answer needs to be evaluated by Perl code inside the < answer>-tag. Cus- tom Response needs to include an algorithm that determines and returns a standard LON- CAPA response. The most common LON-CAPA responses are: • EXACT ANS: return if solved exactly correctly • APPROX ANS: return if solved approximately • INCORRECT: return if not correct, uses up a try • ASSIGNED SCORE: partial credit (also return the credit factor, e.g. return(ASSIGNED SCORE,0.3);) • SIG FAIL, NO UNIT, EXTRA ANSWER, MISSING ANSWER, BAD FORMULA, WANTED NUMERIC, WRONG FORMAT: return if not correct for diﬀerent reasons, does not use up a try 7 AUTHORING NUMERICAL, FORMULA, CUSTOM RESPONSE QUESTIONS 49 The answerdisplay is shown instead of the student response in ’show answer’ mode after the answer date. The following example illustrates this: <problem> <startouttext />Accept an answer of around 90 or -90<endouttext /> <customresponse answerdisplay="something near 90 or -90"> <answer type="loncapa/perl"> # This examples uses perl ’regular expressions’ for string evaluation. # Consult a perl reference for help understanding the regular expressions. # We do not want a vector if ($submission=~/\,/) { return ’EXTRA_ANSWER’; }
# Need a numerical answer here
if ($submission!~/^[\d\.\-\e]+$/i) { return ’WANTED_NUMERIC’; }
$difference=abs(90-abs($submission));
if ($difference==0) { return ’EXACT_ANS’; } if ($difference < 0.1) { return ’APPROX_ANS’; }
</customresponse>
</problem>
Full list of possible return codes:
• EXACT
ANS: student is exactly correct
• APPROX
ANS: student is approximately correct
• NO
RESPONSE: student submitted no response
• MISSING
ANSWER: student submitted some but not all parts of a response
• EXTRA
ANSWER: student submitted a vector of values when a scalar was expected
• WANTED
NUMERIC: expected a numeric answer and didn’t get one
• SIG
FAIL: incorrect number of Signiﬁcant Figures
• UNIT
FAIL: incorrect unit
• UNIT
NOTNEEDED: submitted a unit when one shouldn’t
• UNIT
INVALID
INSTRUCTOR: the unit provided by the author of the problem is
unparsable
• UNIT
INVALID
STUDENT: the unit provided by the student is unparasable
• UNIT
IRRECONCIBLE: the unit from the student and the instructor are of diﬀerent
types
• NO
UNIT: needed a unit but none was submitted