forked from OpenDSA/OpenDSA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhowToCreateRecProgEx.txt
More file actions
87 lines (70 loc) · 3.47 KB
/
howToCreateRecProgEx.txt
File metadata and controls
87 lines (70 loc) · 3.47 KB
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
To create a new recursion programming exercise:
Front end:
==========
1- Go to OpenDSA/Exercises/RecurTutor
2- Create html file exercisename.html. Note that: the exercise name has to have "rec" in its name to be identified by the back end as a recursion exercise (e.g. "recprogex1.html").
3- Open the html file and modify the text of the following tag to have the problem statement:
<p class="problem" id = "test">
e.g. Complete the missing recursive call so that the following function computes something.
4- Modify the text of to have the code that required to be edited by the student:
<textarea id="codeTextarea">
e.g:
int examplefunc(int i) {
if (i > 0) {
if (i % 2 == 1) {
return i;
}
//<<Missing a Recursive call>>
}
}
5- Go to OpenDSA/Exercises/RecurTutor/xml
6- Create a file exercisename.xml with the same name as the exercisename of the html
file created in the previous step (e.g. "recprogex1.xml").
7- Open the xml file and modify the following tags (id,title and description):
<id>http://localhost/OpenDSA/Exercises/RecurTutor/recprogex1.html</id>
<title type='text'>Recursion Tutor Programming Exercise Number or Description</title>
<description type='text'>Recursion Tutor Programming Exercise Number or Description</description>
8- Open OpenDSA/config/RecurTutor.json
9- Add the exercise in the exercises section as follows:
e.g.:
"recprogex1": {
"long_name": "Recursion Programming Exercise Number or Description",
"required": true,
"points": 0.0,
"threshold": 1.0
}
10 - Open OpenDSA/RST/en/RecuTutor/RecursionSkeleton.rst
11- Add the following line so that the programming exercise appears:
e.g.:
.. avembed:: Exercises/RecurTutor/recprogex1.html ka
12- Build the book on the front end:
go to OpenDSA/
run the command: sudo make RecurTutor
Back end: (Unit tests)
======================
1- Go to OpenDSA-server/ODSA-django/openpop/build/rectest
2- Create a directory with the same name as the exercise name created on the front end (e.g. recprogex1)
3- Create java file that will have the unit tests: exercisename.java (e.g. recprogex1.java)
4- Open the exercisename.java.
5- Name the class in the file as studentexercisename (e.g. studentrecprogex1). Note that the class should be missing its closing brace. The Python code on the back end will append that closing brace dynamically when the student submit his code. The Python code appends the function submitted by the student to the java code and add the closing brace dynamically.
6- Create a function in the java file that returns the model answer.
7- In the main function, create the code required for the unit tests and call the model answer function (e.g. int x= modelexercisefunction(i)).
8- For each unit test, call both the model answer function and the function given to the student in the front end in the <textarea id="codeTextarea">. e.g. examplefunc(int i).
9- Compare both answers as follows:
if (studentfunctionreturn(i) == modelexamplefunction(i)) SUCCESS = true;
try{
PrintWriter output = new PrintWriter("output");
if (SUCCESS) {
output.println("Well Done!");
output.close();
}
else
{
output.println("Try Again! Incorrect Answer!");
output.close();
}
}
catch (IOException e) {
e.printStackTrace();
}
10- Note that: you should do the necessary logic to make sure that all the unit tests are correct. Also, you will not need to modify any of the Python files on the back end.