student submissions failed

This commit is contained in:
Raffu Khondaker 2020-06-16 19:43:26 -04:00
parent 4123423dab
commit 401fbaaee9
4 changed files with 61 additions and 8 deletions

View File

@ -112,6 +112,7 @@ class Student:
self.completed = data['completed'] self.completed = data['completed']
self.user = data['user'] self.user = data['user']
self.password = password self.password = password
self.completed = data['completed']
# classes in id form (Example: 4,5) # classes in id form (Example: 4,5)
# storing actual classes # storing actual classes
cid = data['classes'].split(",") cid = data['classes'].split(",")
@ -385,12 +386,13 @@ class Student:
command("git add .") command("git add .")
command("git commit -m update") command("git commit -m update")
command('git checkout ' + course) command('git checkout ' + course)
time.sleep(5)
ass = os.listdir() ass = os.listdir()
oname = ''
inclass = False inclass = False
for a in ass: for a in ass:
if a == assignment: if a in assignment:
inclass = True inclass = True
oname = a + "_" + course
break break
if (inclass == False): if (inclass == False):
print(assignment + " not an assignment of " + course) print(assignment + " not an assignment of " + course)
@ -404,6 +406,11 @@ class Student:
command("git tag " + assignment + "-final") command("git tag " + assignment + "-final")
command("git push -u origin " + course + " --tags") command("git push -u origin " + course + " --tags")
command('git checkout master') command('git checkout master')
self.completed = oname + "," + self.completed
data = {
'completed': self.completed
}
patchDB(self.username, self.password, data, self.url)
os.chdir(cdir) os.chdir(cdir)

View File

@ -604,7 +604,7 @@ class Teacher:
# pull student's work, no modifications # pull student's work, no modifications
def getStudents(self, course): def getStudents(self, course):
if not (course in self.sclass): if not (course in str(self.classes)):
print(course + " not a class.") print(course + " not a class.")
return return
path = self.username + "/Students/" + course path = self.username + "/Students/" + course
@ -697,7 +697,7 @@ class Teacher:
# 'classes':course # 'classes':course
# } # }
log = self.getCommits(student, course, 30) log = self.getCommits(student, course, 30)
assignment['due_date'] = datetime.strptime(assignment['due_date'], '%Y-%m-%d %H:%M:%S.%f') assignment['due_date'] = datetime.strptime(assignment['due_date'], '%Y-%m-%dT%H:%M:%S.%fZ')
late = False late = False
cdir = os.getcwd() cdir = os.getcwd()
os.chdir(self.username + "/Students/" + course + "/" + student) os.chdir(self.username + "/Students/" + course + "/" + student)

View File

@ -121,7 +121,7 @@ def chooseClassStudent(student):
def classOptionsStudent(student, course): def classOptionsStudent(student, course):
student.viewClass(course) student.viewClass(course)
student.getAssignments(course, 100) student.getAssignments(course, 100)
choices = ["Save","Back","Exit SkoolOS"] choices = ["Save","Submit assignment","Back","Exit SkoolOS"]
options = [ options = [
{ {
'type': 'list', 'type': 'list',
@ -143,6 +143,33 @@ def classOptionsStudent(student, course):
student.exitCLI() student.exitCLI()
#exit cli #exit cli
return True return True
if(option == "Submit assignment"):
assignments = os.listdir(student.username)
tlist = []
b = True
for a in assignments:
oname = a + "_" + course
a = student.username + "/" + a
if(os.path.isdir(a) and not "." in a and not oname in student.completed):
tlist.append(a)
assignments = tlist
assignments.append("Back")
print(assignments)
options = [
{
'type': 'list',
'name': 'submit',
'choices':assignments,
'message': 'Select: ',
},
]
ass = prompt(options)['submit']
if(ass == "Back"):
return False
else:
student.submit(course, ass)
return False
#################################################################################################### TEACHER METHODS #################################################################################################### TEACHER METHODS
@ -166,6 +193,8 @@ def teacherCLI(user, password):
EXIT = makeClassTeacher(teacher) EXIT = makeClassTeacher(teacher)
#selected a class #selected a class
else: else:
#Pull confirmed students directory
teacher.getStudents(course)
option = classOptionsTeacher(teacher, course) option = classOptionsTeacher(teacher, course)
if(option == '1'): if(option == '1'):
EXIT = addStudentsTeacher(teacher, course) EXIT = addStudentsTeacher(teacher, course)
@ -362,13 +391,30 @@ def viewStudentsTeacher(teacher, course):
for s in unconf: for s in unconf:
print(s) print(s)
student = input("View student (Enter student's ion username): ") student = input("View student (Enter student's ion username): ")
while((not student in str(data['confirmed'])) or (not student in str(data['unconfirmed']))): while((not student in str(data['confirmed'])) and (not student in str(data['unconfirmed']))):
print("Student not affiliated with class") print("Student not affiliated with class")
student = input("View student ('N' to exit): ") student = input("View student ('N' to exit): ")
if student == 'N': if student == 'N':
return True return False
print(getDB(teacher.username, teacher.password, "http://127.0.0.1:8000/api/students/" + student + "/")) sinfo = getDB(teacher.username, teacher.password, "http://127.0.0.1:8000/api/students/" + student + "/")
pprint.pprint(sinfo)
print("Confirmed: " + str(student in str(data['confirmed'])))
if(student in str(data['confirmed'])):
path = teacher.username + "/Students/" + course + "/" + student
print(student + "'s work: " + path)
fin = sinfo['completed'].split(",")
alist = []
for f in fin:
if(course in f):
late = teacher.afterSubmit(course, f, student)
if(late):
s = f.split("_")[0] + " (LATE)"
else:
s = f.split("_")[0]
alist.append(s)
print("Has submitted: " + str(alist))
#put log stuff
############################################################################################################################################ ############################################################################################################################################