Beispiel #1
0
def execute(state, plugin, argument):
    if argument == None:
        return ''

    stats = statistics.question_stats()
    nr_students = float(len(stats.all_students))

    s = []
    for question in questions.questions.values():
        norme = float(question.stats.given)
        if question.stats.given == 0:
            continue
        s.append([
            question.a_href(),
            "%6.3f" % (question.stats.given / nr_students),
            "%6.3f" % (question.stats.view / norme),
            "%6.3f" % (question.stats.good / norme),
            "%6.3f" % (question.stats.bad / norme),
            "%6.3f" % (question.stats.indice / norme),
            utilities.time_format(question.student_time / norme),
            "%6.3f" % (question.stats.nr_comment / norme),
            "%5d" % question.perfect_time,
        ])

    if s:
        plugin.heart_content = \
               utilities.sortable_table(plugin.sort_column, s,
                                  url = "%s&%s=1" % (plugin.plugin.css_name, plugin.plugin.css_name))
        state.question = None

    return ''
Beispiel #2
0
def execute(state, plugin, argument):
    if argument == None:
        return ''

    stats = statistics.question_stats()
    
    comments = []
    for s in stats.all_students:
        for a in s.answers.values():
            q = questions.a_href(a.question).replace(' ',' ')
            for c in a.comments:
                comments.append( [
                    q,
                    cgi.escape(c[1]),
                    s.a_href(body=c[1]),
                    utilities.date_format(c[0]).replace(' ',' ')])


    plugin.heart_content = \
             utilities.sortable_table(plugin.sort_column,
                                      comments,
                                      url = "%s&%s=1" % (plugin.plugin.css_name, plugin.plugin.css_name)
                                      )
    state.question = None

    return ''
Beispiel #3
0
def execute(state, plugin, argument):
    if not state.question:
        return
    stats = statistics.question_stats()
    columns = set()
    for s in stats.all_students:
        a = s.answer(state.question.name)
        if a.answered:
            for k in a.grades:
                if a.grades[k] != '0':
                    columns.add(k)
    columns = sorted(columns)

    table = []
    for s in stats.all_students:
        a = s.answer(state.question.name)
        if not a.answered:
            continue
        table.append([utilities.answer_format(a.answered)] +
                     [a.grades.get(c, 0) for c in columns])

    return utilities.sortable_table(plugin.sort_column,
                                    table,
                                    url=plugin.plugin.css_name,
                                    titles=['X'] + columns)
Beispiel #4
0
def execute(state, plugin, argument):
    if argument == None:
        return ''

    stats = statistics.question_stats()

    too_quick = collections.defaultdict(int)
    too_quick2 = collections.defaultdict(int)
    too_quick4 = collections.defaultdict(int)
    for s in stats.sorted_students:
        for question_name, answer in s.answers.items():
            if not answer.answered:
                continue
            question = questions.questions[question_name]
            average_time = question.student_time / question.stats.given
            if answer.time_searching < average_time / 10:
                too_quick[s] += 1
            if answer.time_searching < average_time / 20:
                too_quick2[s] += 1
            if answer.time_searching < average_time / 40:
                too_quick4[s] += 1

    plugin.heart_content = utilities.sortable_table(
        plugin.sort_column, [[s.a_href(), nb, too_quick2[s], too_quick4[s]]
                             for s, nb in too_quick.items()],
        url="%s&%s=1" % (plugin.plugin.css_name, plugin.plugin.css_name))

    state.question = None

    return ''
def execute(state, plugin, argument):
    if state.question == None:
        return

    teacher = state.student.filename

    if argument:
        the_student, grade = argument.split(',')
        if the_student.startswith('*'):
            the_student = the_student[1:]
            student.students[the_student].set_why(state.question.name, teacher,
                                                  grade)
        else:
            student.students[the_student].set_grade(state.question.name,
                                                    teacher, grade)
        return 'image/png', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x01sRGB\x00\xae\xce\x1c\xe9\x00\x00\x00\x0fIDAT\x08\x1d\x01\x04\x00\xfb\xff\x00\x00\xff\x00\x02\x02\x01\x00\x0b\x0e\xaa\xaf\x00\x00\x00\x00IEND\xaeB`\x82'

    stats = statistics.question_stats()

    lines = []
    for s in stats.all_students:
        a = s.answer(state.question.name)
        if not a.answered:
            continue
        last = int(a.grades.get(teacher, '-1'))
        why = a.why.get(teacher, '')

        lines.append([
            utilities.answer_format(a.answered),
            '<span><!-- %2d -->' % last + ''.join(
                '<input name="%s" type="radio" value="%d" onclick="question_correction(event)"%s>&nbsp;%d'
                % (s.filename, i, ['', ' checked'][i == last], i) + {
                    0: '',
                    1: '',
                    2: '<br>'
                }[i % 3] for i in range(6)) + '</span>',
            '<textarea rows="2" cols="40" name="*%s" onchange="question_correction(event)">%s</textarea>'
            % (s.filename, cgi.escape(why)),
        ])

    if len(lines) == 0:
        return
    return ('<noscript>!!!!!!!JAVASCRIPT NEEDED!!!!!!</noscript>' +
            utilities.sortable_table(
                plugin.sort_column,
                lines,
                url=plugin.plugin.css_name,
                html_class="question_correction_table",
            ))
Beispiel #6
0
def execute(state, plugin, argument):
    if argument == None:
        return ''

    stats = statistics.question_stats()

    pairs = []
    for s in stats.sorted_students:
        for ss in stats.sorted_students:
            if id(s) > id(ss):
                try:
                    if ss.name not in s.nr_answer_same_time:
                        continue
                    after, before = s.nr_answer_same_time[ss.name]
                    pairs.append((after, before,
                                  (100 * after)
                                  / s.the_number_of_good_answers,
                                  (100 * before)
                                  / ss.the_number_of_good_answers,
                                  s, ss))
                except KeyError:
                    pass
    if len(pairs) == 0:
         plugin.heart_content = '<p class="no_pairs_found"></p>'
         return ''
    pairs.sort(key=lambda x: x[0] + x[1])
    pairs.reverse()
    average = (sum(list(zip(*pairs))[1]) + sum(list(zip(*pairs))[2])) / len(pairs)
    average2 = sum((i[1]+i[2])**2 for i in pairs) / len(pairs)
    stddev = (average2 - average*average) ** 0.5
    
    st = []
    for after, before, nn1, nn2, s1, s2 in pairs:
        st.append([s1.a_href(), s2.a_href(),
                   after, before, '%.2f' % nn1,  '%.2f' % nn2])
        if max(nn1, nn2) < average + stddev/2: # not interesting
            break
        
    plugin.heart_content = utilities.sortable_table(
        plugin.sort_column,
        st,
        url = "%s&%s=1" % (plugin.plugin.css_name, plugin.plugin.css_name))

    state.question = None

    return ''
Beispiel #7
0
def execute(state, plugin, argument):
    if argument == None:
        return ''

    stats = statistics.question_stats()

    content = []
    for s in stats.all_students:
        nr_good_answers = (styles[s.warning_nr_good_answers],
                           s.the_number_of_good_answers)
        nr_bad_answers = (styles[s.warning_nr_bad_answers],
                          s.the_number_of_bad_answers)
        nr_given_indices = (styles[s.warning_nr_given_indices],
                            s.the_number_of_given_indices)
        time_after = (styles[s.warning_time_after],
                      utilities.time_format(s.the_time_after))

        line = [
            s.a_href(),
            nr_good_answers,
            s.the_number_of_given_questions,
            nr_bad_answers,
            nr_given_indices,
            s.the_number_of_comment,
            utilities.time_format(s.the_time_searching),
            time_after,
            utilities.date_format(s.the_time_first),
            utilities.date_format(s.the_time_last),
            "%3.1f" % s.nr_of_same_time_normed,
            int(s.the_time_variance),
            s.logs and s.logs[-1][1] or '?',
        ]

        # line.append('<img src="?action=question_pixel_map_see_other&student=%s">' % s.filename)

        content.append(line)

    plugin.heart_content = \
         utilities.sortable_table(plugin.sort_column,
                                  content,
                                  url = "%s&%s=1" % (plugin.plugin.css_name,
                                                     plugin.plugin.css_name))
    state.question = None

    return ''
Beispiel #8
0
def execute(state, plugin, argument):
    if state.question == None:
        return

    stats = statistics.question_stats()
    
    comments = []
    for s in stats.all_students:
        for a in s.answers.values():
            if a.question != state.question.name:
                continue
            for c in a.comments:
                comments.append( [cgi.escape(c[1]),
                                  s.mailto(body=str(a.question) + "  " + c[1]),
                                  utilities.date_format(c[0])])

    if len(comments) == 0:
        return None
    return utilities.sortable_table(plugin.sort_column, comments,
                                    url=plugin.plugin.css_name
                                    )
Beispiel #9
0
def the_options(state, m_plugin):
    t = []
    for plugin in state.plugins_list:
        a_plugin = plugin.plugin
        name = a_plugin["", "option_name"]
        if name:
            hlp = a_plugin[state.localization, "option_help"]
            hlp = hlp.split('\n', 1)
            hlp = '<b>' + hlp[0] + '</b><br>' + hlp[1]
            t.append([
                '<b>' + name + '</b><br><small>' + a_plugin.css_name,
                hlp,
                a_plugin[state.localization, "option_default"],
                '<TEXTAREA name="option__%s">' % a_plugin.css_name +
                html.escape(plugin.option) + '</TEXTAREA>',
            ])

    button = '<BUTTON type="submit" class="save_options" name="%s" value="set"></BUTTON>' % m_plugin.plugin.css_name

    return ('<FORM action="?">' + button +
            utilities.sortable_table(m_plugin.sort_column, t) + button +
            '</FORM>')
Beispiel #10
0
def acl_page(plugin, user):
    # Plugins.acls.acls.update_student_acls(student.students[user])
    acls = []
    roles = [user]
    stop = False
    while not stop:
        stop = True
        a_student = student.students[roles[-1]]
        Plugins.role.role.update_roles(a_student)
        Plugins.acls.acls.update_student_acls(a_student)
        for role in a_student.roles[::-1]:
            if role != 'Wired' and role not in roles:
                roles.append(role)
                stop = False

    t = []
    for plugin_name, a_plugin in plugins.Plugin.plugins_dict.items():
        line = [
            plugin_name,
            a_plugin.default_container(),
            ('class="doc"', a_plugin.plugin.__doc__)
        ]
        if 'executable' in a_plugin.plugin.acls.get('Wired', ()):
            for role in roles:
                line.append('')
        else:
            for role in roles:
                a = student.students[role].acls.get_an_acl(
                    plugin_name, 'executable')
                if role == roles[0]:
                    aa = '<select name="' + plugin_name + '"><option'
                    if a is None:
                        aa += ' selected'
                    aa += '></option><option'
                    if a is False:
                        aa += ' selected'
                    aa += '>Reject</option><option'
                    if a is True:
                        aa += ' selected'
                    aa += '>Allow</option></select>'
                else:
                    aa = {None: '', False: 'Reject', True: 'Allow'}[a]
                    aa = '<b>' + aa + '</b>'
                acl = a_plugin.plugin.acls.get(role, ())
                if 'executable' in acl:
                    b = 'Allow'
                elif '!executable' in acl:
                    b = 'Reject'
                else:
                    b = ''
                line.append((' class="nowrap"', aa + '/' + b))
        t.append(line)

    titles = ['Plugin', 'Container', 'Documentation']
    for role in roles:
        titles.append(role + '<br><tt class="roles">' +
                      ' '.join(student.students[role].roles) + '</tt>')

    return (
        '<form id="acls_form" action="javascript:change_acls(\'' + user +
        '\')">' +
        '<button type="submit" class="change_acl_save" value=""></button>' +
        utilities.sortable_table(
            plugin.sort_column,
            t,
            url="%s&%s=%s" %
            (plugin.plugin.css_name, plugin.plugin.css_name, user),
            titles=titles) +
        '<button type="submit" class="change_acl_save" value="x"></button>' +
        '</form>')