def setUp(self): sys.path.insert(0, "../../src") from models import Assignment start_date = datetime.date(2000, 5, 5) due_date = datetime.date(2020, 12, 12) self.assignment1 = Assignment(1) self.assignment2 = Assignment(2, start_date, due_date)
def module003_assignment_course(course_id): form = AssigmentForm() course = Course.query.filter_by(id=course_id).first() follow = Follow.query.filter( and_(Follow.course_id == course_id, Follow.user_id == current_user.id)).first() assignments = Assignment.query.filter_by(course_id=course_id) if follow: if request.method == 'POST': if form.validate_on_submit(): if form.never_expire.data: assignment = Assignment(course_id=course_id, author_id=current_user.id, name=form.name.data, descripcion=form.descripcion.data) else: assignment = Assignment( course_id=course_id, author_id=current_user.id, name=form.name.data, descripcion=form.descripcion.data, date_expire=datetime.datetime.combine( form.date_expire.data, form.time_expire.data)) try: db.session.add(assignment) db.session.commit() flash("Assignment created") except: db.session.rollback() flash("Error creating Assignment!") return redirect( url_for('module003.module003_assignment_course', course_id=course.id)) else: if current_user.profile in ('admin', 'staff', 'student'): follows = Follow.query.filter_by(user_id=current_user.id) return render_template("module003_assignment_especifico.html", form=form, module="module003", rows=follows, course=course, assignments=assignments) else: flash("Access denied!") return redirect(url_for('index')) else: flash("Access denied!") # abort(404,description="Access denied!") return redirect(url_for('index'))
def _create_or_add_assignment(self, assignment_name, parentnode, extras): assignment = Assignment(parentnode=parentnode, short_name=assignment_name, long_name=assignment_name.capitalize(), publishing_time=parentnode.start_time) try: assignment.full_clean() assignment.save() except ValidationError: assignment = Assignment.objects.get(parentnode=parentnode, short_name=assignment_name) # add the users (only admins allowed in subject) for admin in extras['admin']: assignment.admins.add(self._create_or_add_user(admin)) if extras['pub']: assignment.publishing_time += timedelta(days=int(extras['pub'][0])) if extras['anon']: if extras['anon'][0] == 'true': assignment.anonymous = True elif extras['anon'][0] == 'false': assignment.anonymous = False else: raise ValueError("anon must be 'true' or 'false'") assignment.full_clean() assignment.save() vars(self)[parentnode.parentnode.short_name + '_' + # subject parentnode.short_name + '_' + # period assignment.short_name] = assignment return assignment
def add_lesson_to_course(courseID): """Adds a lesson to a course""" form = request.form course = Course.query.get(courseID) try: lesson = Lesson(course_id=courseID, title=form.get("title"), num=form.get("num"), date_due=form.get("date_due")) db.session.add(lesson) db.session.commit() for student in course.students_enrolled: assignment = Assignment(student_enrollment_id=student.id, lesson_id=lesson.id, complete=False, turned_in=False) db.session.add(assignment) db.session.commit() flash("Successfully added lesson") except: flash("Failed to add lesson") return redirect("/")
def make_assignment_with_pk_vals(quarter, year, assign): assignment = Assignment() assignment.year = year assignment.quarter = quarter assignment.number = assign return assignment
def _create_or_add_assignment(self, assignment_name, parentnode, extras): # NOTE: Set default publishing_time two seconds after start_time to # make sure it evaluates as "within" the period. publishing_time = parentnode.start_time + timedelta(seconds=2) if extras['delivery_types']: deliverytype_alias = extras['delivery_types'][0] typemap = {'electronic': deliverytypes.ELECTRONIC, 'nonelectronic': deliverytypes.NON_ELECTRONIC} delivery_types = typemap[deliverytype_alias] else: delivery_types = deliverytypes.ELECTRONIC assignment = Assignment(parentnode=parentnode, short_name=assignment_name, long_name=assignment_name.capitalize(), publishing_time=publishing_time, delivery_types=delivery_types, max_points=200) try: assignment.full_clean() assignment.save() except ValidationError: assignment = Assignment.objects.get(parentnode=parentnode, short_name=assignment_name) # add the users (only admins allowed in subject) for admin in extras['admin']: assignment.admins.add(self._create_or_add_user(admin)) if extras['pub']: assignment.publishing_time += timedelta(days=int(extras['pub'][0])) if extras['anon']: if extras['anon'][0] == 'true': assignment.anonymous = True elif extras['anon'][0] == 'false': assignment.anonymous = False else: raise ValueError("anon must be 'true' or 'false'") if extras['ln']: assignment.long_name = extras['ln'][0] if extras['first_deadline']: days = int(extras['first_deadline'][0]) assignment.first_deadline = assignment.publishing_time if days == 0: assignment.first_deadline += timedelta(seconds=1) else: assignment.first_deadline += timedelta(days=days) assignment.full_clean() assignment.save() vars(self)[parentnode.parentnode.short_name + '_' + # subject parentnode.short_name + '_' + # period assignment.short_name] = assignment return assignment
def post(self): parser = reqparse.RequestParser() parser.add_argument( "sid", type=str, required=True, ) parser.add_argument( "ordinal", type=str, choices=assignment_function_mapping.keys(), required=True, ) parser.add_argument( "answers", required=True, action="append", ) try: args = parser.parse_args() except Exception: raise ParameterMissing correctnesses = assignment_function_mapping[args.ordinal](args.answers) if args.sid: past_assignment = Assignment.query.filter_by( sid=args.sid, ordinal=args.ordinal, ).first() if past_assignment is not None: updated_correctenesses = self._merge_correctnesses( self._deserialize_correctnesses( past_assignment.correctnesses, ), correctnesses, ) past_assignment.correctnesses = self._serialize_correctnesses( updated_correctenesses, ) db.session.commit() else: assignment = Assignment( sid=args.sid, ordinal=args.ordinal, correctnesses=self._serialize_correctnesses(correctnesses), ) db.session.add(assignment) db.session.commit() return { "correctnesses": correctnesses, }
def add(): if request.method == "GET": course_num = request.args['courseNum'] return render_template("addAssignment.html", course_num=course_num) name = request.form.get('assignment') course_num = request.form.get('courseNum') newAssignment = Assignment(name=name, class_id=course_num) db_session.add(newAssignment) db_session.commit() db_session.add(Grade(grade=0, assignment_id=newAssignment.id)) db_session.commit() return redirect(url_for('search', courseNum=course_num))
def add_staff(): if "staff_id" not in session: abort(401) if not request.form["request_id"]: abort(404) # Get all the data from the single select element value, we need event request id and staff id staff = Staff.query.filter_by(staff_id=session["staff_id"]).first() eventRequest = EventRequest.query.filter_by(request_id=request.form["request_id"]).first() if staff == None or eventRequest == None: # Make sure both exist in the DB, for FK validation abort(404) assign = Assignment(eventRequest.request_id, staff.staff_id) db.session.add(assign) db.session.commit() flash("Staff " + staff.username + " assigned to event " + str(eventRequest) + " successfully!") return redirect(url_for('staff'))
def post(self): """ Creates an assignment """ data = request.json title = data.get('title') start_date = data.get('start_date')[:10] + " 00:00:00" due_date = data.get('due_date')[:10] + " 23:59:59" group_id = data.get('group_id') problem_id = data.get('problem_id') new_assignment = Assignment(title=title, start_date=start_date, due_date=due_date, group_id=group_id, problem_id=problem_id) db.session.add(new_assignment) db.session.commit() return new_assignment, 201
def setUp(self): db.drop_all() db.create_all() teacher = Teacher.seed_db(name="teacher_name", username="******", password="******") db.session.add(teacher) student = Student.seed_db(name="student_name", username="******", password="******", teacher_id=1) db.session.add(student) assignment = Assignment(title='title', body='body', teacher_id=1) db.session.add(assignment) one = StudentAssignment(assignment_id=assignment.id, student_id=student.id) db.session.add(one) db.session.commit()
def createNewRecord(eventID=None): """ return a reference to a newly created record or elss None""" eventID = cleanRecordID(eventID) rec = None if eventID > 0: #test that countEvent record exits cnt = CountEvent.query.filter(CountEvent.ID == eventID).count() if cnt > 0: rec = Assignment(eventID, getUID()) db.session.add(rec) else: flash( printException( "Invalid countEvent ID during Count Event creation.", "error")) return rec
def homework_upload(): # Save the file file = request.files['homework'] file2 = request.files['homeworksrc'] filename = str(uuid.uuid4()) file.save( os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(filename + '.jar'))) file2.save( os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(filename + '.zip'))) # Add file to the database of assignments assignment = Assignment(id=filename, name=file.filename) models.db.session.add(assignment) models.db.session.commit() return redirect('/')
def new_assignment(course_id): course = Course.query.get(course_id) if request.method == "POST": name = request.form.get('name', None) description = request.form.get('description', None) due_at = request.form.get('due-at', None) display_at = request.form.get('display-at', None) file_ = request.files.get('file', None) if name and due_at and display_at: assignment = Assignment(name=name, description=description) assignment.due_at = parse(due_at) assignment.display_at = parse(display_at) if file_: filename = assignment_descs.save(file_) assignment.description_filename = filename course.add_assignment(assignment) assignment.save() return redirect(url_for('list_assignments', course_id=course_id)) return render_template('assignment/new.html', course=course)
def addassignment(): """ Utility view for adding assignments. """ req_json = request.get_json(silent=True) if not req_json: return "Assignment addition failed." if req_json['key'] != SECRET_KEY: return "Assignment addition failed; key incorrect." assignment = Assignment(title=req_json['title'], desc=req_json['desc'], visible=req_json['visible'], date_due=datetime.date.fromordinal( req_json['date_due'])) db.session.add(assignment) db.session.commit() if assignment.visible: send_email_users_new_asgn(assignment) return "Added assignment " + str(assignment) + " successfully."
def new_assignment(): ''' Create new assignment ''' form = AssignmentForm() if form.validate_on_submit(): my_assignment = Assignment() form.populate_obj(my_assignment) db.session.add(my_assignment) try: db.session.commit() # User info flash('Assignment created correctly', 'success') return redirect(url_for('assignments')) except: db.session.rollback() flash('Error generating assignment.', 'danger') return render_template('web/new_assignment.html', form=form)
def assign(a, b): body = request.get_json() reviewer_id = body.get('reviewer_id', None) project_id = body.get('project_id', None) try: reviewer = Reviewer.query.filter_by(id=reviewer_id).one_or_none() project = Project.query.filter_by(id=project_id).one_or_none() previous_assignments = Assignment.query.filter( Assignment.reviewer_id == reviewer_id, Assignment.project_id == project_id).count() if previous_assignments > 0: raise AuthError({ 'code': 'Bad request', 'description': "this assignment is already existent" }, 400) if reviewer is None: raise AuthError({ 'code': 'Bad request', 'description': "reviewer does not exist" }, 400) if project is None: raise AuthError({ 'code': 'Bad request', 'description': "project does not exist" }, 400) assignment = Assignment() assignment.reviewer_id = reviewer_id assignment.project_id = project_id assignment.insert() return jsonify({ 'success': True, 'assignment': assignment.format() }) except Exception as e: print("exception error post reviewer", e) print(e) if isinstance(e, AuthError): raise e abort(422)
def add_assignments(enrollmentID): """This is a helper function that adds all the assignments to an enrolled student""" enroll = Enrollment.query.get(enrollmentID) lessons = Lesson.query.filter(Lesson.course_id == enroll.course.id) assigned_lessons = [assigned.lesson for assigned in enroll.assignemnts] for lesson in lessons: if not lesson in assigned_lessons: assignment = Assignment(student_enrollment_id=enrollmentID, lesson_id=lesson.id, complete=False, turned_in=False) db.session.add(assignment) db.session.commit()
def load_homework(file_name): """ load homework from a unique csv file in the data folder file_name: the name of the csv file """ path = "../data/" + file_name data = pd.read_csv(path) tprint("Homeworks", data) homework_list = [] for index, row in data.iterrows(): a_assignment = Assignment( cname=row["class"], desc=row["description"], duration=row["duration"], due=row["due"], ) homework_list.append(a_assignment) return homework_list, data
def create_assignment_rpc(course, name, file, command, batch_size, grading_base): assignment: Assignment = Assignment.query.filter_by( name=name, course=course, endpoint=get_endpoint(course=course)).one_or_none() if not assignment: assignment = Assignment( name=name, assignment_secret=new_secret(), course=course, endpoint=get_endpoint(course=course), ) db.session.add(assignment) assignment.file = file assignment.command = command assignment.last_modified = int(time.time()) assignment.batch_size = batch_size assignment.grading_base = grading_base db.session.commit() return assignment.assignment_secret
def module003_create(): form = AssignmentCreateForm() if request.method == 'POST': try: course = Course.query.get(form.course_id.data) assignment = Assignment(title=form.title.data, body=form.description.data, date_expire=datetime.datetime.combine( form.date_expire.data, form.time_expire.data), course_id=course.id, course_name=course.name, institution_name=course.institution_name, user_id=current_user.id) db.session.add(assignment) db.session.commit() flash("Tarea creda con exito") except: flash("Error creando tarea") for course in Course.query.filter_by(user_id=current_user.id): form.course_id.choices += [ (course.id, str(course.id) + ' - ' + course.institution_name + ' - ' + course.name) ] assignments = Assignment.query.filter( Assignment.user_id == current_user.id) return render_template("module003_create.html", module='module003', form=form, rows=assignments)
password="******", teacher_id=1) db.session.add_all([s0, s1, s2, s3, s4, s5, s6, s7, s8, s9]) db.session.commit() #PoemsDB URL https://poetrydb.org/ #To get 10 poems by author Robert Burns, #https://poetrydb.org/author,poemcount/Robert%20Burns;10/title,lines burns = requests.get( "https://poetrydb.org/author,poemcount/Robert%20Burns;10/title,lines") hw = burns.json() all_hw = [] for poem in hw: one = Assignment(title=poem['title'], body=poem['lines'], teacher_id=1) all_hw.append(one) db.session.add_all(all_hw) db.session.commit() student = Student.query.all() assign = Assignment.query.all() all_assign = [] for st in student: for asn in assign: one = StudentAssignment(assignment_id=asn.id, student_id=st.id) all_assign.append(one) db.session.add_all(all_assign) db.session.commit()
def test_normal_class(self): """test creation of a sample class""" #create users of class try: teacher = Users(username='******', first_name='creswell', last_name='creswell', role=self.admin_role) teacher.set_password('password') db.session.add(teacher) student1 = Users(username='******', first_name='notcreswell', last_name='notcreswell', role=self.user_role) student1.set_password('password') db.session.add(student1) student2 = Users(username='******', first_name='notcreswell2', last_name='notcreswell2', role=self.user_role) student2.set_password('password') db.session.add(student2) except: self.fail("Failed to create users.") traceback.print_exc() #create class try: class_ = Class(teacher_id=teacher, name="class", join_code="join") db.session.add(class_) except: self.fail("Failed to create class.") traceback.print_exc() #create gradefactor try: grade_factor = GradeFactor(class_id=class_.id, category1_name="tests", category1_weight=0.5, category2_name="quizzes", category2_weight=0.5) db.session.add(grade_factor) except: self.fail("Failed to create grade factor.") traceback.print_exc() #create gradescale try: grade_scale = GradeScale(class_id=class_.id, a_b = 0.9, b_c = 0.8, c_d = 0.7, d_f = 0.6) db.session.add(grade_scale) except: self.fail("Failed to create grade factor.") traceback.print_exc() #add students to class try: class_student_link1 = ClassStudentLink(student_id=student1.id, class_id=class_.id) db.session.add(class_student_link1) class_student_link2 = ClassStudentLink(student_id=student2.id, class_id=class_.id) db.session.add(class_student_link2) except: self.fail("Failed to create class student links.") traceback.print_exc() #add assignments try: test1 = Assignment(assignment_name="test1", assignment_type=1, assignment_date=datetime.date(2019,1,1), class_id=class_, total_points=100) db.session.add(test1) quiz1 = Assignment(assignment_name="quiz1", assignment_type=2, assignment_date=datetime.date(2019,1,1), class_id=class_, total_points=50) db.session.add(quiz1) except: self.fail("Failed to create assignments.") traceback.print_exc() #add assignment_results try: test1_student1 = AssignmentResult(student_id=student1, assignment_id=test1, points_earned=90) db.session.add(test1_student1) quiz1_student_1 = AssignmentResult(student_id=student1, assignment_id=quiz1, points_earned=45) db.session.add(quiz1_student_1) test1_student2 = AssignmentResult(student_id=student2, assignment_id=test1, points_earned=80) db.session.add(test1_student2) quiz1_student_2 = AssignmentResult(student_id=student2, assignment_id=quiz1, points_earned=40) db.session.add(quiz1_student_2) except: self.fail("Failed to create assignment results.") traceback.print_exc()
def create_assignment(assignment_name, date_due, points, description): new_assignment = Assignment(assignment_name, date_due, points, description) Assignment.create_assignment(new_assignment)
import re from models import Assignment, Problem file = open("management/commands/sample.tex", "r") data = file.read() m = re.search(r"assignment{(.*)}", data) name = m.group(1) m = re.search(r"duedate{(.*)}", data) due_date = m.group(1) asgt = Assignment(name=name, due_date=due_date) asgt.save() problems = [] problem_locs = [m.end() for m in re.finditer("begin{problem}", data)] for loc in problem_locs: p = Problem() m = re.search(r"\[(.*)\]", data[loc:]) p.name = m.group(1) n = re.search(r"\[(.*)\]", data[loc + m.end():]) p.points = n.group(1) o = re.search(r"([^]]*)\\end{problem}", data[loc + m.end() + n.end():]) p.solution = o.group(1) p.save() asgt.problems.add(p)
from app import db from models import Survey, Task, Assignment, Response import os try: os.remove("sample.db") except: pass db.create_all() survey = Survey() task = Task() assignment = Assignment() fileNames = ["file1.mp3", "file2.mp3", "file3.mp3", "file4.mp3"] answers = ["A", "B", "C", "D", "E"] counts = [] counts.append([10, 8, 5, 0, 1]) counts.append([1, 26, 2, 3, 7]) counts.append([4, 0, 0, 3, 57]) counts.append([1, 6, 1, 5, 28]) index = 0 for i in range(0, len(fileNames)): answerCounts = counts[i] for j in range(0, len(answerCounts)): for k in range(0, answerCounts[j]):
def create_from_path(path): """ Create a Node, Subject, Period, Assignment or AssignmentGroup from ``path``. Examples:: assignmentgroup = create_from_path( 'ifi:inf1100.spring05.oblig1.student1,student2') oblig1 = create_from_path( 'ifi:inf1100.spring05.oblig1') """ split = path.split(':', 1) nodes = split[0].split('.') for nodename in nodes: node = Node(short_name=nodename, long_name=nodename.capitalize()) try: node.clean() node.save() except: node = Node.objects.get(short_name=nodename) last = node if len(split) != 2: return last pathsplit = split[1].split('.') # Subject subjectname = pathsplit[0] subject = Subject(parentnode=node, short_name=subjectname, long_name=subjectname.capitalize()) try: subject.clean() subject.save() except: subject = Subject.objects.get(short_name=subjectname) last = subject # Period if len(pathsplit) > 1: periodname = pathsplit[1] period = Period(parentnode=subject, short_name=periodname, long_name=periodname.capitalize(), start_time=datetime.now(), end_time=datetime.now() + timedelta(10)) try: period.clean() period.save() except: period = Period.objects.get(parentnode=subject, short_name=periodname) last = period # Assignment if len(pathsplit) > 2: assignmentname = pathsplit[2] assignment = Assignment(parentnode=period, short_name=assignmentname, long_name=assignmentname.capitalize(), publishing_time=datetime.now()) assignment.clean() try: assignment.save() except: assignment = Assignment.objects.get(parentnode=period, short_name=assignmentname) last = assignment # Candidates if len(pathsplit) > 3: usernames = pathsplit[3].split(',') users = [] for u in usernames: try: user = get_user_model().objects.get(shortname=u) except get_user_model().DoesNotExist: user = get_user_model().objects.create_user(username=u) users.append(user) assignment_group = AssignmentGroup(parentnode=assignment) assignment_group.clean() assignment_group.save() for user in users: assignment_group.candidates.add(Candidate(student=user)) last = assignment_group return last
def create_app(assistant=assistant): app = Flask(__name__) app.config.from_object(Config) db.init_app(app) app.register_blueprint(index, url_prefix='/') app.register_blueprint(teacher, url_prefix='/teacher') app.register_blueprint(student, url_prefix='/student') app.register_blueprint(course, url_prefix='/course') app.register_blueprint(admin, url_prefix='/admin') app.register_blueprint(assistant, url_prefix='/assistant') app.app_context().push() bootstrap.init_app(app) t1 = Teacher( Tno="20201217", Tname="金波", Tpw="123456", Tsex="男", Tage=40, Ttel="13700000000", Taddr="浙江省杭州市西湖区浙大路38号", profile="教授,博士生导师。1993年6月毕业于浙江大学流体传动及控制专业,获学士学位。1998年9" "月于浙江大学流体传动及控制专业获得博士学位,同年留校任教。作为主要完成人获得国家技术发明奖二等奖一项,省部级科技进步一等奖两项。承担多项国家自然科学基金、863" "计划重点项目及浙江省自然科学基金重点项目。承担多项横向科研项目,均圆满地完成了研发任务。共在国内外学术刊物与国际会议上发表论文七十余篇,其中SCI/EI" "收录三十余篇。获得国家发明专利、软件著作权二十余项。", Tprofessional='计算机学院') t2 = Teacher( Tno="20201218", Tname="苏德矿", Tpw="123456", Tsex="男", Tage=40, Ttel="13700000000", Taddr="浙江省杭州市西湖区浙大路38号", profile= "浙江大学理学院数学系教授,浙江省精品课程《微积分》课程负责人、浙江大学公共数学基础课教学指导委员会副主任,浙江大学微积分课程负责人,浙江省高校高等数学教学研究会常务理事兼秘书长,清华大学萧树铁教授主持的前国家教委“面向21世纪教学内容和课程体系改革”研究课题组成员。", Tprofessional='数学学院') t3 = Teacher( Tno="20201219", Tname="邵健", Tpw="123456", Tsex="男", Tage=40, Ttel="13700000000", Taddr="浙江省杭州市西湖区浙大路38号", profile= "2003年7月从南京大学电子科学与工程系获得理学学士学位;2008年7月从中国科学院声学研究所获得信号与信息处理专业工学博士学位;2008年7" "月博士毕业后直接进入浙江大学计算机学院计算机应用学科从事师资博后研究工作,并在2010年9" "月留校,浙大工作期间研究方向拓展为视音频智能分析、跨媒体挖掘与检索、分布式计算,作为负责人承担了中国博士后基金面上与特别资助项目、教育部-微软重点实验室联合项目、省优先主题社会发展项目子课题等多个项目,并作为青年骨干参与承担了973项目子课题、NSFC重大研究计划、核高基重大专项子课题等多个项目。", Tprofessional='计算机学院') s1 = Student(Sno="3180100000", Sname="王小明", Spw="123456", Ssex="男", Sage=20, Stel="13700000000", Saddr="浙江省杭州市西湖区浙大路38号", Class="软工1802", Syear="2018", avatar_path='/student/static/avatar/3180100000.jpg', Sprofessional='软件工程') s2 = Student(Sno="3180100001", Sname="韩梅梅", Spw="123456", Ssex="女", Sage=20, Stel="13700000000", Saddr="浙江省杭州市西湖区浙大路38号", Class="计科1802", Syear="2018", Sprofessional='计算机科学与技术') s3 = Student(Sno="0000000000", Sname="匿名") a1 = Admin(Ano='admin', Aname='管理员', Atel='13700000000', Aaddr='玉泉', Aage=30, Asex='男', Apw='123456') Doc1 = Document(Doc_no=1, Doc_name="客户投诉处理.pptx", Doc_path="static/files/100001/chapter1/courseware", Doc_type="pptx", Doc_chapter=7, Doc_description="客户投诉处理相关事务", Doc_authority='可下载') Ass1 = Assignment(Assign_no=1, Assign_path='static/files/100001/chapter1', Begin_time='2020-12-31 10:00:20', End_time='2021-1-30 11:30:20', Description='平时作业1,请大家参照作业要求的ppt完成', Assign_chapter=7, Assign_name='C1.3作业', type='docx', percent=15, score=90) Ass2 = Assignment(Assign_no=2, Assign_path='static/files/100001/chapter1', Begin_time='2020-12-15 10:00:45', End_time='2020-12-25 11:11:45', Description='平时作业2,请大家参照模板完成', Assign_chapter=8, Assign_name='C1.4作业', type='docx', percent=15) Doc1.Doc_preview_address = create_preview_address(Doc1) D1 = Discussion(Discuss_no=1, Discuss_date='2020-1-1 12:00:00', Discuss_title='请问大家需求优先级排序有些什么好方法呢?', Content='rt,大家组里都是采用什么办法来排需求优先级呢,我觉得QFD比较完善...', isTop=1, isNew=1, reply_amount=1) D2 = Discussion(Discuss_no=2, Discuss_date='2020-1-2 12:00:00', Content='我觉得我们这个项目三层优先级就够了', isTop=0, isNew=0, reply_amount=0, reply_which=1) D3 = Discussion(Discuss_no=3, Discuss_date='2020-1-1 13:10:08', Discuss_title='关于期末答辩的安排', Content='各位同学:期末教学总体安排的' '通知及4个附件已发布,请查阅,并遵照执' '行。最后一周的那次上课就调整到16日的' '答辩了', isTop=1, isNew=1, reply_amount=0, poster_identity='教师') a1 = Admin(Ano="admin", Aname="张小红", Apw="123456", Asex="女", Aaddr="浙江省杭州市西湖区浙大路38号", Aage=23, Atel="13771011111", Aemail='*****@*****.**', Abirth='1995-5-20') assistant = Assistant(Asno="123", Asname="助教", Aspw="123456", Assex="男", Asage=23, Asaddr="浙江省杭州市西湖区浙大路38号") course1 = Course(Cno='100001', Ctype='计算机类', Cname='软件工程管理', Cdate='2020-9-27', Ctime="周三2、3、4节", Is_ongoing="正在进行", Cover_path="/course/static/cover/100001.jpg", introduction="软件工程管理是为了使软件项目能够按照预定的成本、" "进度、质量顺利完成,而对人员(People)、产品(" "Product)、过程(Process)和项目(Project)" "进行分析和管理的活动。") course2 = Course(Cno='100002', Ctype='自然科学类', Cname='微积分甲', Cdate='2020-9-28', Ctime="周四1、2节", Is_ongoing="已结课", Cover_path="/course/static/cover/100002.jpg", introduction="微积分学,数学中的基础分支。内容主要包括函数、极" "限、微分学、积分学及其应用。函数是微积分研究的基" "本对象,极限是微积分的基本概念,微分和积分是特定过程特定形式的极限。17" "世纪后半叶,英国数学家艾萨克·牛顿和德国数学家G.W" ".莱布尼兹,总结和发展了几百年间前人的工作,建立了" "微积分,但他们的出发点是直观的无穷小量,因此尚缺" "乏严密的理论基础。19世纪A.-L.柯西和K.魏尔斯特" "拉斯把微积分建立在极限理论的基础上;加之19世纪后" "半叶实数理论的建立,又使极限理论有了严格的理论基" "础,从而使微积分的基础和思想方法日臻完善。") course1.students = [s1] course1.assignments = [Ass1, Ass2] course1.discussions = [D1, D2, D3] course1.assistants = [assistant] D1.students = [s1] s2.discussions = [D2] course1.documents = [Doc1] course1.teachers = [t1, t3] course2.students = [s1] course2.teachers = [t2] t1.discussions = [D3] db.drop_all() db.create_all() db.session.add_all([course2, t2, t1, t3, s1, s3, s2, assistant, a1]) db.session.commit() return app
from models import db, Assignment from faker import Faker import random #fake = Factory.create() fake = Faker() classes = [ 'Advanced Math', 'Anderson Bible', 'Carpenter Bible', 'Rainear Bible', 'AP History', 'AP Psych', 'Chemistry', 'Smart English', 'Dumb English', 'Coding I', 'Forensic Science', 'American Sign Language', 'ELS Prepworks', 'Class Party' ] # Spanish #fake = Factory.create('es_ES') # Reload tables db.drop_all() db.create_all() # Make 100 fake contacts for num in range(10): randInfo = fake.text() randInfoPrime = randInfo[:20] randClass = random.choice(classes) randDate = fake.date_between(start_date='-30y', end_date='+30y') # Save in database my_contact = Assignment(assignmtInfo=randInfoPrime, assignmtClass=randClass, assignmtDate=randDate) db.session.add(my_contact) db.session.commit()