mirror of
https://github.com/Code-For-Groningen/temmies.git
synced 2025-07-05 12:44:58 +02:00
Formatted, debugging. Added exception.
This commit is contained in:
@ -1,25 +1,30 @@
|
||||
# Module to handle each assignment (most difficult part)
|
||||
|
||||
from Course import Course
|
||||
from File import File
|
||||
from Submission import Submission
|
||||
from Downloadable import Downloadable
|
||||
from Base import Base
|
||||
from Exercise import Exercise
|
||||
from requests import Session
|
||||
|
||||
class Assignment(Base):
|
||||
def __init__(self, url:str, name:str, session:Session, parent:Course):
|
||||
def __init__(self, url:str, name:str, session:Session, parent):
|
||||
super().__init__()
|
||||
self.files = self.files
|
||||
self.download = Downloadable(url, name, session, self)
|
||||
|
||||
def __str__(self):
|
||||
return f"Assignment {self.name} in course {self.parent.name}"
|
||||
return f"Assignment {self.name} in course {self.parent.name}"
|
||||
|
||||
|
||||
def getSubmissions(self) -> Submission:
|
||||
pass
|
||||
def getExercises(self) -> list[Exercise]:
|
||||
# Find li large
|
||||
ul = self.soup.find('ul', class_='round')
|
||||
|
||||
def getExercises(self) -> list[Excercise]:
|
||||
pass
|
||||
# Turn each li to an exercise instance
|
||||
return self.liLargeToExercises(ul, self.session, self)
|
||||
|
||||
def getExercise(self, name:str) -> Exercise:
|
||||
pass
|
||||
# Get the exercise
|
||||
r = self.session.get(self.url)
|
||||
soup = BeautifulSoup(r.text, 'lxml')
|
||||
# Search by name
|
||||
exercise = soup.find('a', text=name)
|
||||
# Get the url and transform it into an exercise object
|
||||
return Exercise(url=exercise['href'], name=name, session=self.session, assignment=self)
|
Reference in New Issue
Block a user