def assignmentList(links): assignments = [] for link in links: a = assignment(link, driver) assignments.append(a) # print(assignments) return assignments
def listassignments(): if checkSession(2): return redirect("/") session['lastPage'] = '' session['currentPage'] = "/assignments" print session['lastPage'] print session['currentPage'] a = assignment() dmsg = '' if request.args.get('delete') in a.getListOfIds(): id = request.args.get('delete') a.deleteById(id) dmsg = "Assignment has been deleted" html = ''' <p style="color: green">''' + dmsg + '''</p> <table style='width: 100%;' id='user_table'> <tr align="center" style="background-color: #2EB4ED; color: #EAEAEA; font-size: 1.13em"> <td><b>Assignment</b></td> <td><b>Project</b></td> <td><b>Assigned To</b></td> <td><b>Status</b></td> <td><b>Due Date</b></td> </tr>''' a.getAll("status ASC") if len(a.data) == 0: html = '''<p style="color: green">''' + dmsg + '''</p> <p>There are no assignments to display</p>''' else: i = 0 for row in a.data: c = "#2EB4ED" if i % 2 == 0: c = "#016C9B" html += ''' <tr align="center" style="color: #EAEAEA; background-color:''' + c + '''"> <td><a href="/assignment/''' + str(row['id']) +'''">''' + str(row['title']) + ''' </a></td> <td><a href="/project/''' + str(row['project']) + '''">''' + str(a.returnProjectName(row['project'])) + '''</a></td> <td><a href="/user/''' + str(row['assignedTo']) + '''">''' + str(a.returnUserName(row['assignedTo'])) + '''</a></td> <td>''' + a.returnStatus(str(row['status'])) +'''</td> <td>''' + str(row['dueDate']) +'''</td> </tr>''' i += 1 html += ''' </table> ''' return header() + html + footer()
def parseFolder( dirPath ): assignments = {} draftReader = PlaintextCorpusReader(dirPath, '\d+draft\d*.*') finalReader = PlaintextCorpusReader(dirPath, '\d+final\d*.*') numFiles = len( os.listdir( dirPath )) assert numFiles % 2 == 0 finalIdsSortedList = finalReader.fileids() draftIdsSortedList = draftReader.fileids() for pid in finalReader.fileids(): final = finalReader.paras( pid ) #finalIdsSortedList[i] ) draft = draftReader.paras( pid ) #draftIdsSortedList[i] ) assn = assignment( draft, final ) assignments[pid] = assn return assignments
def parseFolder( dirPath ): assignments = [] draftReader = PlaintextCorpusReader(dirPath, '\d+draft\d*.*') finalReader = PlaintextCorpusReader(dirPath, '\d+final\d*.*') numFiles = len( os.listdir( dirPath )) assert numFiles % 2 == 0 finalIdsSortedList = finalReader.fileids() draftIdsSortedList = draftReader.fileids() for i in range(len(finalReader.fileids())): final = finalReader.paras( finalIdsSortedList[i] ) draft = draftReader.paras( draftIdsSortedList[i] ) assn = assignment( draft, final ) assignments.append( assn ) return assignments
def edit_assignment(aid): if checkSession(3): return redirect("/") if session['currentPage'] != "/assignment/" + aid: session['lastPage'] += ", " + session['currentPage'] session['currentPage'] = "/assignment/" + aid print session['lastPage'] print session['currentPage'] a = assignment() emsg = '' if request.args.get('action') == 'update': a.getById(aid) a.data[0]['title'] = request.form.get('title') a.data[0]['description'] = request.form.get('description') a.data[0]['dueDate'] = request.form.get('dueDate') a.data[0]['project'] = request.form.get('project') a.data[0]['assignedTo'] = request.form.get('assignedTo') if request.form.get('completed') == "on": a.markComplete() if a.verify_update(): a.update() emsg = "<p style='color:green'>Assignment updated.</p>" else: emsg = "<p style='color:red'>" + a.getErrorHTML() + "</p>" if request.args.get('action') == 'insert': a.createBlank() a.data[0]['title'] = request.form.get('title') a.data[0]['description'] = request.form.get('description') a.data[0]['dueDate'] = request.form.get('dueDate') a.data[0]['project'] = request.form.get('project') a.data[0]['assignedTo'] = request.form.get('assignedTo') if a.verify_new(): a.insert() emsg = '<p style="color:green">Assignment Created.</p>' else: emsg = "<p style='color:red'>" + a.getErrorHTML() + "</p>" if request.args.get('back') == "true": updatePath() if aid == 'new': a.createBlank() w = 'Create New Assignment' act = 'insert' hide = "display: none" col1 = "col-sm-4" col3 = "<div class='col-sm-4'></div>" cta = "Create Assignment" complete = "" return redirect("/assignments") else: a.getById(aid) w = 'Assignment Information' act = 'update' hide = "" col1 = "col-sm-8" col3 = "" cta = "Update Assignment" if a.data[0]['status'] == 1: complete = '''<div align="center"> <p>Assignment has been marked complete</p> </div> ''' else: complete = '''<div align="center"> <p>Check to Complete</p> <input name="completed" style="width: 10%; margin: auto" type="radio" value="on"/> </div> ''' html = '''<div class="row"> <div class="col-sm-2"> <form id="backFunction" action="''' + goBack() + '''?back=true" method="POST"> <input type="submit" class="button-secondary" value="Back"> </form> </div> <div class="col-sm-8"> </div> <div class="col-sm-2"></div> </div> <div class='row'> <div class="col-sm-4"> </div> <div align='center' class='col-sm-4'> <h2 id='user_form_title'>''' + w + '''</h2>''' + emsg + ''' <form align='left' id='assignment_form' action="/assignment/''' + str(aid) + '''?action=''' + act + '''" method="POST"> <p class='labels'>Title</p> <input name="title" required type="text" value="''' + a.data[0]['title'] + '''"/><br/> <p class='labels'>Description</p> <textarea name="description" style="width: 100%; height: 10em" form='assignment_form'>''' + a.data[0]['description'] + '''</textarea> <p class='labels'>Due Date</p> <input name="dueDate" required type="text" id="datepicker" value="''' + str(a.data[0]['dueDate']) + '''"/><br/> <p class='labels'>Project</p> ''' + str(a.returnProjectList(a.data[0]['project'])) + ''' <p class='labels'>Assigned To</p>''' + str(a.returnUserList(a.data[0]['assignedTo'])) + ''' <br><br>''' + complete + '''<br> <input type="submit" class='button-primary' value="''' + cta + '''"/> </form> <a href="/assignments?delete=''' + aid + '''" onclick="return confirm('Are you sure you want to delete this assignment?')" style="color: #C2C2C2; font-size: 80%; ''' + hide + '''">Delete Assignmnet</a> </div> <div class='col-sm-4'></div> </div> ''' return header() + html + footer()
def edit_user(uid): if checkSession(3): return redirect("/") if session['currentPage'] != "/user/" + uid: session['lastPage'] += ", " + session['currentPage'] session['currentPage'] = "/user/" + uid print session['lastPage'] print session['currentPage'] u = user() emsg = '' assignMsg = '' teamMsg = '' assignmentSel = request.args.get('assignmentSelector') if assignmentSel == None: assignmentSel = 0 if request.args.get('action') == 'update': u.getById(uid) u.data[0]['fname'] = request.form.get('fname') u.data[0]['lname'] = request.form.get('lname') u.data[0]['email'] = request.form.get('email') u.data[0]['role'] = request.form.get('role') u.data[0]['pw'] = request.form.get('pw') u.data[0]['pw2'] = request.form.get('pw2') u.data[0]['phoneNumber'] = request.form.get('phoneNumber') u.data[0]['gradDate'] = request.form.get('gradDate') u.data[0]['major'] = request.form.get('major') if u.verify_update(): u.update() emsg = "<p style='color:green'>User updated.</p>" else: emsg = "<p style='color:red'>" + u.getErrorHTML() + "</p>" if request.args.get('action') == 'insert': u.createBlank() u.data[0]['fname'] = request.form.get('fname') u.data[0]['lname'] = request.form.get('lname') u.data[0]['email'] = request.form.get('email') u.data[0]['role'] = request.form.get('role') u.data[0]['pw'] = request.form.get('pw') u.data[0]['pw2'] = request.form.get('pw2') u.data[0]['phoneNumber'] = request.form.get('phoneNumber') u.data[0]['gradDate'] = request.form.get('gradDate') u.data[0]['major'] = request.form.get('major') if u.verify_new(): u.insert() emsg = '<p style="color:green">User added.</p>' else: emsg = "<p style='color:red'>" + u.getErrorHTML() + "</p>" if request.args.get('team') == 'add': t = team() t.createBlank() t.data[0]['project'] = request.form.get('project') t.data[0]['user'] = uid if t.verify_new(t.data[0]['project']): t.insert() teamMsg = '<p style="color:green">Project added.</p>' else: teamMsg = "<p style='color:red'>" + t.getErrorHTML() + "</p>" if request.args.get('team') == 'remove': t = team() t.deleteByUser(uid, str(request.form.get('project'))) teamMsg = '<p style="color: green; margin-bottom: 1em">' + t.returnUserName(uid) + " has been removed from " + t.returnProjectName(request.form.get('project')) + "</p>" if request.args.get('assignment') == "add": a = assignment() a.createBlank() a.data[0]['title'] = request.form.get('title') a.data[0]['description'] = request.form.get('description') a.data[0]['assignedTo'] = uid a.data[0]['dueDate'] = request.form.get('dueDate') a.data[0]['project'] = request.form.get('project') if a.verify_new(): a.insert() assignMsg = '<p style="color: green; margin-bottom: 1em">Assignment Added</p>' else: assignMsg = '<p style="color: red; margin-bottom: 1em">' + a.getErrorHTML() + "</p>" if request.args.get('back') == "true": updatePath() if uid == 'new': u.createBlank() w = 'Add New User' act = 'insert' hide = "display: none" col1 = "col-sm-4" col3 = "<div class='col-sm-4'></div>" cta = "Add User" else: u.getById(uid) w = 'Account Information' act = 'update' hide = "" col1 = "col-sm-8" col3 = "" cta = "Update Account Information" html = '''<div class="row"> <div class="col-sm-2"> <form id="backFunction" action="''' + goBack() + '''?back=true" method="POST"> <input type="submit" class="button-secondary" value="Back"> </form> </div> <div class="col-sm-8"> <h1 align="center" id="user_title_main" style="''' + hide +'''">''' + u.data[0]['fname'].upper() + ''' ''' + u.data[0]['lname'].upper() + '''</h1> </div> <div class="col-sm-2"></div> </div> <h3 align="center" style="margin: 0;''' + hide + '''">''' + u.data[0]['major'] + '''</h3> <div class='row'> <div class="''' + col1 + '''"> <h2 style="''' + hide +'''">Projects</h2> <p style="''' + hide + '''">''' + teamMsg + '''</p> <div style="''' + hide + '''" id="userProjects">''' t = team() html += t.getProjects(uid) html += '''</div> <h2 style="''' + hide + '''">Assignments</h2> <p style="''' + hide + '''">''' + assignMsg + '''</p> <div id="userAssignments" style="''' + hide + '''">''' a = assignment() html += a.getUserAssignments(uid, assignmentSel) html += ''' </div> </div> <div align='center' class='col-sm-4'> <h2 id='user_form_title'>''' + w + '''</h2>''' + emsg + ''' <form align='left' id='user_form' action="/user/''' + str(uid) + '''?action=''' + act + '''" method="POST"> <p class='labels'>First Name</p> <input name="fname" required type="text" value="''' + u.data[0]['fname'] + '''"/><br/> <p class='labels'>Last Name</p> <input name="lname" required type="text" value="''' + u.data[0]['lname'] + '''"/><br/> <p class='labels'>Email</p> <input name="email" required type="text" value="''' + u.data[0]['email'] + '''"/><br/> <p class='labels'>Password</p> <input name="pw" type="password" value=""/><br/> <p class='labels'>Retype Password</p> <input name="pw2" type="password" value=""/><br/> <p class='labels'>Role</p>'''+ u.getRoleMenu() +''' <p class='labels'>Phone Number</p> <input name='phoneNumber' required type="text" value="''' + u.data[0]['phoneNumber'] + '''"/><br/> <p class='labels'>Expected Graduation</p> <input name='gradDate' type='text' id="datepicker" placeholder="YYYY" value="''' + str(u.data[0]['gradDate']) + '''"/> <p class='labels'>Major</p> <input name='major' type='text' value="''' + u.data[0]['major'] + '''"/> <br><br> <input type="submit" class='button-primary' value="''' + cta + '''"/> </form> <a href="/users?delete=''' + uid + '''" onclick="return confirm('Are you sure you want to delete this user?')" style="color: #C2C2C2; font-size: 80%;''' + hide + '''">Delete User</a> </div>''' + col3 + ''' </div> ''' return header() + html + footer()
def edit_project(pid): if checkSession(3): return redirect("/") if session['currentPage'] != "/project/" + pid: session['lastPage'] += ", " + session['currentPage'] session['currentPage'] = "/project/" + pid print session['lastPage'] print session['currentPage'] p = project() emsg = '' teamMsg = '' assignMsg = '' assignmentSel = request.args.get('assignmentSelector') if assignmentSel == None: assignmentSel = 0 if request.args.get('action') == 'update': p.getById(pid) p.data[0]['name'] = request.form.get('name') p.data[0]['description'] = request.form.get('description') p.data[0]['status'] = request.form.get('status') if 'logo' in request.files: p.data[0]['logo'] = request.files['logo'].filename if p.verify_update(): p.update() if 'logo' in request.files: file_save = logos.save(request.files['logo']) emsg = "<p style='color:green'>Project updated.</p>" else: emsg = "<p style='color:red'>" + p.getErrorHTML() + "</p>" if request.args.get('action') == 'insert': p.createBlank() p.data[0]['name'] = request.form.get('name') p.data[0]['description'] = request.form.get('description') p.data[0]['status'] = request.form.get('status') if ('logo' in request.files): filename = logos.save(request.files['logo']) p.data[0]['logo'] = filename if p.verify_new(): p.insert() emsg = '<p style="color:green">Project added.</p>' else: emsg = "<p style='color:red'>" + p.getErrorHTML() + "</p>" if request.args.get('team') == 'add': t = team() t.createBlank() t.data[0]['user'] = request.form.get('user') t.data[0]['position'] = request.form.get('position') t.data[0]['project'] = pid print t.data if t.verify_new(pid): print t.data t.insert() teamMsg = '<p style="color: green; margin-bottom: 1em">User Added</p>' else: teamMsg = '<p style="color: red; margin-bottom: 1em">' + t.getErrorHTML() + "</p>" if request.args.get('team') == 'remove': t = team() t.deleteByUser(request.form.get('user'), pid) teamMsg = '<p style="color: green; margin-bottom: 1em">' + t.returnUserName(request.form.get('user')) + " has been removed from this project</p>" if request.args.get('assignment') == "add": a = assignment() a.createBlank() a.data[0]['title'] = request.form.get('title') a.data[0]['description'] = request.form.get('description') a.data[0]['assignedTo'] = request.form.get('user') a.data[0]['dueDate'] = request.form.get('dueDate') a.data[0]['project'] = pid if a.verify_new(): a.insert() assignMsg = '<p style="color: green; margin-bottom: 1em">Assignment Added</p>' else: assignMsg = '<p style="color: red; margin-bottom: 1em">' + a.getErrorHTML() + "</p>" if request.args.get('back') == "true": updatePath() if pid == 'new': p.createBlank() w = 'Add New Project' act = 'insert' hide = "display: none" col1 = "col-sm-4" col3 = "<div class='col-sm-4'></div>" cta = "Add Project" else: p.getById(pid) w = 'Project Information' act = 'update' hide = "" col1 = "col-sm-8" col3 = "" cta = "Update Project" if p.data[0]['logo'] == '': src = "" else: src = "src='../static/Images/" + p.data[0]['logo'] + "'" html = '''<div class="row"> <div class="col-sm-2"> <form id="backFunction" action="''' + goBack() + '''?back=true" method="POST"> <input type="submit" class="button-secondary" value="Back"> </form> </div> <div class="col-sm-8"> <h1 id="user_title_main" align="center" style="''' + hide +'''">''' + p.data[0]['name'].upper() + '''</h1> </div> <div class="col-sm-2"></div> </div> <div class='row'> <div class="''' + col1 + '''"> <h2 style="''' + hide +'''">Team</h2>''' + teamMsg + ''' <div style="''' + hide + '''" id="projectTeam">''' t = team() html += t.getTeam(pid) html += '''</div> <h2 style="''' + hide +'''">Assignments</h2> <div style="''' + hide + '''" id="projectAssignments">''' a = assignment() html += a.getProjectAssignments(pid, assignmentSel) html += ''' </div> </div> <div align='center' class='col-sm-4'> <h2 id='user_form_title'>''' + w + '''</h2>''' + emsg + ''' <form align='left' enctype="multipart/form-data" id='project_form' action="/project/''' + str(pid) + '''?action=''' + act + '''" method="POST"> <p class='labels'>Name</p> <input name="name" required type="text" value="''' + p.data[0]['name'] + '''"/><br/> <p class='labels'>Description</p> <textarea name="description" style="width:100%; height: 12em" required form="project_form">''' + p.data[0]['description'] + '''</textarea> <p class='labels'>Status</p>''' + p.getStatusMenu() + ''' <p class='labels'>Logo</p> <img id="project_logo" ''' + src + '''/><br/> <input name="logo" type="file" accept="image/*"/ value="''' + p.data[0]['logo'] + '''"> <br> <input type="submit" class='button-primary' value="''' + cta + '''"/> </form> <a href="/projects?delete=''' + pid + '''" onclick="return confirm('Are you sure you want to delete ''' + p.data[0]['name'] + '''?');" style="color: #C2C2C2; font-size: 80%; ''' + hide + '''">Delete Project</a> </div>''' + col3 + ''' </div> ''' return header() + html + footer()
def main(): pygame.init() pygame.display.set_caption("Graduate Nya") window = pygame.display.set_mode((750, 500)) run = True frame = 0 assignum = 1 duedate = [3, 6, 9] progress = [ 0, 0, 0 ] # how many asisgnments completed; 0 means in progress aka dot date = 1 # d-1. puzzle changes from assignment to exam depending on the date title = titlepage(window) mainpg = mainpage(window) assig = assignment(window) sylb = syllabus(window) exm = exam(window) arrow = pygame.image.load('nyas/arrow.png') # points to syllabus flower = [ pygame.image.load('nyas/flower.png'), pygame.image.load_extended('nyas/flower2.png') ] note = pygame.image.load('nyas/note.png') notex = pygame.Rect((517, 116), (20, 17)) showsylb = False showarrow = True enter = False # true when enter is clicked exampass = None # boolean shownote = False text = '' while run: pygame.time.delay(50) for event in pygame.event.get(): if event.type == pygame.QUIT: run = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_BACKSPACE: text = text[:-1] else: text += event.unicode window.fill((255, 255, 255)) if frame == 0: title.blit() if title.clicked(): frame += 1 elif frame == 1: # check date matching with assignment due date for i in range(3): if date > duedate[i] and progress[i] == 0: #over due progress[i] = 2 # assignment fail assignum += 1 #elif date == duedate[i]+1 and progress[i] == 1: #if finished on date # assignum += 1 elif date <= duedate[i] and progress[ i] == 1: #finished before due date = duedate[i] + 1 # jumps to day after due date assignum += 1 mainpg.draw() mainpg.blit(date) mainpg.progressblit(progress) mainpg.showtext(date) a, b = pygame.mouse.get_pos() if pygame.Rect((630, 355), (60, 100)).collidepoint(a, b): window.blit(flower[1], pygame.Rect((600, 325), (100, 140))) if pygame.mouse.get_pressed()[0]: shownote = True else: window.blit(flower[0], pygame.Rect((600, 325), (100, 140))) if showarrow: window.blit(arrow, (135, 280)) if mainpg.clicked(date) == "assignment": frame += assignum elif mainpg.clicked(date) == "syllabus": showsylb = True elif mainpg.clicked(date) == "exam": frame = 5 if showsylb == True: sylb.blit() if sylb.exclicked() == True: showsylb = False showarrow = False if shownote == True: window.blit(note, (0, 0)) if pygame.mouse.get_pressed()[0]: if notex.collidepoint(a, b): shownote = False elif frame == 2 or frame == 3 or frame == 4: # frame for assignments len = [6, 12, 6] #max length of text per assignment input = text[:len[assignum - 1]] # only up to 10 char assig.start(assignum, input) # pulls the assignment 1 screen if assig.clicked(assignum - 1) == "enter": enter = True if enter == True: if assig.correct(assignum, input) == True: progress[ assignum - 1] = 1 # (if not, player can try again until it's due date) assig.popup(1) else: assig.popup(0) if assig.clicked( assignum - 1 ) == "ok": # ok button should only work after enter button has been pressed frame = 1 # go back to mainpg date += 1 enter = False text = '' elif frame == 5: exm.blit(text[:10]) # take up to 10 char if exm.clicked() == "enter": enter = True if enter == True: if exm.correct(text[:10]) == True: exm.popup(1) exampass = True else: exm.popup(0) exampass = False if exm.clicked() == "ok": enter = False frame += 1 elif frame == 6: if exm.passed(progress, exampass) == True: # if user has passing mark exm.blitresult(1) else: exm.blitresult(0) pygame.display.update()