예제 #1
0
def update_previous(test_version_id):
    """
    fog1477

    Some online tests don't have
    the has_previous attribute set correctly.

    Given a version update the has_previous.
    """

    # get our version
    test_version = tst.TestVersion.get(test_version_id)

    previous_section_timed = False
    for section in test_version.sections:
        # The very first section never has a previous,
        # ignore archived sections,
        # don't allow users to go back to sections that aren't
        # timed inevitably stopping the clock
        if section.position > 1 and not section.archived and previous_section_timed and not section.has_previous:
            section.has_previous = True
            set_history(section)
            log.debug("adding previous flag to Section %s Position %s", section.id, section.position)

        # update our timed flag for current section
        previous_section_timed = section.timed
예제 #2
0
def create_track_fog1465():
    """
    Create 2 batteries for Fresno School District
    """

    # get the testing account
    fresno = m.Account.get(24828).testing_account

    # the spanish tests:
    """
    In [9]: for test in fresno.tests:
        test.id, test.description, test.method.short_name
       ....:
       ....:
    Out[10]: (19707L, u'Spanish Reading Test ILR 2+ to 3+/ALTA 8 to 10', u'Online')
    Out[10]: (19708L, u'Spanish Writing Test', u'Online')
    Out[10]: (19709L, u'Spanish Writing Test', u'Paper')
    Out[10]: (19710L, u'Spanish Listening & Speaking Test', u'Live')
    """

    reading = tst.AccountTest.get(19707L)
    live = tst.AccountTest.get(19710L)
    writing_tests = []
    writing_tests.append(tst.AccountTest.get(19708L))
    writing_tests.append(tst.AccountTest.get(19709L))

    # create track
    tracks = []

    for writing_test in writing_tests:

        # create the track
        track = tst.Track()

        # describe the track
        track.description = '%s Battery RWS %s' %\
                (writing_test.test.languages[0].language, writing_test.method.description.split()[0])

        # append to list so we can return it
        tracks.append(track)

        # attributes
        track.account = fresno
        track.is_global = True

        tests = [reading, writing_test, live]
        for test in tests:
            # create our tracktests
            tracktest = tst.TrackTest()
            tracktest.account = fresno
            tracktest.track = track
            tracktest.test = test
            tracktest.position = tests.index(test)

    # update our history
    for track in tracks:
        for track_test in track.track_tests:
            set_history(track_test)
        set_history(track)

    m.meta.Session.commit()

    return tracks