Exemplo n.º 1
0
$my_cat = $my_cat[0];
$parent_id = $my_cat->get_parent_id();
$parent_cat = Category::load($parent_id);
$my_category = array();
$cat = new Category();
$my_category = $cat->shows_all_information_an_category($my_selectcat);
$original_total = $my_category['weight'];
$masked_total = $parent_cat[0]->get_weight();
$sql = 'SELECT * FROM ' . $table_link . ' WHERE category_id = ' . $my_selectcat;
$result = Database::query($sql);
$links = Database::store_result($result, 'ASSOC');
foreach ($links as &$row) {
    $item_weight = $row['weight'];
    //$item_weight = $masked_total*$item_weight/$original_total;
    //
    $sql = 'SELECT * FROM ' . GradebookUtils::get_table_type_course($row['type']) . '
            WHERE c_id = ' . $course_id . ' AND ' . $table_evaluated[$row['type']][2] . ' = ' . $row['ref_id'];
    $result = Database::query($sql);
    $resource_name = Database::fetch_array($result);
    if (isset($resource_name['lp_type'])) {
        $resource_name = $resource_name[4];
    } else {
        $resource_name = $resource_name[3];
    }
    $row['resource_name'] = $resource_name;
    // Update only if value changed
    if (isset($_POST['link'][$row['id']])) {
        //$new_weight = trim($_POST['link'][$row['id']]*$original_total/$masked_total);
        $new_weight = trim($_POST['link'][$row['id']]);
        GradebookUtils::updateLinkWeight($row['id'], $resource_name, $new_weight);
        $item_weight = $new_weight;
Exemplo n.º 2
0
}
$output = '';
$my_cat = Category::load($my_selectcat);
$my_cat = $my_cat[0];
$parent_id = $my_cat->get_parent_id();
$parent_cat = Category::load($parent_id);
$my_category = array();
$cat = new Category();
$my_category = $cat->shows_all_information_an_category($my_selectcat);
$original_total = $my_category->getWeight();
$masked_total = $parent_cat[0]->get_weight();
$links = $em->getRepository('ChamiloCoreBundle:GradebookLink')->findBy(['categoryId' => $my_selectcat]);
$linksInfo = [];
foreach ($links as $row) {
    $item_weight = $row->getWeight();
    $sql = 'SELECT * FROM ' . GradebookUtils::get_table_type_course($row->getType()) . '
            WHERE c_id = ' . $course_id . ' AND ' . $table_evaluated[$row->getType()][2] . ' = ' . $row->getRefId();
    $result = Database::query($sql);
    $resource_name = Database::fetch_array($result);
    if (isset($resource_name['lp_type'])) {
        $resource_name = $resource_name[4];
    } else {
        $resource_name = $resource_name[3];
    }
    $linksInfo[] = ['id' => $row->getId(), 'resource_name' => $resource_name];
    // Update only if value changed
    if (isset($_POST['link'][$row->getId()])) {
        $new_weight = trim($_POST['link'][$row->getId()]);
        GradebookUtils::updateLinkWeight($row->getId(), $resource_name, $new_weight);
        $item_weight = $new_weight;
    }