Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove remaining cheat-related stuff #70

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions sliders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ def play_game(player: Player, message: dict):
)
}

if message_type == "cheat" and settings.DEBUG:
return {
my_id: dict(
type="solution",
solution={s.idx: s.target for s in Slider.filter(puzzle=puzzle)},
)
}

raise RuntimeError("unrecognized message from client")


Expand Down
14 changes: 0 additions & 14 deletions sliders/static/sliders.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ class Controller {
case 'feedback':
this.recvFeedback(message);
break;

case 'solution':
this.cheat(message.solution);
break;
}

if ('progress' in message) { // can be added to message of any type
Expand Down Expand Up @@ -270,16 +266,6 @@ class Controller {
endGame() {
document.getElementById("form").submit();
}

cheat(values) {
let i = 0, cnt=Object.keys(values).length;
let timer = window.setInterval(() => {
this.model.sliders[i].value = values[i];
this.submitSlider(i);
i++;
if (i == cnt) window.clearInterval(timer);
}, js_vars.params.retry_delay * 1000 + 100);
}
}

window.onload = (event) => {
Expand Down
8 changes: 0 additions & 8 deletions sliders/static/sliders_cheating.js

This file was deleted.

14 changes: 0 additions & 14 deletions sliders/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time
from contextlib import contextmanager

from otree import settings
from otree.api import Bot, Submission, expect

from . import Game, Puzzle, Results, Slider
Expand Down Expand Up @@ -176,9 +175,6 @@ def call_live_method(method, group, case, **kwargs): # noqa
print(" - testing skipping")
test_skipping(method, player, puzzle, current_slider, num_correct)

print(" - testing cheating")
test_cheat_nodebug(method, player)


def test_unsuccessful_attempt(method, player, puzzle, slider, num_correct):
target = get_target(puzzle, slider)
Expand Down Expand Up @@ -308,13 +304,3 @@ def test_skipping(method, player, puzzle, slider, num_correct):
expect_puzzle(
get_last_puzzle(player), iteration=1, num_correct=num_correct, is_solved=False
)


def test_cheat_nodebug(method, player):
debug_old = settings.DEBUG
settings.DEBUG = False

with expect_failure(RuntimeError):
send(method, player, "cheat")

settings.DEBUG = debug_old
Loading