コード例 #1
0
ファイル: Publisher.py プロジェクト: timdams/moodle-book
 def publishTopic(self, topic):
     topicFolder = os.getcwd()
     courseFolder, topicFolderName = os.path.split(topicFolder)
     os.chdir(courseFolder)
     course = Course()
     os.chdir(topicFolder)
     self.publishTopicInCourse(course, topic)
コード例 #2
0
 def add_course(self, name, subject, language, author):
     course = Course()
     course.name = name
     course.subject = subject
     course.language = language
     course.author = author
     self.session.add(course)
コード例 #3
0
ファイル: program.py プロジェクト: Nicolas1936/bstorm_ai
from models.Course import Course
from models.Concurrent import Concurrent
from models.Voiture import Voiture
from models.Circuit import Circuit

if __name__ == "__main__":

    spa = Circuit("Spa", 7004, 20)

    c = Course("TechnoBel", spa, 5, 42)

    v_nico = Voiture("Audi", "R8", 180, 260)
    nico = Concurrent("Nico", 7, v_nico)
    c.ajouter_participant(nico)

    mh = Concurrent("Marc-Henry", 21, Voiture("Tesla", "S", 220, 240))
    c.ajouter_participant(mh)

    c.ajouter_participant(
        Concurrent("François", 10, Voiture("Porsche", "911", 225, 230)))

    c.demarrer_course()

    for concurrent in c.concurrents:
        print(concurrent.nom, concurrent.temps_total)

    winner = c.obtenir_vainqueur()
    print(winner.se_decrire())
コード例 #4
0
def home():
    form = AddUserForm()
    if form.validate_on_submit():
        results = request.form

        global courses

        course_name = results['subject']
        course_number = results['course_no']
        course_section = results['course_section']

        new_course = Course(course_name, course_number, course_section)

        course_status = is_course_available(
            new_course
        )  # checks if course is already available or if it is on SSC
        if course_status != False:
            if course_status == True:
                return render_template('error.html',
                                       message='Course is already available!')
            elif course_status == 'Course does not exist!':
                return render_template('error.html', message=course_status)

        student_name = results['name']
        student_surname = results['surname']
        student_email = results['email']

        student = Student(student_name, student_surname, student_email)

        # gets the course from courses if the course exists, otherwise returns None
        existing_course = next(
            (course for course in courses if course == new_course), None)
        try:
            if existing_course is not None:
                add_student_to_course(existing_course, student)
            else:
                num_courses_in_db = get_number_of_courses()

                # Checks if the db and list is synchronized
                if len(courses) == num_courses_in_db:
                    courses.append(new_course)
                    add_student_to_course(new_course, student)
                else:
                    courses = get_courses()
                    existing_course = next(
                        (course for course in courses if course == new_course),
                        None)
                    if existing_course is not None:
                        add_student_to_course(existing_course, student)
                    else:
                        courses.append(new_course)
                        add_student_to_course(new_course, student)

        except StudentExistsException:
            return render_template(
                'error.html',
                message='A student with this email address exists.')
        except Exception as e:
            logging.error('Registration error', exc_info=True)
            return render_template(
                'error.html',
                message=
                'An error occurred during registration. Please try again.')
        return render_template('result.html')

    return render_template('seat_checker.html', form=form)
コード例 #5
0
ファイル: mb.py プロジェクト: timdams/moodle-book
    from os import path
    from controllers.App import App
    from models.Profile import Profile
    from models.Course import Course
    from models.Topic import Topic
    from models.Book import Book

    app = App(path.dirname(path.realpath(__file__)))

    if path.exists('profile.md'):
        print('Publishing Profile')
        profile = Profile()
        app.publishProfile(profile)
    else:
        if path.exists('course.md'):
            print('Publishing full course')
            course = Course()
            app.publishCourse(course)
        else:
            if path.exists('topic.md'):
                print('Publishing topic + contained books')
                fullPath = os.getcwd()
                path, folder = os.path.split(fullPath)
                topic = Topic(folder)
                app.publishTopic(topic)
            else:
                print('Publishing single book')
                book = Book()
                app.publishBook(book)
                app.publishLab(book)
コード例 #6
0
 def add_course_from_csv(self, course_headers, course_data):
     course = Course()
     course.from_csv(course_headers, course_data)
     self.session.add(course)