def resursive_solve(self, assignment): if self.problem.is_satisfied(assignment.assignments): return assignment index, variable = self.unassigned_variable(assignment) if variable is None: print("Leaf") return None values = self.get_variable_domain(variable) for value in values: new_assignment = Assignment([]) new_assignment.fill_from_another(assignment.assignments) new_assignment.assignments[index].value = value # new_assignment.show() self.problem.restrict_domains_for_unassigned( new_assignment.assignments, index) if new_assignment.has_empty_domain(): return None if not self.problem.check_constraints( new_assignment.assignments[index], new_assignment.assignments): continue new_assignment = self.resursive_solve(new_assignment) if new_assignment is not None: return new_assignment return None
def get_agenda(self, echo): self.agenda = echo.get_agenda(self.data['course_name']) self.agenda['assignment_type'] = Notifier.NOTIFYTYPES["AGENDA_UPDATE"] title = self.agenda['title'] # skip when problem getting agenda, or no new agenda if title not in ['Loading...', 'No agenda']: self.assignments += [Assignment(self, self.agenda)]
if idx + 1 < len(res): a = "up" s = res[idx].get("score") d = res[idx].get("score") - res[idx + 1].get("score") if d < 0: a = "down" msg = "grade in {} is {}, it has gone {} by {}%".format( res[idx].get("course_name"), s, a, abs(d)) sms.send(msg, ndata['notification_sms']) elif notify_type == 3: sms.send("EchoAlert: Course has been updated", ndata['notification_sms']) elif notify_type == 4 or notify_type == 2: res = Assignment.get_assignments_after(ndata['account_id'], ndata['created_ts']) for idx in xrange(0, len(res)): title = res[idx].get("title") atype = res[idx].get("assignment_type") if atype == 4 and len(title) > 64: title = title[0:64].strip() if "Past Due" in res[idx].get("due"): pass #msg = """{}:\n{}\n{}...""".format( res[idx].get("course_name"),res[idx].get("due"),title) #sms.send(msg,ndata['notification_sms']) else: if atype == 2: atypestr = "Todo" else:
def get_assets(self, echo): self.assets = echo.get_course_assets(self.data['course_name']) for asset in self.assets: asset['assignment_type'] = Notifier.NOTIFYTYPES["ASSET_UPDATE"] self.assignments += [Assignment(self, asset)]
def get_todos(self, echo): self.todos = echo.get_course_todos(self.data['course_name']) for todo in self.todos: todo['assignment_type'] = Notifier.NOTIFYTYPES["TODO_UPDATE"] self.assignments += [Assignment(self, todo)]
def start(self): return Assignment(self.variables)