Exemplo n.º 1
0
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/scoredisplay.class.php';
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
api_block_anonymous_users();
block_students();
$resultadd = new Result();
$resultadd->set_evaluation_id($_GET['selecteval']);
$evaluation = Evaluation::load($_GET['selecteval']);
$category = !empty($_GET['selectcat']) ? $_GET['selectcat'] : "";
$add_result_form = new EvalForm(EvalForm::TYPE_RESULT_ADD, $evaluation[0], $resultadd, 'add_result_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($category) . '&selecteval=' . Security::remove_XSS($_GET['selecteval']));
$table = $add_result_form->toHtml();
if ($add_result_form->validate()) {
    $values = $add_result_form->exportValues();
    $nr_users = $values['nr_users'];
    if ($nr_users == '0') {
        header('Location: gradebook_view_result.php?addresultnostudents=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
        exit;
    }
    $scores = $values['score'];
    foreach ($scores as $row) {
        $res = new Result();
        $res->set_evaluation_id($values['evaluation_id']);
        $res->set_user_id(key($scores));
        //if no scores are given, don't set the score
        if (!empty($row) || $row == '0') {
            $res->set_score($row);
        }
        $res->add();
Exemplo n.º 2
0
    $result = Result::load($_GET['delete_mark']);
    if (!empty($result[0])) {
        $result[0]->delete();
    }
}
if (isset($_GET['selecteval'])) {
    $allresults = Result::load(null, null, $select_eval);
    $iscourse = $currentcat[0]->get_course_code() == null ? 1 : 0;
}
if (isset($_GET['editres'])) {
    $edit_res_xml = Security::remove_XSS($_GET['editres']);
    $select_eval_edit = Security::remove_XSS($_GET['selecteval']);
    $resultedit = Result::load($edit_res_xml);
    $edit_res_form = new EvalForm(EvalForm::TYPE_RESULT_EDIT, $eval[0], $resultedit[0], 'edit_result_form', null, api_get_self() . '?editres=' . $resultedit[0]->get_id() . '&selecteval=' . $select_eval_edit . '&' . api_get_cidreq());
    if ($edit_res_form->validate()) {
        $values = $edit_res_form->exportValues();
        $result = new Result();
        $resultlog = new Result();
        $resultlog->add_result__log($values['hid_user_id'], $select_eval_edit);
        $result->set_id($edit_res_xml);
        $result->set_user_id($values['hid_user_id']);
        $result->set_evaluation_id($select_eval_edit);
        $row_value = isset($values['score']) ? (double) $values['score'] : 0;
        if (!empty($row_value) || $row_value == 0) {
            $result->set_score(floatval(number_format($row_value, api_get_setting('gradebook_number_decimals'))));
        }
        $result->save();
        unset($result);
        header('Location: gradebook_view_result.php?selecteval=' . $select_eval_edit . '&editresmessage=&' . api_get_cidreq());
        exit;
    }
Exemplo n.º 3
0
api_block_anonymous_users();
GradebookUtils::block_students();
$select_cat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
$is_allowedToEdit = $is_courseAdmin;
$evaladd = new Evaluation();
$evaladd->set_user_id($_user['user_id']);
if (isset($_GET['selectcat']) && !empty($_GET['selectcat'])) {
    $evaladd->set_category_id($_GET['selectcat']);
    $cat = Category::load($_GET['selectcat']);
    $evaladd->set_course_code($cat[0]->get_course_code());
} else {
    $evaladd->set_category_id(0);
}
$form = new EvalForm(EvalForm::TYPE_ADD, $evaladd, null, 'add_eval_form', null, api_get_self() . '?selectcat=' . $select_cat . '&' . api_get_cidreq());
if ($form->validate()) {
    $values = $form->exportValues();
    $eval = new Evaluation();
    $eval->set_name($values['name']);
    $eval->set_description($values['description']);
    $eval->set_user_id($values['hid_user_id']);
    if (!empty($values['hid_course_code'])) {
        $eval->set_course_code($values['hid_course_code']);
    }
    //Always add the gradebook to the course
    $eval->set_course_code(api_get_course_id());
    $eval->set_category_id($values['hid_category_id']);
    $parent_cat = Category::load($values['hid_category_id']);
    $global_weight = $cat[0]->get_weight();
    //$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
    $values['weight'] = $values['weight_mask'];
    $eval->set_weight($values['weight']);