def acknowledgeBehaviours(students: dict) -> None: openListOfStudents() for _, (k, v) in progressBar(students.items(), prefix='Applying behaviours:', suffix='behaviours applied.', length=20): giveFeedback(k, v['positive'], v['behaviour'])
def getSubmissionFiles(submissions: list): # if not os.path.isdir(f'{submissions[0].courseAcr}{submissions[0].assignment}' os.makedirs(f'{submissions[0].courseAcr} {submissions[0].assignment}', exist_ok=True) for _, sub in progressBar(submissions, prefix = 'Downloading files:', suffix = 'files downloaded.', length = 20): if not sub.address: continue downloadFiles(sub)
def repairDefective(outliers: list): for _, k in progressBar(outliers, prefix = 'Repairing outliers:', suffix = 'outlying assessments\' weights set to 0.', length = 20): DRIVER.get(k) try: Select(DRIVER.find_element_by_id("id_weight")).select_by_value("0") DRIVER.find_element_by_id("id_feedbackreviewer_editoreditable").send_keys( "Težinska vrijednost ocjene postavljena je na 0 zato što dodijeljena ocjena previše odskače od ostalih procjena iste zadaće." ) except Exception as e: pass DRIVER.find_element_by_id("id_save").click()
def readQuestFeedback(students: dict) -> list: feedback = students e = findElementXpath( '//table[@class="ObjectiveProgressTableWrapper"]/tbody/tr', single=False) for _, aFeedback in progressBar(e, prefix='Getting assignment status:', suffix='assignment statuses collected.', length=20): student = aFeedback.find_element_by_xpath('./td[1]/span').text try: state = aFeedback.find_element_by_xpath( './/div/label[2]').get_attribute('class') if "selected" in state: feedback[student] = {'positive': False, 'behaviour': 9} continue except Exception as ex: pass try: state = aFeedback.find_element_by_xpath('.//td/div').get_attribute( "class") if "dot late" in state: feedback[student] = {'positive': False, 'behaviour': 2} elif "dot timely" in state or "dot early" in state: feedback[student] = {'positive': True, 'behaviour': 3} except Exception as ex: continue # print(feedback) return feedback
def getSubmissionBasic(): rows = DRIVER.find_elements_by_xpath( '//table[contains(@class, "grading-report")]/tbody/tr' ) course = DRIVER.find_element_by_xpath( '//*[@id="page-header"]//h1' ).text courseAcr = DRIVER.find_element_by_xpath( f'//*[@id="page-navbar"]//a[@title="{course}"]' ).text assignment = DRIVER.find_element_by_xpath( '//*[@id="region-main"]//h2[1]' ).text submissions = [] total = len(rows) for _, row in progressBar(rows, prefix = 'Getting info:', suffix = 'info on submissions collected.', length = 20): try: student = row.find_element_by_xpath( './/td[contains(@class,"participant")]//span' ).text submissions.append(Submission(student=student)) submissions[-1].course = course submissions[-1].courseAcr = courseAcr submissions[-1].assignment = assignment except: pass try: received = row.find_element_by_xpath( './td[contains(@class, "receivedgrade")][./div[@class="assessmentdetails"]]' ) try: mark = int(received.find_element_by_xpath( './/span[@class="grade"]' ).text) except Exception as e: mark = None student = received.find_element_by_xpath( './/span[@class="fullname"]' ).text link = received.find_element_by_xpath( './/a[@class="grade"]' ).get_attribute("href") submissions[-1].addAssessment(student, mark, link) except Exception as e: pass try: given = row.find_element_by_xpath( './td[contains(@class, "givengrade")][./div[@class="assessmentdetails"]]' ) try: mark = int(given.find_element_by_xpath( './/span[@class="grade"]' ).text) except Exception as e: mark = None student = given.find_element_by_xpath( './/span[@class="fullname"]' ).text link = given.find_element_by_xpath( './/a[@class="grade"]' ).get_attribute("href") submissions[-1].addAssessment(student, mark, link, given=True) except Exception as e: pass try: link = row.find_element_by_xpath( './/td[contains(@class,"submission")]/a' ).get_attribute("href") submissions[-1].address = link except Exception as e: continue try: mark = row.find_element_by_xpath( './/td[contains(@class, "submissiongrade")]' ) try: markIn = int(mark.text) except Exception as e: markIn = int(mark.find_element_by_xpath('./ins').text) markInOld = int(mark.find_element_by_xpath('./del').text) submissions[-1].markInOld = markInOld submissions[-1].markIn = markIn submissions[-1].markSum = markIn except Exception as e: # markIn = None # markOut = None continue try: markOut = int(row.find_element_by_xpath( './/td[contains(@class, "gradinggrade")]' ).text) submissions[-1].markOut = markOut submissions[-1].markSum += markOut except Exception as e: # markOut = None pass return submissions
def fetchStudentInfo(): students = {} openListOfTeams() data = findElementXpath('//div[@class="teacherDashboard_teamWrapper"]', False) for _, entry in progressBar(data, prefix='Getting student info:', suffix='student stats collected.', length=20): entry.location_once_scrolled_into_view teamName = entry.find_element_by_xpath( './/div[@class="teamName"]').text for student in entry.find_elements_by_xpath( './/tr[@class="playerContainer"]'): student.location_once_scrolled_into_view try: studentName = student.find_element_by_xpath( './/td[@class="nameWrapper"]').text stats = student.find_elements_by_xpath( './/span[@class="current"]') except Exception as ex: pass try: studentLevel = int( student.find_element_by_xpath('.//td[6]').text) except Exception as ex: studentLevel = None try: studentClass = student.find_element_by_xpath( './/td[@class="classWrapper"]').text except Exception as ex: studentClass = None if not stats: students.update({studentName: None}) continue students.update({ studentName: { 'team': teamName, 'stats': { 'hp': int(stats[0].text.replace(" ", "")), 'ap': int(stats[1].text.replace(" ", "")), 'xp': int(stats[2].text.replace(" ", "")), 'gp': int(stats[3].text.replace(" ", "")) }, 'lvl': studentLevel, 'avatarClass': studentClass } }) students.update({ 'course': getCourseName(), 'time': datetime.datetime.now().strftime("%Y-%m-%d %H:%M") }) with open( f'{getCourseName().replace("/","-")} :: stats - {datetime.datetime.now().strftime("%Y-%m-%d %H:%M")}.json', "w", encoding='utf8') as jsonFile: json.dump(students, jsonFile, ensure_ascii=False) return students