diff --git a/CLI/s-git.py b/CLI/s-git.py index 9c2b514..91047f5 100644 --- a/CLI/s-git.py +++ b/CLI/s-git.py @@ -120,8 +120,6 @@ class Student: print(url) os.system(url) cdir = os.getcwd() - os.mkdir(self.username) - os.chdir(self.username) command('git clone https://github.com/' + self.git + '/' + self.username + '.git') os.chdir(self.username) command('git checkout master') @@ -147,33 +145,38 @@ class Student: } print(putDB(data, self.url)) print("Synced to " + self.username) - + + #update API and Github, all assignments / classes def update(self): + cdir = os.getcwd() + os.chdir(self.username) for c in self.classes: data = getDB("http://127.0.0.1:8000/classes/" + str(c['id'])) - os.chdir(self.username + "/" + data['name']) - command("git checkout -b " + data['name']) + command("git checkout " + data['name']) command("git add " + data['name']) command("git commit -m " + data['name']) - command("git push -u origin " + data['name']) command("git pull origin " + data['name']) + command("git push -u origin " + data['name']) + os.chdir(cdir) for c in self.new: self.addClass(str(c['id'])) + command("git checkout master") #class name format: _ - #add classes from 'new' field def addClass(self, cid): if((cid in self.snew) == False): if((cid in self.sclass) == True): print("Already enrolled in this class.") - else: + return None + if((cid in self.snew) == True): print("Not added by teacher yet.") - return None + return None data = getDB('http://127.0.0.1:8000/classes/'+ str(cid)) + print(os.getcwd()) pwd= input("Enter Github password: ") tgit = getDB("http://127.0.0.1:8000/teachers/" + data['teacher'] + "/")['git'] url= "curl -i -u " + self.git + ":" + pwd + " -X PUT -d '' " + "'https://api.github.com/repos/" + self.git + "/" + self.username + "/collaborators/" + tgit + "'" @@ -199,23 +202,22 @@ class Student: self.sclass = self.sclass + "," + str(data['id']) cdir = os.getcwd() - path1 = self.username + "/" + self.username - path2 = self.username - if(os.path.isdir(path1)): - os.chdir(path1) - else: - os.chdir(self.username) - command("git clone " + self.repo) - os.chdir(self.username) + print(cdir) + # path1 = self.username + "/" + self.username + # path2 = self.username + # if(os.path.isdir(path1)): + # os.chdir(path1) + # else: + # os.chdir(self.username) + # command("git clone " + self.repo) + # os.chdir(self.username) - command("git checkout -b " + data['name']) - command("touch welcome.txt") - command("git add welcome.txt") + os.chdir(self.username) + command("git branch " + data['name']) command("git commit -m initial") command("git push origin " + data['name']) #git clone --single-branch --branch os.chdir(cdir) - shutil.move(path1, self.username + "/" + data['name']) #upddate self.new s="" nar = '' @@ -288,7 +290,29 @@ class Student: 'completed':self.completed } #print(putDB(data, "http://127.0.0.1:8000/students/" + self.username + "/")) + + def viewClass(self, courses): + cdir = os.getcwd() + os.chdir(self.username) + for c in self.classes: + if c['name'] == courses: + print(courses) + command("git checkout " + courses) + print(os.listdir()) + return + os.chdir(cdir) + print("Class not found") + return + + def submit(self, courses): + command("git add .") + command("git commit -m submit") + command("git tag " + parts[1] + "-final") + command("git push -u origin " + self.username + " --tags") -data = getStudent("2022rkhondak") +data = getStudent("2023rumareti") s = Student(data) +s.update() + + #s.update() \ No newline at end of file diff --git a/CLI/t-git.py b/CLI/t-git.py index 84d1d4e..24a534b 100644 --- a/CLI/t-git.py +++ b/CLI/t-git.py @@ -371,33 +371,34 @@ class Teacher: } print(putDB(d, data1['url'])) - #confirmed students - def addStudent(self, student, classes): + #confirmed students + # pull student work and push updates + def updateStudent(self, student, classes): for c in self.classes: if(c['name'] == classes): cid = c['id'] data = getDB("http://127.0.0.1:8000/classes/" + str(cid)) - if(student in data['confirmed']): - print("Student already added to " + classes) - return if(student in data['unconfirmed']): - print("Student has been enrolled in " + classes) + print(student + " has not accepted request to " + classes) return cdir = os.getcwd() cpath = self.username + "/" + classes path = self.username + "/Students/" + classes + spath = self.username + "/Students/" + classes + "/" + student if(os.path.isdir(path) == False): os.makedirs(path) - os.chdir(path) - student = getDB("http://127.0.0.1:8000/students/" + student) - command("git clone " + student['repo']) - os.chdir(cdir) + if(os.path.isdir(spath) == False): + os.chdir(path) + student = getDB("http://127.0.0.1:8000/students/" + student) + command("git clone " + student['repo']) + os.chdir(cdir) copy_tree(cpath, path + "/" + student['ion_user']) os.chdir(self.username + "/Students/" + classes + "/" + student['ion_user']) + command('git checkout ' + classes) + command('git pull origin ' + classes) command('git add .') - command('git checkout -b ' + classes) command('git commit -m Hello') command('git push -u origin ' + classes) @@ -412,7 +413,7 @@ class Teacher: data = getTeacher("mlauerbach") t = Teacher(data) -t.makeClass("Math5_mlauerbach", ["Week1_HW", "Test1"]) -input() -t.reqStudent("2022rkhondak", "Math5_mlauerbach") -t.addStudent("2022rkhondak", "Math5_mlauerbach") +t.reqStudent("2023rumareti", 'Math5_mlauerbach') +t.updateStudent("2023rumareti", 'Math5_mlauerbach') + + diff --git a/sjfrank/APBiology_sjfrank/Lab1/instructions.txt b/sjfrank/APBiology_sjfrank/Lab1/instructions.txt new file mode 100644 index 0000000..e69de29 diff --git a/sjfrank/APBiology_sjfrank/README.md b/sjfrank/APBiology_sjfrank/README.md new file mode 100644 index 0000000..e69de29