コード例 #1
0
 /**
  * Builds the course or platform admin icons to edit an evaluation
  * @param  Evaluation $eval evaluation object
  * @param int $selectcat id of selected category
  */
 public static function build_edit_icons_eval($eval, $selectcat)
 {
     $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
     $is_locked = $eval->is_locked();
     $eval->get_course_code();
     $cat = new Category();
     $message_eval = $cat->show_message_resource_delete($eval->get_course_code());
     if ($message_eval === false && api_is_allowed_to_edit(null, true)) {
         $visibility_icon = $eval->is_visible() == 0 ? 'invisible' : 'visible';
         $visibility_command = $eval->is_visible() == 0 ? 'set_visible' : 'set_invisible';
         if ($is_locked && !api_is_platform_admin()) {
             $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
         } else {
             $modify_icons = '<a href="gradebook_edit_eval.php?editeval=' . $eval->get_id() . '&cidReq=' . $eval->get_course_code() . '&id_session=' . $eval->getSessionId() . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
         }
         $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visibleeval=' . $eval->get_id() . '&' . $visibility_command . '=&selectcat=' . $selectcat . '&id_session=' . $eval->getSessionId() . ' ">' . Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>';
         if (api_is_allowed_to_edit(null, true)) {
             $modify_icons .= '&nbsp;<a href="gradebook_showlog_eval.php?visiblelog=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $eval->get_course_code() . '&id_session=' . $eval->getSessionId() . '">' . Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>';
         }
         if ($is_locked && !api_is_platform_admin()) {
             $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
         } else {
             $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deleteeval=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $eval->get_course_code() . '&id_session=' . $eval->getSessionId() . '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
         }
         return $modify_icons;
     }
 }
コード例 #2
0
    }
    $eval->set_visible($visible);
    $eval->add();
    if ($eval->get_course_code() == null) {
        if ($values['adduser'] == 1) {
            //Disabling code when course code is null see issue #2705
            //header('Location: gradebook_add_user.php?selecteval=' . $eval->get_id());
            exit;
        } else {
            header('Location: ' . Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $eval->get_category_id() . '&' . api_get_cidreq());
            exit;
        }
    } else {
        $val_addresult = isset($values['addresult']) ? $values['addresult'] : null;
        if ($val_addresult == 1) {
            header('Location: gradebook_add_result.php?selecteval=' . $eval->get_id() . '&' . api_get_cidreq());
            exit;
        } else {
            header('Location: ' . Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $eval->get_category_id() . '&' . api_get_cidreq());
            exit;
        }
    }
}
$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $select_cat . '&' . api_get_cidreq(), 'name' => get_lang('Gradebook'));
$this_section = SECTION_COURSES;
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {
    $("#hid_category_id").change(function() {
       $("#hid_category_id option:selected").each(function () {
           var cat_id = $(this).val();
            $.ajax({
コード例 #3
0
 /**
  * Lazy load function to get the linked evaluation
  */
 protected function get_evaluation()
 {
     if (!isset($this->evaluation)) {
         if (isset($this->ref_id)) {
             $evalarray = Evaluation::load($this->get_ref_id());
             $this->evaluation = $evalarray[0];
         } else {
             $eval = new Evaluation();
             $eval->set_category_id(-1);
             $eval->set_date(api_get_utc_datetime());
             // these values will be changed
             $eval->set_weight(0);
             //   when the link setter
             $eval->set_visible(0);
             //     is called
             $eval->set_id(-1);
             // a 'real' id will be set when eval is added to db
             $eval->set_user_id($this->get_user_id());
             $eval->set_course_code($this->get_course_code());
             $this->evaluation = $eval;
             $this->set_ref_id($eval->get_id());
         }
     }
     return $this->evaluation;
 }
コード例 #4
0
 static function add_gradebook_result_with_evaluation($data)
 {
     error_log('add_gradebook_result_with_evaluation');
     $session_id = isset($data['session_id']) ? $data['session_id'] : null;
     $user_id = isset($data['user_id']) ? $data['user_id'] : null;
     //Default evaluation title
     $title = 'Evaluación General';
     if (!empty($session_id) && !empty($user_id)) {
         global $data_list, $utc_datetime;
         //$course_list = SessionManager::get_course_list_by_session_id($session_id);
         $course_list = array(0 => array('code' => $data_list['session_course'][$session_id]));
         if (!empty($course_list)) {
             $course_data = current($course_list);
             if (isset($course_data['code'])) {
                 $gradebook = array('id' => $data_list['session_course_gradebook'][$course_data['code']][$session_id]);
                 //Get gradebook
                 //$gradebook = new Gradebook();
                 //$gradebook = $gradebook->get_first(array('where' => array('course_code = ? AND session_id = ?' => array($course_data['code'], $session_id))));
                 //error_log("Looking gradebook in course code:  {$course_data['code']} - session_id: $session_id, user_id: $user_id");
                 if (!empty($gradebook)) {
                     error_log("Gradebook exists: {$gradebook['id']}");
                     //Creates
                     $eval = new Evaluation();
                     $evals_found = false;
                     if (isset($data_list['course_evals'][$course_data['code']][$gradebook['id']][$title])) {
                         $evals_found = $data_list['course_evals'][$course_data['code']][$gradebook['id']][$title];
                     }
                     if (empty($evals_found)) {
                         $eval->set_name($title);
                         //$eval->set_evaluation_type_id($data['gradebook_evaluation_type_id']);
                         $eval->set_user_id(self::default_admin_id);
                         $eval->set_course_code($course_data['code']);
                         $eval->set_category_id($gradebook['id']);
                         //harcoded values
                         $eval->set_weight(100);
                         $eval->set_max(100);
                         //score of tinNota is over 100
                         $eval->set_visible(1);
                         $eval->add();
                         $eval_id = $eval->get_id();
                         $data_list['course_evals'][$course_data['code']][$gradebook['id']][$title] = $eval_id;
                     } else {
                         $eval_id = $evals_found;
                     }
                     if ($eval_id) {
                         //Check if already exists
                         //$check_result = Result :: load (null, $user_id, $eval_id);
                         $check_result = $data_list['course_eval_results'][$eval_id][$user_id];
                         if (empty($check_result)) {
                             //$res = new Result();
                             //$res->set_evaluation_id($eval_id);
                             //$res->set_user_id($user_id);
                             ////if no scores are given, don't set the score
                             //$res->set_score($data['nota']);
                             //$res_id = $res->add();
                             $eval_data = array('user_id' => $user_id, 'evaluation_id' => $eval_id, 'created_at' => $utc_datetime, 'score' => $data['nota']);
                             $data_list['course_eval_results'][$eval_id][$user_id] = $res_id;
                             $limit = $data_list['create_eval_results_limit'];
                             if (count($data_list['create_eval_results']) > $limit) {
                                 $data_list['create_eval_results'][] = $eval_data;
                                 $res = new Result();
                                 $res->group_add($data_list['create_eval_results']);
                                 $data_list['create_eval_results'] = array();
                             } else {
                                 $data_list['create_eval_results'][] = $eval_data;
                             }
                         } else {
                             error_log("Result already added ");
                         }
                     } else {
                         error_log("Evaluation not detected");
                     }
                 } else {
                     error_log("Gradebook does not exists");
                 }
             } else {
                 error_log("Something is wrong with the course ");
             }
         } else {
             error_log("NO course found for session id: {$session_id}");
         }
     } else {
         error_log("NO session id found: {$session_id}");
     }
 }
コード例 #5
0
    }
    $eval->set_visible($visible);
    $eval->add();
    if ($eval->get_course_code() == null) {
        if ($values['adduser'] == 1) {
            //Disabling code when course code is null see issue #2705
            //header('Location: gradebook_add_user.php?selecteval=' . $eval->get_id());
            exit;
        } else {
            header('Location: ' . Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $eval->get_category_id());
            exit;
        }
    } else {
        $val_addresult = isset($values['addresult']) ? $values['addresult'] : null;
        if ($val_addresult == 1) {
            header('Location: gradebook_add_result.php?selecteval=' . $eval->get_id());
            exit;
        } else {
            header('Location: ' . Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $eval->get_category_id());
            exit;
        }
    }
}
$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $select_cat, 'name' => get_lang('Gradebook'));
$this_section = SECTION_COURSES;
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {

    $("#hid_category_id").change(function(){

       $("#hid_category_id option:selected").each(function () {
コード例 #6
0
ファイル: GradebookUtils.php プロジェクト: KRCM13/chamilo-lms
 /**
  * Builds the course or platform admin icons to edit an evaluation
  * @param  Evaluation $eval evaluation object
  * @param int $selectcat id of selected category
  */
 public static function build_edit_icons_eval($eval, $selectcat)
 {
     $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
     $is_locked = $eval->is_locked();
     $eval->get_course_code();
     $cat = new Category();
     $message_eval = $cat->show_message_resource_delete($eval->get_course_code());
     if ($message_eval === false && api_is_allowed_to_edit(null, true)) {
         $visibility_icon = $eval->is_visible() == 0 ? 'invisible' : 'visible';
         $visibility_command = $eval->is_visible() == 0 ? 'set_visible' : 'set_invisible';
         if ($is_locked && !api_is_platform_admin()) {
             $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
         } else {
             $modify_icons = '<a href="gradebook_edit_eval.php?editeval=' . $eval->get_id() . '&cidReq=' . $eval->get_course_code() . '&id_session=' . $eval->getSessionId() . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
         }
         $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visibleeval=' . $eval->get_id() . '&' . $visibility_command . '=&selectcat=' . $selectcat . '&id_session=' . $eval->getSessionId() . ' ">' . Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>';
         if (api_is_allowed_to_edit(null, true)) {
             $modify_icons .= '&nbsp;<a href="gradebook_showlog_eval.php?visiblelog=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $eval->get_course_code() . '&id_session=' . $eval->getSessionId() . '">' . Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>';
         }
         /*
                       if ($locked_status == 0){
                       $modify_icons .= "&nbsp;<a href=\"javascript:if (confirm('".addslashes(get_lang('AreYouSureToLockedTheEvaluation'))."')) { location.href='".api_get_self().'?lockedeval=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq='.$eval->get_course_code()."'; }\">".Display::return_icon('unlock.png',get_lang('LockEvaluation'), array(), ICON_SIZE_SMALL)."</a>";
                       } else {
                       if (api_is_platform_admin()){
                       $modify_icons .= "&nbsp;<a href=\"javascript:if (confirm('".addslashes(get_lang('AreYouSureToUnLockedTheEvaluation'))."')) { location.href='".api_get_self().'?lockedeval=' . $eval->get_id() . '&typelocked=&selectcat=' . $selectcat . ' &cidReq='.$eval->get_course_code()."';\">".Display::return_icon('lock.png',get_lang('UnLockEvaluation'), array(), ICON_SIZE_SMALL)."</a>";
                       } else {
                       $modify_icons .= '&nbsp;<img src="../img/locked_na.png" border="0" title="' . get_lang('TheEvaluationIsLocked') . '" alt="" />';
                       }
                       } */
         if ($is_locked && !api_is_platform_admin()) {
             $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
         } else {
             $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deleteeval=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $eval->get_course_code() . '&id_session=' . $eval->getSessionId() . '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
         }
         return $modify_icons;
     }
 }