Beispiel #1
0
def result_feedback(result, feedback_settings):
    # Top level message
    msg = "{}\n".format(feedback_settings["status_message"].get(result.returncode, "Uncommon Failure"))

    # if we have a feedback, use it
    if feedback_settings["has_feedback"]:

        # JavaGrading
        if feedback_settings["feedback_kind"] == "JavaGrading":
            score_ratio, msg = extract_java_grading_result(result, feedback_settings)
            # To prevent some genius to have success grade with a prohibited
            score_ratio = 0.0 if result.returncode == 2 else score_ratio
            feedback_result(score_ratio, feedback_settings)
            feedback.set_global_feedback(msg, True)

        # JaCoCo
        if feedback_settings["feedback_kind"] == "JaCoCo":
            if result.returncode == 0:
                score_ratio, msg = extract_jacoco_result(feedback_settings)
                feedback_result(score_ratio, feedback_settings)
                message_index = 0 if score_ratio >= feedback_settings["quorum"] else 3
                msg2 = "{}\n".format(feedback_settings["status_message"].get(message_index, "Uncommon Failure"))
                feedback.set_global_feedback(msg2, True)
                feedback.set_global_feedback(rst.get_codeblock("java", msg), True)
            else:
                feedback.set_global_feedback(msg, True)
                feedback_result(0.0, feedback_settings)

    # For exercises with binary result : 0 or 100
    else:
        feedback.set_global_feedback(msg, True)
        score_ratio = 1.0 if result.returncode == 0 else 0.0
        feedback_result(score_ratio, feedback_settings)
Beispiel #2
0
 def jacoco(result, feedback_settings, msg):
     if result.returncode == 0:
         score_ratio, msg = extract_jacoco_result(feedback_settings)
         feedback_result(score_ratio, feedback_settings)
         message_index = 0 if score_ratio >= feedback_settings["quorum"] else 3
         msg2 = "{}\n".format(feedback_settings["status_message"].get(message_index, "Uncommon Failure"))
         feedback.set_global_feedback(msg2, True)
         feedback.set_global_feedback(rst.get_codeblock("java", msg), True)
     else:
         feedback.set_global_feedback(msg, True)
         feedback_result(0.0, feedback_settings)
Beispiel #3
0
# Fetch and save the student code into a file for compilation
input.parse_template("student_code.c.tpl", "student_code.c")

# Compilation
p = subprocess.Popen(shlex.split("make"),
                     stderr=subprocess.STDOUT,
                     stdout=subprocess.PIPE)
make_output = p.communicate()[0].decode('utf-8')
# If compilation failed, exit with "failed" result
if p.returncode:
    feedback.set_tag("not_compile", True)
    feedback.set_global_result("failed")
    feedback.set_global_feedback(
        "La compilation de votre code a échoué. Voici le message de sortie de la commande ``make`` :"
    )
    feedback.set_global_feedback(rst.get_codeblock('', make_output), True)
    exit(0)
else:
    # Cppcheck
    p = subprocess.Popen(shlex.split("make check"),
                         stderr=subprocess.STDOUT,
                         stdout=subprocess.PIPE)
    cppcheck_output = p.communicate()[0].decode('utf-8')
    if p.returncode:
        feedback.set_tag("cppcheck", True)
        feedback.set_global_result("failed")
        feedback.set_global_feedback(
            "La compilation de votre code avec ``cppcheck`` a échoué. Voici le message de sortie de la commande ``make check`` :"
        )
        feedback.set_global_feedback(rst.get_codeblock('', cppcheck_output),
                                     True)