Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d7e9c83
Added data
vivaanbhandary Oct 19, 2024
54044d0
created script.py
nazie23 Oct 19, 2024
a746ded
created script.py
nazie23 Oct 19, 2024
3786aee
created token
nazie23 Oct 19, 2024
de3e330
Started objection
vivaanbhandary Oct 19, 2024
68b53b9
Merge branch 'main' of https://github.com/nazie23/hack-la-2024
vivaanbhandary Oct 19, 2024
7ab95d0
read txt file
nikipdsci Oct 19, 2024
1ffd209
Merge remote-tracking branch 'origin/main'
nikipdsci Oct 19, 2024
7046252
comments
nikipdsci Oct 19, 2024
3d0eca6
fixed input username!
nazie23 Oct 19, 2024
8562d05
fixed input username!
nazie23 Oct 19, 2024
534c382
Update submission.md
nazie23 Oct 19, 2024
7a557ef
Update submission.md
nazie23 Oct 19, 2024
5cf6fbb
tets
vivaanbhandary Oct 19, 2024
f888bf6
tets
vivaanbhandary Oct 19, 2024
d3b5015
new
vivaanbhandary Oct 19, 2024
e743c89
fixed arguments!
nazie23 Oct 19, 2024
ffc5b6b
Merge remote-tracking branch 'origin/main'
nazie23 Oct 19, 2024
9f4a1be
fixed arguments!
nazie23 Oct 19, 2024
afb4b10
discussion objects
nikipdsci Oct 19, 2024
d64e4b8
Merge remote-tracking branch 'origin/main'
nikipdsci Oct 19, 2024
d225116
added discussion spectater and initializer
vivaanbhandary Oct 19, 2024
0658d6a
changed character woo!!!!
nazie23 Oct 19, 2024
5e6acb8
Merge remote-tracking branch 'origin/main'
nazie23 Oct 19, 2024
ac6bbed
added spectator
vivaanbhandary Oct 19, 2024
1c31040
merged
vivaanbhandary Oct 19, 2024
7f085c0
discussion replies now actually work
nazie23 Oct 19, 2024
ea747ef
Merge remote-tracking branch 'origin/main'
nazie23 Oct 19, 2024
29848eb
animations
vivaanbhandary Oct 19, 2024
67d948f
apostrophe
vivaanbhandary Oct 19, 2024
8c27c03
discussion replies now actually work
nazie23 Oct 19, 2024
73bdc73
discussion replies now actually work
nazie23 Oct 19, 2024
aa8e180
Merge remote-tracking branch 'origin/main'
nazie23 Oct 19, 2024
18414f9
Update submission.md
nazie23 Oct 20, 2024
38b1c91
Update submission.md
nazie23 Oct 20, 2024
38d4599
Update submission.md
nazie23 Oct 20, 2024
59d5d1d
Update submission.md
nazie23 Oct 20, 2024
af37639
Update submission.md
nazie23 Oct 20, 2024
1e8fa47
Update submission.md
nazie23 Oct 20, 2024
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
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/hack-la-2024.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Discussion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Discussion:
def __init__(self, title, user1, user2):
self.title = title
self.user1 = user1
self.user2 = user2

Binary file added __pycache__/script.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file added chromedriver.exe
Binary file not shown.
8 changes: 8 additions & 0 deletions objection/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions objection/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions objection/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions objection/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions objection/.idea/objection.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions objection/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# open banksy.json: https://www.w3schools.com/python/python_json.asp
# read
# add info to Discussion object

import json

banksy = open("bonus-hackathon-data/bonus-hackathon-data/hack-la-24-banksy-discussions.json",'r')
data = json.load(banksy)

class Discussion:
def __init__(self):
self.title = None
self.user1 = None
self.user2 = None
self.messages = []

def add_title(self, title):
self.title = title

def add_message(self, message):
self.messages.append(message)

def add_user(self, user):
if self.user1 is None:
self.user1 = user
elif self.user2 is None and user != self.user1:
self.user2 = user

def print_messages(self):
for msg in self.messages:
print(msg)

def get_user1(self):
return self.user1

def get_user2(self):
return self.user2

def get_title(self):
return self.title

def get_messages(self):
return self.messages


discussion_array = []

for discussions in data:
discussion_data = discussions['discussion_topic']

discussion = Discussion()

discussion.add_title(discussion_data['title'])
discussion.add_user(discussion_data['user_name'])
discussion.add_message(discussion_data['message'])

for reply in discussion_data['replies']:
discussion.add_user(reply['user_name'])
discussion.add_message(reply['message'])

discussion_array.append(discussion)

for i in discussion_array:
print(f"User 1: {i.user1}")
print(f"User 2: {i.user2}")
i.print_messages()
9 changes: 6 additions & 3 deletions submission.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
- "submit" your work by forking the repo (see README), and make a pull request with your final submission including an update of this submission.md file.

List your group members:
> Your Group Members
> Nazia, Vivaan, Nikita

# This Project
> Link to presentation:
> Give a brief description of the final product:
> Link to presentation:
> <br>Give a brief description of the final product: A project designed to take mundane Canvas discussions and turn them into engaging animations!

# Reflection
## Approach
> What was your approach to the dataset? What problem did you want to solve? What technology did you decide to use? How did your team split the work?
> <br><br>We used the sample json file provided as a basis for the information that could be extracted from Canvas. We wanted to make tedious and mundane discussions much more lively and engaging for students to read and interact with. We decided to use Python, specifically the library Selenium and JSON. We split the work evenly, working on different aspects of our project at the same time and using Git to deal with merge conflicts.

## Wins / Challenges
> Describe some wins / challenges. What did you learn? What would you do differently next time?
> <br><br>We successfully got the website to automatically begin an animated debate to do with one of the discussions provided about Banksy. The characters in the animation were dynamic and aimed to captivate the spectator and ensure they remember the information delivered. We learned to use Python to manipulate and use a website programmatically. This naturally extends to the skill of frontend testing, which uses the same library. If we had more time, we would have extended the project to work with any number of people in a discussion. We would have also added a GUI to make the tool more user-friendly and added customizable features such as text speed and more animations.


162 changes: 162 additions & 0 deletions tryObj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

import script
from script import Discussion
import time
import random


# Set up your WebDriver (Chrome in this example)
driver_path = "chromedriver.exe" # Ensure you have the correct path to your ChromeDriver
service = Service(driver_path) # Create a Service object
options = Options()

def new_discussion_spectate(discussiontitle, driver):
driver.get('https://objection.lol/courtroom')
driver.implicitly_wait(10)

text_input = driver.find_element(by=By.XPATH,
value='/html/body/div/div[1]/div[2]/main/div/div/form/div[1]/div[1]/div/div/div/div/input')
text_input.send_keys("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b")
text_input.send_keys(discussiontitle)

text_input = driver.find_element(by=By.XPATH,
value='/html/body/div/div[1]/div[2]/main/div/div/form/div[2]/div[2]/div/div/div/div[1]/input')

discussion_code = text_input.get_attribute('value')
print(discussion_code)

submit_button = driver.find_element(by=By.XPATH, value='/html/body/div/div[1]/div[2]/main/div/div/form/div[4]/div/button')
submit_button.click()

spectate_button = driver.find_element(by=By.XPATH,
value='/html/body/div/div[3]/div/div/form/div[3]/button[1]')
spectate_button.click()

return discussion_code
def post_user1(user, disc_code, driver):
driver.get('https://objection.lol/courtroom/' + disc_code)
driver.implicitly_wait(10)

# Find and interact with the text input (example selector, modify as needed)
# text_input = driver.find_element("id", "input-631")
text_input = driver.find_element(by=By.XPATH,
value='/html/body/div/div[3]/div/div/form/div[2]/div/div/div/div/div[1]/div/input')

# Enter the argument
# text_input.send_keys(argument)
text_input.send_keys(user)

# Simulate pressing "Enter" or clicking a button to submit (modify selector as needed)
submit_button = driver.find_element(By.CSS_SELECTOR, '#app > div.v-dialog__content.v-dialog__content--active > div > div > form > div.v-card__actions > button:nth-child(3) > span')
submit_button.click()
def post_user2(user, disc_code, driver):
driver.get('https://objection.lol/courtroom/' + disc_code)
driver.implicitly_wait(10)

# Find and interact with the text input (example selector, modify as needed)
# text_input = driver.find_element("id", "input-631")
text_input = driver.find_element(by=By.XPATH,
value='/html/body/div/div[3]/div/div/form/div[2]/div/div/div/div/div[1]/div/input')

# Enter the argument
# text_input.send_keys(argument)
text_input.send_keys(user)

# Simulate pressing "Enter" or clicking a button to submit (modify selector as needed)
submit_button = driver.find_element(By.CSS_SELECTOR, '#app > div.v-dialog__content.v-dialog__content--active > div > div > form > div.v-card__actions > button:nth-child(3) > span')
submit_button.click()

characterChoice = driver.find_element(by=By.XPATH, value='/html/body/div/div[2]/div[2]/main/div/div/div[1]/div[1]/div/div[2]/div[1]/div/div[3]')
characterChoice.click()
driver.implicitly_wait(10)
character = driver.find_element(By.CSS_SELECTOR, value='#app > div.v-dialog__content.v-dialog__content--active > div > div > div > div.d-flex.flex-wrap.mt-4 > div:nth-child(2)')
character.click()

def normal(driver):
face_input = driver.find_element(by=By.XPATH,
value='/html/body/div/div[2]/div[2]/main/div/div/div[1]/div[1]/div/div[2]/div[2]/div/div/div[1]/div[1]/div/img')
face_input.click()

def desk(driver):
face_input = driver.find_element(by=By.XPATH,
value='/html/body/div/div[2]/div[2]/main/div/div/div[1]/div[1]/div/div[2]/div[2]/div/div/div[1]/div[2]/div/img')
face_input.click()

def point(driver):
face_input = driver.find_element(by=By.XPATH,
value='/html/body/div/div[2]/div[2]/main/div/div/div[1]/div[1]/div/div[2]/div[2]/div/div/div[1]/div[3]/div/img')
face_input.click()

# Function to open an instance of objection.lol and post an argument
def post_argument(argument, driver):
# driver.get('https://objection.lol/courtroom/3792uz')
driver.implicitly_wait(20)

# Find and interact with the text input (example selector, modify as needed)
# text_input = driver.find_element("id", "input-631")

random_number = random.choice([1, 2, 3])

if random_number == 1:
normal(driver)
elif random_number == 2:
desk(driver)
else:
point(driver)

text_input = driver.find_element(by=By.XPATH, value='/html/body/div/div[2]/div[2]/main/div/div/div[1]/div[1]/div/div[3]/div[2]/div/div[2]/textarea')
text_input.click()

# Enter the argument
# text_input.send_keys(argument)
text_input.send_keys(argument)

# Simulate pressing "Enter" or clicking a button to submit (modify selector as needed)

submit_button = driver.find_element(By.CSS_SELECTOR, '#app > div.v-application--wrap > div.container.pa-0.pa-lg-2.container--fluid > main > div > div > div.row.no-gutters > div:nth-child(1) > div > div:nth-child(4) > div:nth-child(2) > div > div > div:nth-child(2) > div > div.pl-1 > button')
submit_button.click()


# Open two instances of Chrome with different options if needed

driver1 = webdriver.Chrome()
driver2 = webdriver.Chrome()
driver0 = webdriver.Chrome()

driver0.maximize_window()


# Post users and arguments from the course discussion
discussion = script.discussion_array[0]
user1 = discussion.get_user1()
user2 = discussion.get_user2()
discussiontitle = discussion.get_title()

disc_code = new_discussion_spectate(discussiontitle, driver0)
post_user1(user1, disc_code, driver1)
post_user2(user2, disc_code, driver2)

for i in range(0, len(discussion.get_messages()) - 1):
if i % 2 == 0:
post_argument(discussion.get_messages()[i], driver1) # Argument 1 posted in browser 1
else:
post_argument(discussion.get_messages()[i], driver2) # Argument 2 posted in browser 2

time.sleep(5) # Adding delay for timing (adjust as needed)


# Add more interactions if necessary, or let the drivers stay open to watch the results

# To keep the browsers open:
time.sleep(300) # Adjust the time to keep the browser open before closing

# Close the browser windows when done
driver0.quit()

driver1.quit()
driver2.quit()