Beispiel #1
0
def make_exam(bank_set):
    """Creates a list of exam images to use from the bank set
    
    Images names are encoded with rot13 and cut to 10 characters. A file is printed
    with new names for reference, the terminal commands to copy the files into a
    new directory with the new names, and then the bank set is passed onto make_mulch
    to create the list of test questions as per usual.
    """
    conversion = []
    bash = []
    exam_bank = []
    for unit in bank_set:
        for item in unit:
            r13 = item[1].encode('rot13')
                # take out dates cut to 10 char max and return to jpg 
            r13 = re.sub('.wct','',r13)
            r13 = re.sub(r'\.\d+\-?\d*.\.','',r13)
            if  len(r13) > 10:
                r13 = r13[:10]
            r13 = r13 + '.jpg'
            conversion.append(item[1] + " --> " + r13)
            bash.append("cp " + item[1] + " _exam/" + r13)
            exam_bank.append((item[0],r13))
    file_name = "../images/_exam_notes.txt"
    title = "Exam Images Key:"
    write_to_file(conversion,file_name,title, mode='a')
    title = "Bash Commands for file rename:"
    write_to_file(bash,file_name,title, mode='a')
    make_mulch(exam_bank,[exam_bank])
Beispiel #2
0
def make_mulch(test_set, bank_set):
    """Creates a list of artists from unit lists of artists/image tuples
    
    test_set is the unit set to test, example: u2set
    bank_set is a list of all units to draw answers from, ex: [u1set,u2set,...]
    """
    bank = load_bank(bank_set)
    blen = len(bank) - 1    
    file_name = "../md/_multichoice.txt"
    title = "Multiple Choice"
    l = []
    qlist = ["A.","B.","C.", "D."]
    for x in range(len(test_set)):
        l.append("Q: This Artwork is by:")
        answer_set = [test_set[x][0]]
            # load unique artists names into answer_set
        for p in range(len(qlist) - 1):
            while True:
                r = random.randint(0, blen)
                if (bank[r] not in answer_set):
                    answer_set.append(bank[r])
                    break; 
        for q in range(len(qlist)):
            l.append( qlist[q] + answer_set[q] )
        l.append("Answer: A")
        l.append("POINTS: 5")
        l.append("TYPE: MC")
        l.append("IMAGE: $COURSE_PATH$images/"+ test_set[x][1])
        l.append("\n")
    write_to_file(l,file_name,title, mode='a')