Skip to content

Actions#1077

Merged
bmcutler merged 43 commits intomasterfrom
Actions
Jun 26, 2017
Merged

Actions#1077
bmcutler merged 43 commits intomasterfrom
Actions

Conversation

@emaicus
Copy link
Contributor

@emaicus emaicus commented Jun 19, 2017

Closes #1000

Brief: Adds support for scripted keyboard and mouse interaction, screenshots, and delays for use in interactive programs. While developing, some modifications were made to execute.cpp, maincompile.cpp, etc. but most major changes take place in the added window_utils.cpp file. I have added documentation on Submitty.org under the Assignment Configuration heading (the section is called Types of Action) which specifies the interactions I have implemented and the commands needed to utilize them.

Breakdown:
When the execute function in execute.cpp is called, the first thing that happens is a check if the instructor has specified any actions. If they have, we assume that a window will be created to use them on. The process forks as it did before, with the child running the student's code. The parent, however, begins looking for the expected window every 1/10th second (only if a window is expected, 1/10th second was the value specified before, and all memory/time checks on the student's program are still in place). If the window is found (for now, if a window is spawned with a pid matching the child's), the program begins taking actions, one every 1/10th second. While there are still actions to take, the execute function calls the takeAction function in window_utils.cpp, which routes the provided command to the proper function (e.g., if the next action is a delay of the form "delay 4", the takeAction function will parse it and forward it to the delay function). If a delay is invoked, it is broken into 1/10th second portions, with memory and time checks performed when appropriate (per the previous implementation of execute). Before any action is taken, a check is performed to see if the student's window still exists. if it does, the mouse is centered on the student's window and the window is brought into focus before the action is taken. If the student's window has failed, the action is not taken. All mouse commands should be clamped to within the student's window minus a one pixel boundary, meaning that unless the mouse is physically manipulated, it should not be able to leave the student's window and interact with the pc.

Known Issues:

  1. Programs involving actions should be run sequentially, as more than one program can not manipulate the mouse or keyboard concurrently. However, merging this code should not have any effect on the ability of standard programs to execute in parallel.
  2. In order to allow untrusted users to access the screen, the command: xhost +SI:localuser:USER must be run, where USER is replaced by the desired user.

emaicus and others added 30 commits May 31, 2017 15:10
…tils

Author:   Evan Maicus <emaicus@outlook.com>
* add sorting options for labs, default viewing options for labs

* sorting for registration and rotation grading

* sort by more than just id
* Looks better when there are zero numeric fields

* Looks better when there are zero numeric fields
…ructor has grading (#1026)

* add sorting options for labs, default viewing options for labs

* sorting for registration and rotation grading

* sort by more than just id

* changed function names

* now user id not left aligned

* remove unneeded code
* Added a row for total points.

* total row is functional

* is updated when you make a gradeable from a template

* made suggested changes and fixed a typo.

* all updates made

* corrected some unnecessary changes
…rmissions (#1030)

* just starting

* progress

* a bit more

* edits to check_everything script

* more checks

* change requests

* rearrange logic

* add to travis after_script
* Penalty, extra, and normal credit look diffirent now

* Extra credit and penalty have colors and icons

* The icons are now on the left
* Added checks for the form for the user

* updated with requested changes

* updated with requested changes
…ms (#1050)

replace 'assignment' with 'gradeable' in grade_students.sh (improves consistency)

better error message for attempted use of system programs that are not on the whitelist

now scrapes the config.json for names of compiled_executables to improve the check for local programs

if the config.json uses an unacceptable local, now it complains at BUILD time (not delaying to submission debugging as before)

fix autograding test failures

disabled seccomp because it's broken :( will make a new issue & fix that next, in a new PR #1051.
…tils

Author:   Evan Maicus <emaicus@outlook.com>
@bmcutler bmcutler self-requested a review June 20, 2017 13:31
Copy link
Member

@bmcutler bmcutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments place to the right of code are harder to read, and if they are long, they wrap badly with narrower displays. Please put most of these comments above the code, on a line without code.


// for graphics/window interaction
{ "scrot", "/usr/bin/scrot"},
{ "xdotool", "/usr/bin/xdotool"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

bool window_mode = false; //Tells us if the process is expected to spawn a window. (additional support later)

if(actions.size() > 0){ //right now, we assume if there are actions, there will be a window.
std::cout << "Recieved " << actions.size() << " actions" << std::endl; //useful debug line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling


/*
* At the moment, this method finds any window names associated with the child's pid. This works fine.
* However, it is concieveable that the child could fork/generate a window with its own pid. In this case
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

continue;
}

if(std::regex_match(window, match, regex)){ //get the third collumn (the pid, view example output above)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

}
}

if(!found) //we are inside of the box (gauranteed by clamp) so move
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

@bmcutler
Copy link
Member

Also, please pull master & fix merge conflicts & re-test w/ graphics & non graphics programs.

{ "xdotool", "/usr/bin/xdotool"}
{ "scrot", "/usr/bin/scrot"}, //screenshot utility
{ "xdotool", "/usr/bin/xdotool"}, //keyboard/mouse input
{ "xdotool", "/usr/bin/wmctrl"}, //bring window into focus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo? repeated program name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I just pushed an update.

@bmcutler bmcutler merged commit 427ae29 into master Jun 26, 2017
@bmcutler bmcutler deleted the Actions branch June 26, 2017 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants