forked from mitocw/latex2edx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest3.tex
154 lines (99 loc) · 3.48 KB
/
test3.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
%
% File: test3.tex
% Date: 17-Jul-12
% Author: I. Chuang <[email protected]>
%
% Example latex source file for an edX course.
% This file can be compiled using
%
% python latex2edx -prefix ATEST test3.tex
%
% to generate all the content files for an example edX course named
% "1.00x". The files are saved in a subdirectory named "1.00x", and
% include:
%
% 1.00x/course.xml - main table of contents for course
% 1.00x/problem/Problem_1.xml - problem 1 (symbolic response example)
% 1.00x/problem/Problem_2.xml - problem 2 (option response example)
\documentclass[12pt]{article}
\usepackage{edXpsl} % edX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{edXcourse}{1.00x}{1.00x Fall 2012}
\begin{edXchapter}{Unit 1}
\begin{edXsection}{Introduction}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{edXproblem}{Problem 1}{40}
\section{Example of symbolic response}
This is a sample problem, which is worth 40 points. What is the number made famous by
Hitchhiker's guide to the galaxy?
\edXabox{type='symbolic' size='90' expect='42' }
\end{edXproblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{edXproblem}{Problem 2}{10}
\section{Example of option response}
This is a sample problem, which is worth 10 points.
Give the correct python {\tt type} for the following expressions. Select {\tt noneType} if the expression is illegal.
\begin{itemize}
\item {\tt 3} \edXabox{expect="int" options="noneType","int","float"}
\item {\tt 5.2} \edXabox{expect="float" options="noneType","int","float"}
\item {\tt 3/2} \edXabox{expect="int" options="noneType","int","float"}
\item {\tt 1+[]} \edXabox{expect="noneType" options="noneType","int","float"}
\end{itemize}
\end{edXproblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{edXproblem}{Problem 3}{10}
\section{Example of string response}
What state is Detroit in?
\edXabox{expect="Michigan" type="string"}
\end{edXproblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{edXvertical}{A sample vertical - multiple problems in one day}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{edXproblem}{Problem 3.5}{10}
\section{Example of numerical response}
What is the numerical value of $pi$?
\edXabox{expect="3.14159" type="numerical" tolerance='0.01' }
\end{edXproblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{edXproblem}{Problem 4}{10}
\section{Example of custom response}
This problem demonstrates the use of a custom python script used for
checking the answer.
\begin{edXscript}
def sumtest(expect,ans):
(a1,a2) = map(float,eval(ans))
return (a1+a2)==10
\end{edXscript}
Enter a python list of two numbers which sum to 10:
\edXabox{expect="[1,9]" type="custom" cfn="sumtest"}
\end{edXproblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{edXvertical}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{edXproblem}{Problem 4}{10}
\section{Example of external response (coding problem)}
This problem demonstrates a python coding problem.
\begin{edXscript}
initial_display = ""
answer = """
print "hello world"
"""
preamble = """
code = '''
"""
test_program = """
'''
code = code.replace('print ','print >> LOG_OUTPUT, ')
exec(code)
"""
\end{edXscript}
Write python code which prints out ``hello world''
\edXabox{type="external" tests="1"}
\end{edXproblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{edXsection}
\end{edXchapter}
\end{edXcourse}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}