Skip to content

Commit 297a94b

Browse files
committed
finalized 14 and 15
1 parent c22962b commit 297a94b

File tree

4 files changed

+140
-1
lines changed

4 files changed

+140
-1
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
{
3+
"resource_limits" : {
4+
// Allow the submission to run for 10 seconds.
5+
"RLIMIT_CPU" : 10,
6+
// Allow up to 20 additional processes launched by the student code.
7+
"RLIMIT_NPROC" : 20
8+
},
9+
"allow_system_calls" : [
10+
"ALLOW_SYSTEM_CALL_CATEGORY_COMMUNICATIONS_AND_NETWORKING_SIGNALS",
11+
"ALLOW_SYSTEM_CALL_CATEGORY_COMMUNICATIONS_AND_NETWORKING_SOCKETS",
12+
"ALLOW_SYSTEM_CALL_CATEGORY_COMMUNICATIONS_AND_NETWORKING_SOCKETS_MINIMAL",
13+
"ALLOW_SYSTEM_CALL_CATEGORY_FILE_MANAGEMENT_RARE",
14+
"ALLOW_SYSTEM_CALL_CATEGORY_PROCESS_CONTROL_NEW_PROCESS_THREAD"
15+
],
16+
"testcases" : [
17+
{
18+
"title" : "Actions Example",
19+
//The expected python program creates a window using tkinter
20+
//This window is a simple dialog box, which echoes input.
21+
//To grade this, we want to type "Submitty" into a text
22+
//field, click the ok box, then click the exit button.
23+
//To do this, we will use the actions defined below.
24+
"command" : ["python3 *.py" ],
25+
//*************** Actions *********************
26+
//Actions allow you to interface GUI programs
27+
//via submitty. Note that in order to run such
28+
//applications, it is required that you have
29+
//set up a "Submitty with a screen;" a machine
30+
//running submitty with a monitor. This machine
31+
//must also run only one grading thread at a
32+
//time. For more information, please visit the
33+
//submitty wiki.
34+
"actions" : [
35+
//it is recommended that programs with GUIs begin with
36+
//an extra delay to allow student code time to fully
37+
//initialize.
38+
"delay 2",
39+
//This command will screenshot the student's window.
40+
//Pair it with the validation below to show it to
41+
//display it to the students.
42+
"screenshot",
43+
//The type command will submitty the provided characters
44+
//as keyboard input to the student's window.
45+
"type 'Submitty'",
46+
//This screenshot should show the effects of the type command
47+
//above
48+
"screenshot",
49+
//We will now move the mouse (in pixels relative to the upper
50+
//left hand corner of the screen). This location correlates with
51+
//where the student's ok button should be. Note that we could have
52+
//required the student to map the button to a specific hotkey and typed
53+
//that instead.
54+
"mouse move 200 75",
55+
//This delay is added merely so that instructors can watch the grading
56+
//happen, in practice it is unnecessary.
57+
"delay 1",
58+
//now we click the ok button.
59+
"click",
60+
//This screenshot should show the effect of the previous command.
61+
"screenshot",
62+
"delay 1",
63+
//The no clamp option allows us to move the mouse 'outside' of the window
64+
//It is recommended that this option only be used after much testing to avoid
65+
//unwelcome interactions. In this case, it was necessary to access the 'x' in
66+
//border of the student's screen.
67+
"mouse move no clamp 10 -10",
68+
"click"],
69+
// Point value of this testcase.
70+
"points" : 10,
71+
//These validation steps check for the screenshots taken above, which are created
72+
//with sequential labels starting at 0. For more information, please visit the submitty wiki.
73+
"validation" : [
74+
{
75+
"actual_file": "0.png",
76+
"description": "Screenshot of an empty echo",
77+
"method": "fileExists",
78+
"show_actual": "always",
79+
"show_message": "always"
80+
},
81+
{
82+
"actual_file": "1.png",
83+
"description": "Screenshot of Submitty in dialog box.",
84+
"method": "fileExists",
85+
"show_actual": "always",
86+
"show_message": "always"
87+
},
88+
{
89+
"actual_file": "2.png",
90+
"description": "Screenshot of echoed Submitty.",
91+
"method": "fileExists",
92+
"show_actual": "always",
93+
"show_message": "always"
94+
}
95+
]
96+
}
97+
]
98+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
from tkinter import *
5+
from tkinter import ttk
6+
7+
8+
def echo(*args):
9+
global displayed_text
10+
try:
11+
displayed_text.set(user_text.get())
12+
except ValueError:
13+
pass
14+
15+
root = Tk()
16+
root.title("Echo Input")
17+
18+
program_window = ttk.Frame(root, padding="3 3 12 12")
19+
program_window.grid(column=0, row=0, sticky=(N, W, E, S))
20+
program_window.columnconfigure(0, weight=1)
21+
program_window.rowconfigure(0, weight=1)
22+
23+
user_text = StringVar()
24+
displayed_text = StringVar()
25+
26+
user_text = ttk.Entry(program_window, width=7, textvariable=user_text)
27+
user_text.grid(column=2, row=1, sticky=(W, E))
28+
29+
#ttk.Label(program_window, textvariable=meters).grid(column=2, row=2, sticky=(W, E))
30+
ttk.Button(program_window, text="Echo", command=echo).grid(column=3, row=3, sticky=W)
31+
32+
ttk.Label(program_window, text="Input").grid(column=3, row=1, sticky=W)
33+
ttk.Label(program_window, text="You Entered: ").grid(column=1, row=2, sticky=E)
34+
label = ttk.Label(program_window, textvar=displayed_text)
35+
label.grid(column=2, row=2, sticky=W)
36+
37+
for child in program_window.winfo_children(): child.grid_configure(padx=5, pady=5)
38+
39+
user_text.focus()
40+
root.bind('<Return>', echo)
41+
42+
root.mainloop()

examples/15_advanced_graphics/config/config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
"title" : "Graphics program 1",
8686
"command" : "./a.out -input sierpinski_triangle.txt -size 400 -iters 0 -cubes",
8787
"actions" : [
88-
"type 'm'",
8988
"click and drag delta 50 -125",
9089
"delay 1",
9190
"screenshot",
Binary file not shown.

0 commit comments

Comments
 (0)