예제 #1
0
 private static function create_category_objects_from_sql_result($result)
 {
     $allcat = array();
     while ($data = Database::fetch_array($result)) {
         $cat = new Category();
         $cat->set_id($data['id']);
         $cat->set_name($data['name']);
         $cat->set_description($data['description']);
         $cat->set_user_id($data['user_id']);
         $cat->set_course_code($data['course_code']);
         $cat->set_parent_id($data['parent_id']);
         $cat->set_weight($data['weight']);
         $cat->set_visible($data['visible']);
         $cat->set_session_id($data['session_id']);
         $cat->set_certificate_min_score($data['certif_min_score']);
         $cat->set_grade_model_id($data['grade_model_id']);
         $cat->set_locked($data['locked']);
         $allcat[] = $cat;
     }
     return $allcat;
 }
예제 #2
0
}
</script>';
$filter_confirm_msg = true;
$filter_warning_msg = true;
// ACTIONS
//this is called when there is no data for the course admin
if (isset($_GET['createallcategories'])) {
    GradebookUtils::block_students();
    $coursecat = Category::get_not_created_course_categories(api_get_user_id());
    if (!count($coursecat) == 0) {
        foreach ($coursecat as $row) {
            $cat = new Category();
            $cat->set_name($row[1]);
            $cat->set_course_code($row[0]);
            $cat->set_description(null);
            $cat->set_user_id(api_get_user_id());
            $cat->set_parent_id(0);
            $cat->set_weight(0);
            $cat->set_visible(0);
            $cat->add();
            unset($cat);
        }
    }
    header('Location: ' . $_SESSION['gradebook_dest'] . '?addallcat=&selectcat=0');
    exit;
}
//move a category
$selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
if (isset($_GET['movecat'])) {
    $move_cat = Security::remove_XSS($_GET['movecat']);
    GradebookUtils::block_students();
<?php

/* For licensing terms, see /license.txt */
/**
 * Script
 * @package chamilo.gradebook
 */
//require_once '../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script(true);
api_block_anonymous_users();
GradebookUtils::block_students();
$catadd = new Category();
$catadd->set_user_id(api_get_user_id());
$catadd->set_parent_id($_GET['selectcat']);
$catcourse = Category::load($_GET['selectcat']);
$form = new CatForm(CatForm::TYPE_SELECT_COURSE, $catadd, 'add_cat_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&' . api_get_cidreq());
if ($form->validate()) {
    $values = $form->exportValues();
    $cat = new Category();
    $cat->set_course_code($values['select_course']);
    $cat->set_name($values['name']);
    header('location: gradebook_add_link.php?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&course_code=' . Security::remove_XSS($values['select_course']) . '&' . api_get_cidreq());
    exit;
}
$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&' . api_get_cidreq(), 'name' => get_lang('Gradebook'));
Display::display_header(get_lang('NewCategory'));
$form->display();
Display::display_footer();
예제 #4
0
 /**
  * @param null $course_code
  * @param int $gradebook_model_id
  * @return mixed
  */
 public static function create_default_course_gradebook($course_code = null, $gradebook_model_id = 0)
 {
     if (api_is_allowed_to_edit(true, true)) {
         if (!isset($course_code) || empty($course_code)) {
             $course_code = api_get_course_id();
         }
         $session_id = api_get_session_id();
         $t = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
         $sql = "SELECT * FROM {$t} WHERE course_code = '" . Database::escape_string($course_code) . "' ";
         if (!empty($session_id)) {
             $sql .= " AND session_id = " . (int) $session_id;
         } else {
             $sql .= " AND (session_id IS NULL OR session_id = 0) ";
         }
         $sql .= " ORDER BY id";
         $res = Database::query($sql);
         if (Database::num_rows($res) < 1) {
             //there is no unique category for this course+session combination,
             $cat = new Category();
             if (!empty($session_id)) {
                 $my_session_id = api_get_session_id();
                 $s_name = api_get_session_name($my_session_id);
                 $cat->set_name($course_code . ' - ' . get_lang('Session') . ' ' . $s_name);
                 $cat->set_session_id($session_id);
             } else {
                 $cat->set_name($course_code);
             }
             $cat->set_course_code($course_code);
             $cat->set_description(null);
             $cat->set_user_id(api_get_user_id());
             $cat->set_parent_id(0);
             $default_weight_setting = api_get_setting('gradebook_default_weight');
             $default_weight = isset($default_weight_setting) && !empty($default_weight_setting) ? $default_weight_setting : 100;
             $cat->set_weight($default_weight);
             $cat->set_grade_model_id($gradebook_model_id);
             $cat->set_certificate_min_score(75);
             $cat->set_visible(0);
             $cat->add();
             $category_id = $cat->get_id();
             unset($cat);
         } else {
             $row = Database::fetch_array($res);
             $category_id = $row['id'];
         }
     }
     return $category_id;
 }
예제 #5
0
             }
             //end hack*/
     $cats = Category::load(null, null, $course_code, null, null, $session_id, false);
     if (empty($cats)) {
         // There is no category for this course+session, so create one
         $cat = new Category();
         if (!empty($session_id)) {
             $s_name = api_get_session_name($session_id);
             $cat->set_name($course_code . ' - ' . get_lang('Session') . ' ' . $s_name);
             $cat->set_session_id($session_id);
         } else {
             $cat->set_name($course_code);
         }
         $cat->set_course_code($course_code);
         $cat->set_description(null);
         $cat->set_user_id($stud_id);
         $cat->set_parent_id(0);
         $cat->set_weight(100);
         $cat->set_visible(0);
         $cat->set_certificate_min_score(75);
         $can_edit = api_is_allowed_to_edit(true, true);
         if ($can_edit) {
             $cat->add();
         }
         unset($cat);
     }
     unset($cats);
 }
 $cats = Category::load($category, null, null, null, null, null, false);
 //with this fix the teacher only can view 1 gradebook
 if (api_is_platform_admin()) {
 */
/**
 * Init
 */
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/catform.class.php';
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
api_block_anonymous_users();
block_students();
$catadd = new Category();
$catadd->set_user_id($_user['user_id']);
$catadd->set_parent_id($_GET['selectcat']);
$catcourse = Category::load($_GET['selectcat']);
//$catadd->set_course_code($catcourse[0]->get_course_code());
$form = new CatForm(CatForm::TYPE_SELECT_COURSE, $catadd, 'add_cat_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']));
if ($form->validate()) {
    $values = $form->exportValues();
    $cat = new Category();
    $cat->set_course_code($values['select_course']);
    $cat->set_name($values['name']);
    header('location: gradebook_add_link.php?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&course_code=' . Security::remove_XSS($values['select_course']));
    exit;
}
$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('Gradebook'));
Display::display_header(get_lang('NewCategory'));
$form->display();
예제 #7
0
     } else {
         $cat->set_course_code($select_course);
         $cat->set_name($values['name']);
     }
 } else {
     $cat->set_name($values['name']);
     $cat->set_course_code($values['course_code']);
 }
 $cat->set_session_id(api_get_session_id());
 //Always add the gradebook to the course
 $cat->set_course_code(api_get_course_id());
 if (isset($values['skills'])) {
     $cat->set_skills($values['skills']);
 }
 $cat->set_description($values['description']);
 $cat->set_user_id($values['hid_user_id']);
 $cat->set_parent_id($values['hid_parent_id']);
 $cat->set_weight($values['weight']);
 if (isset($values['generate_certificates'])) {
     $cat->setGenerateCertificates(true);
 } else {
     $cat->setGenerateCertificates(false);
 }
 if (isset($values['is_requirement'])) {
     $cat->setIsRequirement(true);
 } else {
     $cat->setIsRequirement(false);
 }
 if (empty($values['visible'])) {
     $visible = 0;
 } else {
예제 #8
0
 /**
  * Create a category object from a GradebookCategory entity
  * @param Chamilo\CoreBundle\Entity\GradebookCategory $gradebookCategory
  *         The entity
  * @return \Category
  */
 public static function createCategoryObjectFromEntity(Chamilo\CoreBundle\Entity\GradebookCategory $gradebookCategory)
 {
     $category = new Category();
     $category->set_id($gradebookCategory->getId());
     $category->set_name($gradebookCategory->getName());
     $category->set_description($gradebookCategory->getDescription());
     $category->set_user_id($gradebookCategory->getUserId());
     $category->set_course_code($gradebookCategory->getCourseCode());
     $category->set_parent_id($gradebookCategory->getParentId());
     $category->set_weight($gradebookCategory->getWeight());
     $category->set_visible($gradebookCategory->getVisible());
     $category->set_session_id($gradebookCategory->getSessionId());
     $category->set_certificate_min_score($gradebookCategory->getCertifMinScore());
     $category->set_grade_model_id($gradebookCategory->getGradeModelId());
     $category->set_locked($gradebookCategory->getLocked());
     $category->setGenerateCertificates($gradebookCategory->getGenerateCertificates());
     $category->setIsRequirement($gradebookCategory->getIsRequirement());
     return $category;
 }
예제 #9
0
 /**
  * @param null $course_code
  * @param int $gradebook_model_id
  * @return mixed
  */
 public static function create_default_course_gradebook($course_code = null, $gradebook_model_id = 0)
 {
     if (api_is_allowed_to_edit(true, true)) {
         if (!isset($course_code) || empty($course_code)) {
             $course_code = api_get_course_id();
         }
         $session_id = api_get_session_id();
         $courseId = api_get_course_int_id($course_code);
         $em = Database::getManager();
         $qb = $em->createQueryBuilder();
         $qb->select('gc')->from('ChamiloCoreBundle:GradebookCategory', 'gc');
         $qb->where($qb->expr()->eq('gc.course', $courseId));
         if (!empty($session_id)) {
             $qb->andWhere($qb->expr()->eq('gc.sessionId', $session_id));
         } else {
             $qb->andWhere($qb->expr()->orX($qb->expr()->isNull('gc.sessionId'), $qb->expr()->eq('gc.sessionId', 0)));
         }
         $qb->orderBy('gc.id', 'ASC');
         $res = $qb->getQuery()->getResult();
         if (count($res) < 1) {
             //there is no unique category for this course+session combination,
             $cat = new Category();
             if (!empty($session_id)) {
                 $my_session_id = api_get_session_id();
                 $s_name = api_get_session_name($my_session_id);
                 $cat->set_name($course_code . ' - ' . get_lang('Session') . ' ' . $s_name);
                 $cat->set_session_id($session_id);
             } else {
                 $cat->set_name($course_code);
             }
             $cat->set_course_code($course_code);
             $cat->set_description(null);
             $cat->set_user_id(api_get_user_id());
             $cat->set_parent_id(0);
             $default_weight_setting = api_get_setting('gradebook.gradebook_default_weight');
             $default_weight = isset($default_weight_setting) && !empty($default_weight_setting) ? $default_weight_setting : 100;
             $cat->set_weight($default_weight);
             $cat->set_grade_model_id($gradebook_model_id);
             $cat->set_certificate_min_score(75);
             $cat->set_visible(0);
             $cat->add();
             $category_id = $cat->get_id();
             unset($cat);
         } else {
             $row = current($res);
             $category_id = $row->getId();
         }
         return $category_id;
     }
     return false;
 }