Esempio n. 1
0
if (isset($_GET['exerciseId'])) {
    $exerciseId = intval($_GET['exerciseId']);
}

// if the object is not in the session
if (!isset($_SESSION['objExercise'][$exerciseId])) {
    // construction of Exercise
    $objExercise = new Exercise();
    // if the specified exercise doesn't exist or is disabled
    if (!$objExercise->read($exerciseId) && (!$is_editor)) {
        $tool_content .= "<p>$langExerciseNotFound</p>";
        draw($tool_content, 2);
        exit();
    }
    if(!$objExercise->selectScore() &&  !$is_editor) {
        redirect_to_home_page("modules/exercise/index.php?course=$course_code");
    }
}

if (isset($_SESSION['objExercise'][$exerciseId])) {
    $objExercise = $_SESSION['objExercise'][$exerciseId];
}

if ($is_editor && isset($_GET['purgeAttempID'])) {
    $eurid = $_GET['purgeAttempID'];
    $objExercise->purgeAttempt($eurid);
    Session::Messages($langPurgeExerciseResultsSuccess);
    redirect_to_home_page("modules/exercise/results.php?course=$course_code&exerciseId=$exerciseId");  
}
$exerciseTitle = $objExercise->selectTitle();
Esempio n. 2
0
    }
    $objExercise = new Exercise();
    $objExercise->read($exercise_user_record->eid);
} else {
    //exercise user recird id is not set
    redirect_to_home_page('modules/exercise/index.php?course=' . $course_code);
}
if ($is_editor && $exercise_user_record->attempt_status == ATTEMPT_PENDING) {
    $head_content .= "<script type='text/javascript'>                             \n    \t\t\$(document).ready(function(){\n                    function save_grade(elem){\n                        var grade = parseInt(\$(elem).val());\n                        var element_name = \$(elem).attr('name');\n                        var questionId = parseInt(element_name.substring(14,element_name.length - 1));\n                        var questionMaxGrade = parseInt(\$(elem).next().val());\n                        if (grade > questionMaxGrade) {\n                            bootbox.alert('{$langGradeTooBig}');\n                            return false;\n                        } else if (isNaN(grade)){\n                            \$(elem).css({'border-color':'red'});\n                            return false;\n                        } else {\n                            \$.ajax({\n                              type: 'POST',\n                              url: '',\n                              data: {question_grade: grade, question_id: questionId},\n                            });\n                            \$(elem).parent().prev().hide();\n                            \$(elem).prop('disabled', true);\n                            \$(elem).css({'border-color':'#dfdfdf'});\n                            var prev_grade = parseInt(\$('span#total_score').html());\n                            var updated_grade = prev_grade + grade;\n                            \$('span#total_score').html(updated_grade);\n                            return true;\n                        }                    \n                    }\n                    \$('.questionGradeBox').keyup(function (e) {\n                        if (e.keyCode == 13) {\n                            save_grade(this);\n                            var countnotgraded = \$('input.questionGradeBox').not(':disabled').length;\n                            if (countnotgraded == 0) {\n                                \$('a#submitButton').hide();\n                                \$('a#all').hide();\n                                \$('a#ungraded').hide();\n                                \$('table.graded').show('slow');\n                            }                        \n                        }\n                    });\n                    \$('a#submitButton').click(function(e){\n                        e.preventDefault();\n                        var success = true;\n                        \$('.questionGradeBox').each(function() {\n                           success = save_grade(this);\n                        });\n                        if (success) {\n                         \$(this).parent().hide();\n                        }\n                    });                    \n                    \$('a#ungraded').click(function(e){\n                        e.preventDefault();\n                        \$('a#all').removeClass('btn-primary').addClass('btn-default');\n                        \$(this).removeClass('btn-default').addClass('btn-primary');\n                        \$('table.graded').hide('slow');\n                    });\n                    \$('a#all').click(function(e){\n                        e.preventDefault();\n                        \$('a#ungraded').removeClass('btn-primary').addClass('btn-default');\n                        \$(this).removeClass('btn-default').addClass('btn-primary');\n                        \$('table.graded').show('slow');\n                    });        \n                });\n                </script>";
}
$exerciseTitle = $objExercise->selectTitle();
$exerciseDescription = $objExercise->selectDescription();
$exerciseDescription_temp = nl2br(make_clickable($exerciseDescription));
$exerciseDescription_temp = mathfilter($exerciseDescription_temp, 12, "../../courses/mathimg/");
$displayResults = $objExercise->selectResults();
$displayScore = $objExercise->selectScore();
$tool_content .= "<div class='panel panel-primary'>\n  <div class='panel-heading'>\n    <h3 class='panel-title'>{$exerciseTitle}</h3>\n  </div>";
if (!empty($exerciseDescription_temp)) {
    $tool_content .= "<div class='panel-body'>\n        {$exerciseDescription_temp}\n      </div>";
}
$tool_content .= "</div>";
$tool_content .= "\n  <div class='row margin-bottom-fat'>\n    <div class='col-md-5 col-md-offset-7'>\n        " . ($is_editor && $exercise_user_record->attempt_status == ATTEMPT_PENDING ? "<div class='btn-group btn-group-sm' style='float:right;'><a class='btn btn-primary' id='all'>Όλες οι ερωτήσεις</a><a class='btn btn-default' id='ungraded'>Ερωτήσεις προς Βαθμολόγηση</a></div>" : "") . "\n    </div>    \n  </div>";
$i = 0;
// for each question
if (count($exercise_question_ids) > 0) {
    foreach ($exercise_question_ids as $row) {
        // creates a temporary Question object
        $objQuestionTmp = new Question();
        $objQuestionTmp->read($row->question_id);
        // gets the student choice for this question
        $choice = $objQuestionTmp->get_answers_record($eurid);