Developing Interactive Courseware in Mathematica

Kelvin Mischo

Senior Sales Engineer

Mathematica Documents in Education

Row[{
Import["http://blog.wolfram.com/images/Version2.gif"],
"      ",
Column[{
Style["Classic Uses of Notebook Format:", FontFamily->"Arial", "Subsection"],
Style["   • Static Graphics", FontFamily->"Arial", "Text"],
Style["   • Series of Calculations for Lectures", FontFamily->"Arial", "Text"],
Style["   • Student Projects, Authoring Answers", FontFamily->"Arial", "Text"]
}],
}]

Row[{
Column[{
Style["Notebook Format with Version 6:", FontFamily->"Arial", "Subsection"],
Style["   • Demonstrations Project Applications", FontFamily->"Arial", "Text"],
Style["   • webMathematica Applications", FontFamily->"Arial", "Text"],
Style["   • Students Authoring Applications", FontFamily->"Arial", "Text"]
}],
"      ",
Import["http://blog.wolfram.com/images/m6.gif"]
}]

Row[{
ImageCrop[Import["http://www.wolfram.com/mathematica/compare-mathematica/images/integrated.jpg"], {180, 180}],
"      ",
Column[{
Style["Mathematica 8 and CDF:", FontFamily->"Arial", "Subsection"],
Style["   • Embedded Applications in Web Sites", FontFamily->"Arial", "Text"],
Style["   • Involved Applications with Open Input", FontFamily->"Arial", "Text"],
Style["   • Virtual Labs in Physical Science and Engineering", FontFamily->"Arial", "Text"],
Style["   • Application to Poll Students During Lecture", FontFamily->"Arial", "Text"]
}]
}]

Embedding Applications in Web Sites

CDF Browser Plug-In

Blog Entry, Interactive ‘Slinky Thing’

CUNY Faculty Personal Web Page

Define NB and CDF File Types in CMS

Add to server’s configuration files:

application/vnd.wolfram.player nbp
application/vnd.wolfram.mathematica nb
application/vnd.wolfram.cdf cdf
application/vnd.wolfram.cdf.text cdf

Practice Problem Application

Panel[
DynamicModule[
{eq1=(x+3)*(x+4),answer1="enter answer here", grade1="ready to grade"},
Column[{
"Equation:",
InputField[Dynamic[TraditionalForm[eq1], (eq1=#)&]],
"Write expanded form here:",
InputField[Dynamic[TraditionalForm[answer1], (answer1=#)&]],
Button["Grade", checker[eq1, answer1]],
Button["New Problem", {eq1=(x+a) (x+b)/.{a->RandomInteger[{-10,10}],b->RandomInteger[{-10,10}]}, answer1="enter answer here", grade1="ready to grade"}],
InputField[Dynamic[grade1]]
}], Initialization:>(checker[eq_,answer_]:=
If[Expand[eq]===answer, grade1=Correct, grade1=Incorrect])
]
]

Underlying Mathematica Calculations

Expand[(x+4)(x+3)]

checker[eq6_,answer6_]:=
If[Expand[eq6]===answer6, grade6=True, grade6=False]

checker[(x+4)(x+3), (x^2)+7 x+12]

Interface Layout

InputField[Dynamic[grade6]]

InputField[Dynamic[eq6]]
InputField[Dynamic[answer6]]
Button["Grade", checker[eq6, answer6]]
InputField[Dynamic[grade6]]

Combine the Interface Layout and Calculations

Panel[
DynamicModule[
{eq6=(x+3) (x+4),answer6="enter answer here"},
Column[{
InputField[Dynamic[eq6]],
InputField[Dynamic[answer6]],
Button["Grade", checker[eq6, answer6]],
InputField[Dynamic[grade6]]
}], 
Initialization:>(checker[eq6_,answer6_]:=
If[Expand[eq]===answer6, grade6=True, grade6=False])
]
]

Addition of Random Number Generator

Panel[
DynamicModule[
{eq2=(x+3) (x+4),answer2="enter answer here", grade2="ready to grade"},
Column[{
"Equation:",
InputField[Dynamic[TraditionalForm[eq2], (eq2=#)&]],
"Write expanded form here:",
InputField[Dynamic[TraditionalForm[answer2], (answer2=#)&]],
Button["Grade", checker[eq2, answer2]],
Button["New Problem", {eq2=(x+a) (x+b)/.{a->RandomInteger[{-10,10}],b->RandomInteger[{-10,10}]}, answer2="enter answer here", grade2="ready to grade"}],
InputField[Dynamic[grade2]]
}], 
Initialization:>(checker[eq_,answer_]:=
If[Expand[eq1]===answer2, grade1=Correct, grade2=Incorrect])
]
]

Practice Problem Application

Random Graphics Rather Than Random Expressions

Panel[
DynamicModule[
{eq4=3x+4,answer4="enter answer here", grade4="ready to grade"},
Column[{
"Find the equation of the line in standard form that passes through\nthe given points and represents the line on the graph below.",
Dynamic[Plot[eq4, {x, -10, 10}, PlotRange->{-10, 10},GridLines->{Range[-10, 10],Range[-10, 10]},ImageSize->450, Background->White]],
" ",
"Write equation here:",
Row[{
"y = ",
InputField[Dynamic[TraditionalForm[answer4], (answer4=#)&]]
}],
Button["Grade", checker4[eq4, answer4], ImageSize->200],
Button["New Problem", {eq4=a x+b/.{a->RandomInteger[{-10,10}],b->RandomInteger[{-10,10}]}, answer4="enter answer here", grade4="ready to grade"}, ImageSize->200],
InputField[Dynamic[grade4]]
}], Initialization:>(checker4[eq_,answer_]:=
If[Expand[eq]===answer, grade4=Correct, grade4=Incorrect])
]
]

Mouse-Driven Answers Rather Than Simple Expression

Panel[
DynamicModule[
{eq5=(3/5)x+4,pt1={2,0},pt2={3,0},answer5="enter answer here", grade5="ready to grade"},
Column[{
Style["Instructions:", Blue],
"Graph the following equation by moving the points in the graph.  \nClick the Grade button to see if you've graphed the equation correctly.",
" ",
Row[{"y = ",Dynamic[eq5]}],
LocatorPane[Dynamic[{pt1, pt2}],
Dynamic[Plot[
If[Round[First[pt2]]===Round[First[pt1]],
20,
(Round[Last[pt2]]-Round[Last[pt1]])/(Round[First[pt2]]-Round[First[pt1]]) (x-Round[First[pt1]])+Round[Last[pt1]]], 
{x, -10, 10}, 
PlotRange->{-10, 10},
GridLines->{Range[-10, 10],Range[-10, 10]},ImageSize->450, Background->White,
Epilog->{
PointSize[Large],
Point[
{Dynamic[{Round[First[pt1]],Round[Last[pt1]]}],{Round[First[pt2]],Round[Last[pt2]]}}
]}]], Appearance->None
],
" ",
Button["Grade", 
checker[eq5, Simplify[((Round[Last[pt2]]-Round[Last[pt1]])/(Round[First[pt2]]-Round[First[pt1]])) (x-Round[First[pt1]])+Round[Last[pt1]]]], 
ImageSize->200],
Button["New Problem", {eq5=(a/b) x+c/.{a->RandomInteger[{-10,10}],b->RandomInteger[{1,10}], c->RandomInteger[{-10,10}]}, answer5="enter answer here", grade5="ready to grade"}, ImageSize->200],
InputField[Dynamic[grade5]]
}], Initialization:>(checker[eq_,answer_]:=
If[Expand[eq5]===answer, grade5=Correct, grade5=Incorrect])
]
]

Curated Data As Basis For Random Practice Problems

Panel[
DynamicModule[
{chemical="Water", chemicaltable=Row[{ChemicalData["Water", "MolecularFormula"], ChemicalData["Water", "MoleculePlot"]}],answer1="enter answer here", grade1="ready to grade"},
Column[{
"Molecular formula and molecule plot:",
Dynamic[chemicaltable],
"Write common name here:",
InputField[Dynamic[answer1], String],
Button["Grade", 
If[chemical===answer1,
grade1=Correct,
grade1=Incorrect]
],
Button["New Problem", {chemical=RandomChoice[chemicallist], chemicaltable=Row[{ChemicalData[chemical, "MolecularFormula"], ChemicalData[chemical, "MoleculePlot"]}], answer1="enter answer here", grade1="ready to grade"}],
InputField[Dynamic[grade1]]
}],
Initialization:>(chemicallist={"Water", "Caffeine", "Acetone", "Sucrose"})
]
]

Add Applications to Your Suite of Mathematica Tools

Courseware With Text, Drawing Tools, Manipulate, and Open Inputfield Application

Binomial Expansion

Virtual Labs in Physical Science and Engineering

Display Physical Phenomena Not Possible in Class

Terminal Velocity Demonstration

Application To Analyze Measured Student Data

Manipulate[
Column[{
ListPlot[Partition[Riffle[data[[All, 2]], data[[All,3]]],2][[time;;time]], PlotRange->{{-0.2, 1.5}, {-0.2, 0.3}}, ImageSize->350, AxesLabel->{"Time", "Position"}, Axes->False, PlotStyle->PointSize[0.04], Epilog->{Line[{{0,-0.013},{0.78, -0.013}}], Line[{{0.78,-0.013},{1.5, 0.244}}]}, PlotLabel->"Animation of Ball Rolling on Incline, Phys 107 Lab 1"],
Row[{
ListPlot[Partition[Riffle[data[[All, 1]], data[[All,10]]],2][[1;;time]], PlotRange->{{0, 2.2}, {0, 2}}, ImageSize->200, AxesLabel->{"Time", "Position"}],
ListPlot[Partition[Riffle[data[[All, 1]], data[[All,11]]],2][[1;;time]], PlotRange->{{0, 2.2}, {-2.5, 2.5}}, ImageSize->200, AxesLabel->{"Time", "Velocity"}],
ListPlot[Partition[Riffle[data[[All, 1]], data[[All,12]]],2][[1;;time]], PlotRange->{{0, 2.2}, {-8, 4}}, ImageSize->200, AxesLabel->{"Time", "Acceleration"}]
}]
}],
{time, 1, Length[data], 1}, 
Initialization:>(data=Import["C:\\Users\\kelvinm\\Desktop\\Developing Interactive Courseware Tech Conf 2011\\Bates_lab_data_freefall.xls"][[1]])]

Application To Poll Students During Lecture

Notebook Given To Students

Note that this is set up for WRI’s internal file share and will not work in it’s current form.  Change reference of temp-store to your file share system

Panel[
DynamicModule[
{firstname="Joe", 
lastname="Smith",
question1= "Today we talked about functions and certain calculations that relate to velocity and acceleration.  The term f''(x) is notation for what mathematical concept?",
answer1="Enter answer here", 
question2="What is the derivative of sin(x) with respect to x?",
answer2="Enter answer here", 
question3="π is greater than 3.14.",
answerlabel3={"True", "False"},
answer3=1, 
question4="Which graph below is the graph of the derivative of sin(x)?",
answerlabel4={Plot[Tan[x], {x, -5, 5}],Plot[Cos[x], {x, -5, 5}],Plot[Sin[x], {x, -5, 5}],Plot[Sec[x], {x, -5, 5}]},
answer4=1,
question5="How confident are you that you got all the answers correct?",
answerlabel5={"Very confident", "Somewhat confident", "Had to guess on a few questions", "Didn't know any single answer"},
answer5=1},
Column[{
Row[{Style["Enter First Name:  ", Brown, Bold],InputField[Dynamic[firstname], String], Style["   Enter Last Name:  ", Brown, Bold], InputField[Dynamic[lastname], String]}],
" ",
Row[{Style["Question 1:\n", Red], Style[stringcut[question1, 70], Blue]}],
InputField[Dynamic[answer1], String, FieldSize->40],
" ",
Row[{Style["Question 2:\n", Red], Style[stringcut[question2, 70], Blue]}],
InputField[Dynamic[answer2], FieldSize->40],
" ",
Row[{Style["Question 3:\n", Red], Style[stringcut[question3, 70] , Blue]}],
Grid[Table[{RadioButton[Dynamic[answer3], i], i},{i, answerlabel3}], Alignment->Left],
" ",
Row[{Style["Question 4:\n", Red], Style[stringcut[question4, 70] , Blue]}],
Grid[Table[{RadioButton[Dynamic[answer4], i], i},{i, answerlabel4}], Alignment->Left],
Row[{Style["Question 5:\n", Red], Style[stringcut[question5, 70] , Blue]}],
Grid[Table[{RadioButton[Dynamic[answer5], i], i},{i, answerlabel5}], Alignment->Left],
Button[Style["Submit Quiz Answers", Red], Export["//files.wolfram.com/temp-store/kelvinm/techconf/"<>ToString[firstname]<>ToString[lastname]<>".nb", {firstname, lastname, question1, answer1, question2,answer2, question3,answer3, question4,answer4, question5, answer5}]
]
}],
Initialization:>(stringcut[st_, stdivision_]:=
(result={};
low=1;
Do[
If[Total[Map[StringLength, StringSplit[st][[low;;i]]]]>stdivision, AppendTo[result,Map[#<>" "&, StringSplit[st][[low;;i]]]]; low=i+1;, f],
{i, 1, Length[StringSplit[st]], 1}];
Apply[StringJoin,Riffle[AppendTo[result, Map[#<>" "&, StringSplit[st][[low;;Length[StringSplit[st]]]]]], "\n"]]))
]
]

Application To Poll Students During Lecture

Teacher Notebook to Analyze Answers

Can be any expression rather than a, b, c, d

Note that this is set up for WRI’s internal file share and will not work in it’s current form.  Change reference of temp-store to your file share system

Shared Drive Required - Clients Posting Results For Teacher to Import

SetDirectory["//files.wolfram.com/temp-store/kelvinm/techconf/"];
results=ToExpression[Import[#][[1]][[1]]/.Cell[BoxData[p_],"Input"]-> p]&/@FileNames[];//AbsoluteTiming
Manipulate[Column[{results[[All, (i-1)]][[1]],BarChart[Tally[results[[All,i]]][[All,2]],ChartStyle->"DarkRainbow",ChartLegends->Tally[results[[All,i]]][[All,1]]]}], {i, 4, Length[results[[1]]], 2}]

CDF Player and Mathematica Deployment

CDF Player

Mathematica Site License

Mathematica Player Pro

Custom “Signing” of CDF Documents