Exemplo n.º 1
0
        if (!($course_to_crsind && !isset($_GET['confirm']))) {
            $cats[0]->move_to_cat($targetcat[0]);
            header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
            exit;
        }
        unset($targetcat);
    }
    unset($cats);
}
//move an evaluation
if (isset($_GET['moveeval'])) {
    GradebookUtils::block_students();
    $get_move_eval = Security::remove_XSS($_GET['moveeval']);
    $evals = Evaluation::load($get_move_eval);
    if (!isset($_GET['targetcat'])) {
        $move_form = new EvalForm(EvalForm::TYPE_MOVE, $evals[0], null, 'move_eval_form', null, api_get_self() . '?moveeval=' . $get_move_eval . '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
        if ($move_form->validate()) {
            header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&moveeval=' . $get_move_eval . '&targetcat=' . $move_form->exportValue('move_cat'));
            exit;
        }
    } else {
        $get_target_cat = Security::remove_XSS($_GET['targetcat']);
        $targetcat = Category::load($get_target_cat);
        $course_to_crsind = $evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null;
        if (!($course_to_crsind && !isset($_GET['confirm']))) {
            $evals[0]->move_to_cat($targetcat[0]);
            header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
            exit;
        }
        unset($targetcat);
    }
require_once '../inc/global.inc.php';
$this_section = SECTION_MYGRADEBOOK;
require_once 'lib/be.inc.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/scoredisplay.class.php';
api_block_anonymous_users();
block_students();
$evaluation = Evaluation::load($_GET['selecteval']);
$newstudents = $evaluation[0]->get_not_subscribed_students();
if (count($newstudents) == '0') {
    header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
    exit;
}
$add_user_form = new EvalForm(EvalForm::TYPE_ADD_USERS_TO_EVAL, $evaluation[0], null, 'add_users_to_evaluation', null, api_get_self() . '?selecteval=' . Security::remove_XSS($_GET['selecteval']), Security::remove_XSS($_GET['firstletter']), $newstudents);
if (isset($_POST['submit_button'])) {
    $users = is_array($_POST['add_users']) ? $_POST['add_users'] : array();
    foreach ($users as $key => $value) {
        $users[$key] = intval($value);
    }
    if (count($users) == 0) {
        header('Location: ' . api_get_self() . '?erroroneuser=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
        exit;
    } else {
        foreach ($users as $user_id) {
            $result = new Result();
            $result->set_user_id($user_id);
            $result->set_evaluation_id($_GET['selecteval']);
            $result->add();
        }
Exemplo n.º 3
0
//load the result with the evaluation id
if (isset($_GET['delete_mark'])) {
    $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());
/* For licensing terms, see /license.txt */
/**
 * Script
 * @package chamilo.gradebook
 */
//require_once '../inc/global.inc.php';
api_block_anonymous_users();
GradebookUtils::block_students();
$select_eval = Security::remove_XSS($_GET['selecteval']);
if (empty($select_eval)) {
    api_not_allowed();
}
$resultedit = Result::load(null, null, $select_eval);
$evaluation = Evaluation::load($select_eval);
$evaluation[0]->check_lock_permissions();
$edit_result_form = new EvalForm(EvalForm::TYPE_ALL_RESULTS_EDIT, $evaluation[0], $resultedit, 'edit_result_form', null, api_get_self() . '?&selecteval=' . $select_eval);
$table = $edit_result_form->toHtml();
if ($edit_result_form->validate()) {
    $values = $edit_result_form->exportValues();
    $scores = $values['score'];
    foreach ($scores as $row) {
        $resultedit = Result::load(key($scores));
        $row_value = $row;
        if ($row_value != '') {
            $resultedit[0]->set_score(floatval(number_format($row_value, api_get_setting('gradebook.gradebook_number_decimals'))));
            $resultedit[0]->save();
        }
        next($scores);
    }
    header('Location: gradebook_view_result.php?selecteval=' . $select_eval . '&editallresults=&' . api_get_cidreq());
    exit;
Exemplo n.º 5
0
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script(true);
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();
Exemplo n.º 6
0
 public function actionUpdateEvaContext($id)
 {
     Yii::log("actionUpdateEvaContext called", "trace", self::LOG_CAT);
     $this->setPageTitle('Update Evaluation Context');
     if (isset($_POST['pageId'])) {
         SystemController::savePage($this->createUrl('updateEvaContext', ['id' => $id]));
     }
     $evaluationHeader = EvaluationHeader::model()->with('evalDetails')->find('t.evalId=:evaId', [':evaId' => $id]);
     //$this->frameworkId = Yii::app()->session['surDesign']['id'];
     $dataArray = [];
     $dataArray['formType'] = 'Update';
     $model = new EvalForm();
     //print_r(FrameworkContext::model()->getFrameworkSummary($this->frameworkId)); die;
     $returnArray = self::getElementsAndDynamicAttributes();
     $elements = $returnArray['elements'];
     $model->setRules($returnArray['rules']);
     $model->setProperties($returnArray['dynamicDataAttributes']);
     $model->setAttributeLabels($returnArray['labels']);
     //print_r($model->attributes); die;
     foreach ($model->attributes as $attributeName => $attributeVal) {
         $attributeNameAndId = explode('_', $attributeName);
         foreach ($evaluationHeader->evalDetails as $evaluationData) {
             if (isset($attributeNameAndId[1]) && $attributeNameAndId[1] == $evaluationData->evalElementsId) {
                 $model->setPropertyName($attributeName, $evaluationData->value);
                 if (DForm::isJson($evaluationData->value)) {
                     $model->setPropertyName($attributeName, json_decode($evaluationData->value));
                 }
                 break;
             }
         }
     }
     $elements['buttons'] = ['updateEvaluation' => ['label' => 'Update evaluation context', 'type' => 'submit']];
     // generate the elements form
     $form = new CForm($elements);
     $form['evaluationHeader']->model = $evaluationHeader;
     $form['evaContext']->model = $model;
     if ($form->submitted('updateEvaluation')) {
         //die('opop');
         $evaluationHeader = $form['evaluationHeader']->model;
         $evaluationHeader->frameworkId = Yii::app()->session['surDesign']['id'];
         $evaluationHeader->userId = Yii::app()->user->id;
         $model->setProperties($_POST['EvalForm']);
         //var_dump($model); die;
         //save the componentHead values
         if ($evaluationHeader->save() && $model->save($evaluationHeader->evalId, false)) {
             //
             if (isset(Yii::app()->session['evaContext'])) {
                 Yii::app()->session->add('evaContext', ['id' => $evaluationHeader->evalId, 'name' => $evaluationHeader->evaluationName, 'questionId' => $evaluationHeader->questionId]);
             }
             Yii::app()->user->setFlash('success', Yii::t("translation", "Evaluation protocol updated successfully"));
             $this->redirect(['listEvaContext']);
             return;
         }
         Yii::app()->user->setFlash('error', Yii::t("translation", "An error occurred when updating the " . "evaluation context, please try again or contact your administrator if the problem persists"));
     }
     $this->docName = 'addEvaContext';
     $page = SystemController::getPageContent($this->docName);
     $this->render('context', ['model' => $model, 'dataArray' => $dataArray, 'form' => $form, 'page' => $page]);
 }