コード例 #1
0
def createCourseObject(filePath, tableIndex):
    # 创建文档对象
    doc = Document(filePath)
    # 获取课程所在表格
    try:
        courseTable = doc.tables[tableIndex]  #文档中第index个表格
    except Exception as e:
        print(e)
    try:
        # 创建课程对象
        from course.models import Course
        course = Course()
    except Exception as e:
        print(e)
    course.name = coursenameMange(courseTable.cell(2, 1).text)  #课程名称
    course.courseNumber = courseTable.cell(0, 1).text  #课程编号
    course.totalHours = courseTable.cell(1, 1).text  #总学时
    course.courseCategory = getCourseCategory(courseTable.cell(3,
                                                               1).text)  #课程类别
    course.writer = courseTable.cell(4, 1).text  #执笔人
    course.prerequisiteCourses = coursenameMange(courseTable.cell(
        5, 1).text)  #先修课程
    course.credit = courseTable.cell(0, 3).text  #学分
    course.experimentalHours = courseTable.cell(1, 3).text  #实验/上机学时
    course.englishName = courseTable.cell(2, 3).text  #英文名称
    course.appliedSpecialty = courseTable.cell(3, 3).text  #适用专业
    course.auditor = courseTable.cell(4, 3).text  #审核人
    return course
コード例 #2
0
ファイル: views.py プロジェクト: u5s10/Projekt-zespolowy
def create_course_view(request):
    context = {}
    if request.method == 'POST':
        course_form = CourseCreateForm(request.POST,
                                       request.FILES,
                                       instance=request.user)

        course = Course()
        if course_form.is_valid():
            data = course_form.cleaned_data
            course.name = data['name']
            course.target_language = data['target_language']
            course.source_language = data['source_language']
            course.description = data['description']
            course.author = request.user
            if (data['image']):
                course.image = data['image']

            try:
                course.save()
                return redirect('course:detail', course.slug)
            except IntegrityError:
                print("error")
                context[
                    'course_error'] = "You have already created a course with this name. Choose a different one."
    else:
        course_form = CourseCreateForm(instance=request.user)

    context['course_form'] = course_form

    return render(request, 'course/create_course.html', context)
コード例 #3
0
def pasth(request):
    context = RequestContext(request)
    if request.user.is_authenticated():
        data = request.POST.get('test')
        results = list()
        pq = PyQuery(data)
        coursesFound = 0
        tempSchedule = Schedule()
        for c in pq('tr'):
            results.append(pq(c).text())

            #find out if this is class data
            query = "COURSE SECT GRADE CREDIT CREDIT EARNED CREDIT FOR GPA COURSE TITLE"

            if pq(c).text(
            ) == query:  #go through the page to find when courses first appear
                coursesFound = 1
                #print "found courses" #debug log

            else:  #if it is not a header then do this
                if coursesFound == 1:  #if it is not a header AND courses have already been found, parse them
                    coursedata = pq(c)
                    pastClass = Course()  #temp class object
                    for d in coursedata(
                            'td'):  # break the tr down into it's td values
                        #print coursedata(d).text() #debugging logs

                        length = len(
                            coursedata(d).text()
                        )  #get the length of the data so we know what field it is

                        if length == 8:
                            pastClass.name = coursedata(d).text()
                        else:
                            if length == 4:
                                pastClass.section = coursedata(
                                    d).text()  #0000 for transfer classes
                            else:
                                if length == 1 or length == 2:
                                    pastClass.finalgrade = coursedata(d).text()
                                else:
                                    if length == 3:
                                        pastClass.cedits = coursedata(d).text(
                                        )  #note: there can be multiple credit fields (credits earned, for gpa, credits), we are grabbing the very last one
                                    else:
                                        pastClass.cname = coursedata(d).text()
                    tempSchedule.add(pastClass)

        user_profile = request.user.get_profile()
        user_profile.pastHistory = tempSchedule
        #go to user profile and add tempschedule

        return render_to_response('pasth.html', {
            "results": results,
        },
                                  context_instance=context)

    else:
        return render_to_response('nsi.html', context_instance=context)
コード例 #4
0
ファイル: views.py プロジェクト: CrypticGator/sGator
def pasth(request):
    context = RequestContext(request)
    if request.user.is_authenticated(): 
        data = request.POST.get('test')
        results = list()
        pq = PyQuery(data)
        coursesFound = 0;
        tempSchedule = Schedule()
        for c in pq('tr'):
            results.append(pq(c).text())
	
			#find out if this is class data
            query = "COURSE SECT GRADE CREDIT CREDIT EARNED CREDIT FOR GPA COURSE TITLE"
			
			
            if pq(c).text() == query: #go through the page to find when courses first appear 
				coursesFound = 1
				#print "found courses" #debug log
				
            else: #if it is not a header then do this
				if coursesFound == 1: #if it is not a header AND courses have already been found, parse them
					coursedata = pq(c)
					pastClass = Course() #temp class object 
					for d in coursedata('td'): # break the tr down into it's td values
						#print coursedata(d).text() #debugging logs 
						
						length = len(coursedata(d).text()) #get the length of the data so we know what field it is
						
						if length == 8:
							pastClass.name = coursedata(d).text()
						else: 
							if length == 4:
								 pastClass.section = coursedata(d).text() #0000 for transfer classes
							else:
								if length == 1 or length == 2:
									pastClass.finalgrade = coursedata(d).text() 
								else:
									if length == 3:
										pastClass.cedits = coursedata(d).text() #note: there can be multiple credit fields (credits earned, for gpa, credits), we are grabbing the very last one 
									else:
										pastClass.cname = coursedata(d).text()
					tempSchedule.add(pastClass)
						
        user_profile = request.user.get_profile()				
        user_profile.pastHistory = tempSchedule; #go to user profile and add tempschedule	
			
        return render_to_response('pasth.html', {"results": results,}, context_instance=context)

    else:
        return render_to_response('nsi.html', context_instance=context)
コード例 #5
0
def createRelationBetweenCourseAndCourse(courseObject, couseName, graph):
    # 从数据库中查找特点node
    prerequisiteCourseNode = graph.nodes.match('Course',
                                               name=couseName).first()
    if prerequisiteCourseNode:
        # 将node转换为对象
        prerequisiteCourse = courseObject.wrap(prerequisiteCourseNode)
    else:
        try:
            from course.models import Course
            prerequisiteCourse = Course()
        except Exception as e:
            print(e)
        prerequisiteCourse.name = couseName
    # 构建关系
    courseObject.Prerequisite.add(prerequisiteCourse)
コード例 #6
0
            teacher = newteacher
    except:
        a = User.objects.create_user(teacher, "*****@*****.**", "jtdxjwk")
        newteacher = Teacher()
        newteacher.teacher = a
        newteacher.is_teacher = True
        newteacher.save()
        teacher = newteacher
        print("we have save a new user %r" % teacher, end="||")

    from course.models import Course
    try:
        course = Course.objects.get(name=course)
    except:
        newcourse = Course()
        newcourse.name = course
        newcourse.teacher = theuser
        newcourse.save()
        course = newcourse

    from teachingtask.models import TeachingTask, Semester
    try:
        semester = Semester.objects.get(semester_year=semester_year,
                                        semester_period=semester_period)
    except:
        newsemester = Semester()
        newsemester.semester_year = semester_year
        newsemester.semester_period = semester_period
        newsemester.save()
        semester = newsemester
コード例 #7
0
ファイル: updb.py プロジェクト: Fireworks/sGator
    def handle(self, *args, **options):
        updateR = False
        if options['rating']:
            updateR = True
        url = "http://www.registrar.ufl.edu/soc/201401/all/"
        page = urllib2.urlopen(url)
        soup = BeautifulSoup(page)
        list1 = list()  # list of categories
        list2 = list()  #list of website endings
        soup2 = [option.get('value') for option in soup.findAll('option')]
        contents = [str(x.text) for x in soup.find_all('option')]
        x = 0
        for value in contents:
            # all option values all DEPARTMENTS
            list1.append(value)

        for value in soup2:
            # all endings for the web addresses per department
            list2.append(value)

        for idx, website in enumerate(list2):
            temp1 = website.strip()
            if not not temp1:
                print "OPENING: " + url + website
                page = urllib2.urlopen(url + website)
                pages = str(page.read())

                started = False
                moveA = False
                count = 0
                y = 0
                g = Course('0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                           '0', '0', '0', '0', '0', '0')
                pq = PyQuery(pages)
                tag = pq('td')
                index = list2.index(website)

                for c in pq('td'):
                    if (pq(c).text().__len__() == 8 and pq(c).text()[3:4]
                            == " ") or (pq(c).text().__len__() == 9
                                        and pq(c).text()[3:4] == " "):
                        y = 0
                        x = x + 1

                        if g.name != '0':
                            g.dept = list1[
                                index]  # Department added to each course
                            g.save()

                        g = Course(x, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
                                   ' ', ' ', ' ', ' ', ' ', ' ', ' ')
                        g.name = pq(c).text()
                        started = True
                        moveA = False

                    if (not (pq(c).text().__len__() == 8
                             and pq(c).text()[3:4] == " ") or
                        (pq(c).text().__len__() == 9
                         and pq(c).text()[3:4] == " ")) and started == True:
                        y = y + 1
                        if y == 7 and moveA != True:
                            g.lday = pq(c).text()
                        if y == 21 and moveA != True:
                            g.dday = pq(c).text()
                        if y == 22 and moveA != True:
                            g.dtime = pq(c).text()
                        if y == 23 and moveA != True:
                            g.dbuild = pq(c).text()
                        if y == 24 and moveA != True:
                            g.droom = pq(c).text()
                        if y == 5 and moveA != True:
                            if (len(pq(c).text()) == 0) or (len(pq(c).text())
                                                            == 1):
                                moveA = True
                            else:
                                g.section = pq(c).text()
                        if y == 6 and moveA != True:
                            g.cedits = pq(c).text()
                        if y == 8 and moveA != True:
                            g.ltime = pq(c).text()
                        if y == 9 and moveA != True:
                            g.lbuild = pq(c).text()
                        if y == 10 and moveA != True:
                            g.lroom = pq(c).text()
                        if y == 12 and moveA != True:
                            g.cname = pq(c).text()
                        if y == 13 and moveA != True:
                            g.cinst = pq(c).text()
                            if updateR:
                                g.rmpr = getrmp(g.cinst, count)
                                count = count + 1

                        if y == 6 and moveA == True:
                            g.section = pq(c).text()
                        if y == 7 and moveA == True:
                            g.cedits = pq(c).text()
                        if y == 9 and moveA == True:
                            g.ltime = pq(c).text()
                        if y == 22 and moveA == True:
                            g.dday = pq(c).text()
                        if y == 23 and moveA == True:
                            g.dtime = pq(c).text()
                        if y == 24 and moveA == True:
                            g.dbuild = pq(c).text()
                        if y == 25 and moveA == True:
                            g.dbuild = pq(c).text()
                        if y == 8 and moveA == True:
                            g.lday = pq(c).text()
                        if y == 10 and moveA == True:
                            g.lbuild = pq(c).text()
                        if y == 11 and moveA == True:
                            g.lroom = pq(c).text()
                        if y == 13 and moveA == True:
                            g.cname = pq(c).text()
                        if y == 14 and moveA == True:
                            g.cinst = pq(c).text()
                            if updateR:
                                g.rmpr = getrmp(g.cinst, count)
                                count = count + 1

                        if y == 36 and moveA == True:
                            g.d2day = pq(c).text()
                        if y == 37 and moveA == True:
                            g.d2time = pq(c).text()
                        if y == 38 and moveA == True:
                            g.d2build = pq(c).text()
                        if y == 39 and moveA == True:
                            g.d2room = pq(c).text()
コード例 #8
0
ファイル: updb.py プロジェクト: CrypticGator/sGator
    def handle(self, *args, **options):
            updateR = False
            if options['rating']:
                updateR = True    
            url = "http://www.registrar.ufl.edu/soc/201401/all/"
            page = urllib2.urlopen(url)
            soup = BeautifulSoup(page)
            list1 = list()      # list of categories
            list2 = list()      #list of website endings
            soup2 = [option.get('value') for option in soup.findAll('option')]
            contents = [str(x.text) for x in soup.find_all('option')]
            x = 0
            for value in contents:
                # all option values all DEPARTMENTS
                list1.append(value)
                
            for value in soup2:
                # all endings for the web addresses per department 
                list2.append(value)

            for idx, website in enumerate(list2):
                temp1 = website.strip()
                if not not temp1:
                    print "OPENING: " + url + website
                    page = urllib2.urlopen(url+ website)
                    pages = str( page.read()) 
                    
                    started = False
                    moveA = False
                    count = 0
                    y = 0
                    g = Course('0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0')
                    pq = PyQuery(pages)
                    tag = pq('td')
                    index = list2.index(website)
                    
                    for c in  pq('td'):
                        if (pq(c).text().__len__() == 8 and pq(c).text()[3:4] == " ") or (pq(c).text().__len__() == 9 and pq(c).text()[3:4] == " "):
                                y = 0
                                x= x+1
                                
                                if g.name != '0':
                                    g.dept = list1[index] # Department added to each course
                                    g.save()
                                    
                                g = Course(x,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
                                g.name = pq(c).text()
                                started = True
                                moveA = False
                                
                        if (not (pq(c).text().__len__() == 8 and pq(c).text()[3:4] == " ") or (pq(c).text().__len__() == 9 and pq(c).text()[3:4] == " ")) and started == True:
                                y = y+1
                                if y == 7 and moveA != True:
                                     g.lday = pq(c).text()
                                if y == 21 and moveA != True:
                                     g.dday = pq(c).text()
                                if y == 22 and moveA != True:
                                     g.dtime = pq(c).text()
                                if y == 23 and moveA != True:
                                     g.dbuild = pq(c).text()
                                if y == 24 and moveA != True:
                                     g.droom = pq(c).text()
                                if y == 5 and moveA != True:
                                     if (len(pq(c).text()) == 0) or (len(pq(c).text()) == 1):
                                             moveA = True
                                     else: g.section = pq(c).text()
                                if y == 6 and moveA != True:
                                     g.cedits = pq(c).text()
                                if y == 8 and moveA != True:
                                     g.ltime = pq(c).text()
                                if y == 9 and moveA != True:
                                     g.lbuild = pq(c).text()
                                if y == 10 and moveA != True:
                                     g.lroom = pq(c).text()
                                if y == 12 and moveA != True:
                                     g.cname = pq(c).text()
                                if y == 13 and moveA != True:
                                     g.cinst = pq(c).text()
                                     if updateR:
                                         g.rmpr = getrmp(g.cinst,count)
                                         count = count +1
                                     
                                if y == 6 and moveA == True:
                                     g.section = pq(c).text()
                                if y == 7 and moveA == True:
                                     g.cedits = pq(c).text()
                                if y == 9 and moveA == True:
                                     g.ltime = pq(c).text()
                                if y == 22 and moveA == True:
                                     g.dday = pq(c).text()
                                if y == 23 and moveA == True:
                                     g.dtime = pq(c).text()
                                if y == 24 and moveA == True:
                                     g.dbuild = pq(c).text()
                                if y == 25 and moveA == True:
                                     g.dbuild = pq(c).text()
                                if y == 8 and moveA == True:
                                     g.lday = pq(c).text()
                                if y == 10 and moveA == True:
                                     g.lbuild = pq(c).text()
                                if y == 11 and moveA == True:
                                     g.lroom = pq(c).text()
                                if y == 13 and moveA == True:
                                     g.cname = pq(c).text()
                                if y == 14 and moveA == True:
                                     g.cinst = pq(c).text()
                                     if updateR:
                                         g.rmpr = getrmp(g.cinst,count)
                                         count = count +1
                                         
                                if y == 36 and moveA == True:
                                     g.d2day = pq(c).text()
                                if y == 37 and moveA == True:
                                     g.d2time = pq(c).text()
                                if y == 38 and moveA == True:
                                     g.d2build = pq(c).text()
                                if y == 39 and moveA == True:
                                     g.d2room = pq(c).text()
コード例 #9
0
def main():
    from django.contrib.auth.models import User
    from course.models import Course, CourseInstance, CourseModule
    from course.models import Enrollment, StudentGroup, LearningObjectCategory
    from exercise.exercise_models import BaseExercise
    from exercise.submission_models import Submission

    now = timezone.now()
    year_later = now + timedelta(days=365)

    user0 = User(id=500)
    user0.username = '******'
    user0.first_name = 'Perry'
    user0.last_name = 'Cash'
    user0.email = '*****@*****.**'
    user0.set_password('percash0')
    user0.save()

    user1 = User(id=501)
    user1.username = '******'
    user1.first_name = 'Zorita'
    user1.last_name = 'Alston'
    user1.email = '*****@*****.**'
    user1.set_password('zoralst1')
    user1.save()

    user2 = User(id=502)
    user2.username = '******'
    user2.first_name = 'Cameron'
    user2.last_name = 'Stein'
    user2.email = '*****@*****.**'
    user2.set_password('camstei2')
    user2.save()

    user3 = User(id=503)
    user3.username = '******'
    user3.first_name = 'Brynne'
    user3.last_name = 'Pollard'
    user3.email = '*****@*****.**'
    user3.set_password('brypoll3')
    user3.save()

    user4 = User(id=504)
    user4.username = '******'
    user4.first_name = 'Allistair'
    user4.last_name = 'Blackburn'
    user4.email = '*****@*****.**'
    user4.set_password('allblac4')
    user4.save()

    user5 = User(id=505)
    user5.username = '******'
    user5.first_name = 'Zachary'
    user5.last_name = 'Bolton'
    user5.email = '*****@*****.**'
    user5.set_password('zacbolt5')
    user5.save()

    user6 = User(id=506)
    user6.username = '******'
    user6.first_name = 'Kelsie'
    user6.last_name = 'Wolf'
    user6.email = '*****@*****.**'
    user6.set_password('kelwolf6')
    user6.save()

    user7 = User(id=507)
    user7.username = '******'
    user7.first_name = 'John'
    user7.last_name = 'McCarty'
    user7.email = '*****@*****.**'
    user7.set_password('johmcca7')
    user7.save()

    user8 = User(id=508)
    user8.username = '******'
    user8.first_name = 'Sheila'
    user8.last_name = 'Rodriquez'
    user8.email = '*****@*****.**'
    user8.set_password('sherodr8')
    user8.save()

    user9 = User(id=509)
    user9.username = '******'
    user9.first_name = 'Cassady'
    user9.last_name = 'Stanley'
    user9.email = '*****@*****.**'
    user9.set_password('casstan9')
    user9.save()

    course0 = Course()
    course0.name = 'Test Course'
    course0.url = 'test-course'
    course0.save()

    instance0 = CourseInstance(id=100, course=course0)
    instance0.instance_name = 'Test Instance'
    instance0.url = 'test-instance'
    instance0.starting_time = now
    instance0.ending_time = year_later
    instance0.save()

    Enrollment.objects.create(course_instance=instance0, user_profile=user0.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user1.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user2.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user3.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user4.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user5.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user6.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user7.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user8.userprofile)
    Enrollment.objects.create(course_instance=instance0, user_profile=user9.userprofile)

    group0 = StudentGroup.objects.create(id=200, course_instance=instance0)
    group0.members.add(user0.userprofile)
    group0.members.add(user1.userprofile)
    group0.save()

    group1 = StudentGroup.objects.create(id=201, course_instance=instance0)
    group1.members.add(user0.userprofile)
    group1.members.add(user2.userprofile)
    group1.members.add(user3.userprofile)
    group1.save()

    group2 = StudentGroup.objects.create(id=202, course_instance=instance0)
    group2.members.add(user1.userprofile)
    group2.members.add(user4.userprofile)
    group2.save()

    group3 = StudentGroup.objects.create(id=203, course_instance=instance0)
    group3.members.add(user5.userprofile)
    group3.members.add(user6.userprofile)
    group3.members.add(user7.userprofile)
    group3.members.add(user8.userprofile)
    group3.save()

    module0 = CourseModule(course_instance=instance0)
    module0.name = "First module"
    module0.url = "first-module"
    module0.opening_time = now
    module0.closing_time = year_later
    module0.save()

    module1 = CourseModule(course_instance=instance0)
    module1.name = "Second module"
    module1.url = "second-module"
    module1.opening_time = now
    module1.closing_time = year_later
    module1.save()

    category0 = LearningObjectCategory(course_instance=instance0)
    category0.name = "Some category"
    category0.save()

    exercise0 = BaseExercise(id=300, course_module=module0, category=category0)
    exercise0.name = "Easy exercise"
    exercise0.url = 'easy-exercise'
    exercise0.max_submissions = 10
    exercise0.max_group_size = 4
    exercise0.max_points = 100
    exercise0.points_to_pass = 50
    exercise0.save()

    exercise1 = BaseExercise(id=301, course_module=module0, category=category0)
    exercise1.name = "Hard exercise"
    exercise1.url = 'hard-exercise'
    exercise1.max_submissions = 5
    exercise0.max_group_size = 2
    exercise1.max_points = 100
    exercise1.points_to_pass = 100
    exercise1.save()

    exercise2 = BaseExercise(id=302, course_module=module1, category=category0)
    exercise2.name = "Nice exercise"
    exercise2.url = 'nice-exercise'
    exercise2.max_submissions = 0
    exercise2.max_points = 10
    exercise2.points_to_pass = 0
    exercise2.save()

    submission0 = Submission.objects.create(id=400, exercise=exercise0)
    submission0.submitters.add(user0.userprofile)
    submission0.submitters.add(user1.userprofile)
    submission0.feedback = '<html><body>Not bad.</body></html>'
    submission0.set_points(40, 100)
    submission0.set_ready()
    submission0.save()

    submission1 = Submission.objects.create(id=401, exercise=exercise0)
    submission1.submitters.add(user0.userprofile)
    submission1.submitters.add(user1.userprofile)
    submission1.feedback = '<html><body>Good.</body></html>'
    submission1.set_points(60, 100)
    submission1.set_ready()
    submission1.save()

    submission2 = Submission.objects.create(id=402, exercise=exercise0)
    submission2.submitters.add(user1.userprofile)
    submission2.submitters.add(user4.userprofile)
    submission2.feedback = '<html><body>Good.</body></html>'
    submission2.set_points(50, 100)
    submission2.set_ready()
    submission2.save()

    submission3 = Submission.objects.create(id=403, exercise=exercise2)
    submission3.submitters.add(user0.userprofile)
    submission3.feedback = '<html><body>Excellent.</body></html>'
    submission3.set_points(10, 10)
    submission3.set_ready()
    submission3.save()