Exemplo n.º 1
0
def add_lab1_assignment():
    assignment = Assignment(
        name="Lab 1",
        semester="sp14",
        href=
        "https://docs.google.com/document/d/1RA0P097KZLwZp_zAB63HOQVCcE5z8W6p9osu3HjGjww/pub",
        description="",
        deadline=datetime(2014, 2, 19, 17, 59),
        points=5)
    db.session.add(assignment)
    db.session.commit()
    print colored('lab 1 assignment added to database', "green")
Exemplo n.º 2
0
def add_homework4():
    assignment = Assignment(name="Homework 4",
                            semester="sp14",
                            href="/homework/calendar/",
                            description="",
                            deadline=datetime(2014, 4, 9, 23, 59),
                            points=8)
    db.session.add(assignment)
    db.session.commit()
    homework4 = Homework(week=7,
                         deadline=assignment.deadline,
                         assignment_id=assignment.id)
    db.session.add(homework4)
    db.session.commit()
    print colored('homework 4 and assignment added to database', "green")
Exemplo n.º 3
0
def add_quiz1_assignment():
    quiz1 = Quiz.query.filter_by(week=1).first()
    num_questions = QuizQuestion.query.filter_by(quiz_id=quiz1.id).count()
    assignment1 = Assignment(name="Quiz 1",
                             semester="sp14",
                             href="/quiz/1/",
                             description="",
                             deadline=quiz1.deadline,
                             points=num_questions)
    db.session.add(assignment1)
    db.session.commit()
    quiz1.assignment_id = assignment1.id
    db.session.add(quiz1)
    db.session.commit()
    print colored('quiz 1 assignment added to database', "green")
Exemplo n.º 4
0
def add_quiz5():
    assignment = Assignment(name="Quiz 5",
                            semester="sp14",
                            href="/quiz/5/",
                            description="",
                            deadline=datetime(2014, 3, 12, 18, 59),
                            points=3)
    db.session.add(assignment)
    db.session.commit()

    quiz5 = Quiz(name="Week 5 Quiz",
                 week=5,
                 deadline=assignment.deadline,
                 assignment_id=assignment.id)

    question1 = QuizQuestion(
        question=
        "Consider the following function definition:<br><br>var hotdogs = function(num) {<br>&nbsp;&nbsp;for (var i = 0; i <= num; i++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;console.log(i);<br>&nbsp;&nbsp}<br>};<br><br>What does the following code print?",
        answer_choices=json.dumps([{
            'id':
            'A',
            'answer':
            'Nothing gets printed because the function is never called'
        }, {
            'id': 'B',
            'answer': 'Every number from 0 to num'
        }, {
            'id': 'C',
            'answer': '0 1 2 3 4 5 6'
        }, {
            'id': 'D',
            'answer': '0'
        }]),
        solution='A')

    question2 = QuizQuestion(
        question=
        "Consider the following function definition:<br><br>var hotdogs = function(num) {<br>&nbsp;&nbsp;for (var i = 0; i <= num; i++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;console.log(i);<br>&nbsp;&nbsp}<br>};<br>hotdogs(10);<br><br>What does the following code print?",
        answer_choices=json.dumps([{
            'id':
            'A',
            'answer':
            'Nothing gets printed because the function is never called'
        }, {
            'id': 'B',
            'answer': '0 1 2 3 4 5 6 7 8 9 10'
        }, {
            'id': 'C',
            'answer': '0 1 2 3 4 5 6 7 8 9'
        }]),
        solution='B')

    question3 = QuizQuestion(
        question=
        "Consider the following function definition:<br><br>var hotdogs = function(num) {<br>&nbsp;&nbsp;for (var i = 0; i <= num; i++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;console.log(i);<br>&nbsp;&nbsp}<br>&nbsp;&nbsp;return num;<br>};<br>var x = hotdogs(3);<br>var y = hotdogs(4);<br>console.log(x + y);<br>What does the following code print?",
        answer_choices=json.dumps([{
            'id':
            'A',
            'answer':
            'Nothing gets printed because the function is never called'
        }, {
            'id': 'B',
            'answer': '0 1 2 3 0 1 2 3 4'
        }, {
            'id': 'C',
            'answer': '7'
        }, {
            'id': 'D',
            'answer': '0 1 2 3 0 1 2 3 4 7'
        }]),
        solution='D')

    quiz5.questions.append(question1)
    quiz5.questions.append(question2)
    quiz5.questions.append(question3)
    db.session.add(quiz5)
    db.session.add(question1)
    db.session.add(question2)
    db.session.add(question3)
    db.session.commit()
    print colored('quiz 5 added to database', "green")
Exemplo n.º 5
0
def add_quiz4():
    assignment = Assignment(name="Quiz 4",
                            semester="sp14",
                            href="/quiz/4/",
                            description="",
                            deadline=datetime(2014, 3, 5, 18, 59),
                            points=3)
    db.session.add(assignment)
    db.session.commit()

    quiz4 = Quiz(name="Week 4 Quiz",
                 week=4,
                 deadline=assignment.deadline,
                 assignment_id=assignment.id)

    question1 = QuizQuestion(
        question=
        "Consider the following function definition:<br><br>var window = function(sill, pane) {<br>&nbsp;&nbsp;return sill * sill + pane;<br>};<br><br>What is the name of the function?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'window'
        }, {
            'id': 'B',
            'answer': 'sill'
        }, {
            'id': 'C',
            'answer': 'pane'
        }, {
            'id': 'D',
            'answer': 'anonymous'
        }]),
        solution='A')

    question2 = QuizQuestion(
        question=
        "What are the parameters (also called arguments) of the above function?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'window'
        }, {
            'id': 'B',
            'answer': 'sill and pane'
        }, {
            'id': 'C',
            'answer': 'window, sill, and pane'
        }, {
            'id': 'D',
            'answer': 'return'
        }]),
        solution='B')

    question3 = QuizQuestion(
        question="Which of the following would print '23'?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'window(23);'
        }, {
            'id': 'B',
            'answer': 'window(4, 7);'
        }, {
            'id': 'C',
            'answer': 'window();'
        }, {
            'id': 'D',
            'answer': 'console.log(window(1, 1) + "3");'
        }]),
        solution='D')

    quiz4.questions.append(question1)
    quiz4.questions.append(question2)
    quiz4.questions.append(question3)
    db.session.add(quiz4)
    db.session.add(question1)
    db.session.add(question2)
    db.session.add(question3)
    db.session.commit()
    print colored('quiz 4 added to database', "green")
Exemplo n.º 6
0
def add_quiz3():
    assignment = Assignment(name="Quiz 3",
                            semester="sp14",
                            href="/quiz/3/",
                            description="",
                            deadline=datetime(2014, 2, 26, 18, 59),
                            points=3)
    db.session.add(assignment)
    db.session.commit()

    quiz3 = Quiz(name="Week 3 Quiz",
                 week=3,
                 deadline=assignment.deadline,
                 assignment_id=assignment.id)

    question1 = QuizQuestion(
        question=
        "Which of the following cannot be used to control program execution flow?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'if statements'
        }, {
            'id': 'B',
            'answer': 'console.log statements'
        }, {
            'id': 'C',
            'answer': 'for loops'
        }, {
            'id': 'D',
            'answer': 'while loops'
        }]),
        solution='B')

    question2 = QuizQuestion(
        question=
        "Which of the following variables is named using 'camel case' capitalization?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'fuzzylittleturtles'
        }, {
            'id': 'B',
            'answer': 'fuzzyLittleTurtles'
        }, {
            'id': 'C',
            'answer': 'FuzzyLittleTurtles'
        }, {
            'id': 'D',
            'answer': 'fuzzy_little_turtles'
        }]),
        solution='B')

    question3 = QuizQuestion(
        question=
        "What does the following code print? 'console.log(\"This is\" + 7 + \"words in a sentence.\");",
        answer_choices=json.dumps([{
            'id':
            'A',
            'answer':
            'This is + 7 + words in a sentence.'
        }, {
            'id': 'B',
            'answer': 'This is7words in a sentence.'
        }, {
            'id': 'C',
            'answer': 'This is 7 words in a sentence.'
        }, {
            'id':
            'D',
            'answer':
            '\"This is \" + 7 + \" words in a sentence.\"'
        }]),
        solution='B')

    quiz3.questions.append(question1)
    quiz3.questions.append(question2)
    quiz3.questions.append(question3)
    db.session.add(quiz3)
    db.session.add(question1)
    db.session.add(question2)
    db.session.add(question3)
    db.session.commit()
    print colored('quiz 3 added to database', "green")
Exemplo n.º 7
0
def add_quiz2():
    assignment = Assignment(name="Quiz 2",
                            semester="sp14",
                            href="/quiz/2/",
                            description="",
                            deadline=datetime(2014, 2, 19, 18, 59),
                            points=4)
    db.session.add(assignment)
    db.session.commit()

    quiz2 = Quiz(name="Week 2 Quiz",
                 week=2,
                 deadline=assignment.deadline,
                 assignment_id=assignment.id)

    question1 = QuizQuestion(
        question="How does the reading tell you to imagine variables?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'As renamed values'
        }, {
            'id': 'B',
            'answer': 'As tentacles to grasp values'
        }, {
            'id': 'C',
            'answer': 'As boxes to contain values'
        }, {
            'id': 'D',
            'answer': 'As envelopes to send values'
        }]),
        solution='B')

    question2 = QuizQuestion(
        question="Which of the following is an example of calling a function?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'alert("Star Slinger!")'
        }, {
            'id': 'B',
            'answer': 'var x = 5'
        }, {
            'id': 'C',
            'answer': 'var f = function() { }'
        }, {
            'id': 'D',
            'answer': 'All of the above'
        }]),
        solution='A')

    question3 = QuizQuestion(
        question=
        "What symbol goes at the end of every statement in JavaScript?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'Dollar Sign ($)'
        }, {
            'id': 'B',
            'answer': 'Tilde (~)'
        }, {
            'id': 'C',
            'answer': 'Equals sign (=)'
        }, {
            'id': 'D',
            'answer': 'Semicolon (;)'
        }]),
        solution='D')

    question4 = QuizQuestion(
        question="How do we print 'Hello World!' in JavaScript?",
        answer_choices=json.dumps([{
            'id': 'A',
            'answer': 'console.log("Hello World!")'
        }, {
            'id':
            'B',
            'answer':
            'System.out.println("Hello World!")'
        }, {
            'id': 'C',
            'answer': 'cout << "Hello World!" << endl'
        }, {
            'id': 'D',
            'answer': "print 'Hello World!'"
        }]),
        solution='A')

    quiz2.questions.append(question1)
    quiz2.questions.append(question2)
    quiz2.questions.append(question3)
    quiz2.questions.append(question4)
    db.session.add(quiz2)
    db.session.add(question1)
    db.session.add(question2)
    db.session.add(question3)
    db.session.add(question4)
    db.session.commit()
    print colored('quiz 2 added to database', "green")