/** * Update the properties of this evaluation in the database */ public function save() { $tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION); $sql = 'UPDATE ' . $tbl_grade_evaluations . " SET name = '" . Database::escape_string($this->get_name()) . "'" . ', description = '; if (isset($this->description)) { $sql .= "'" . Database::escape_string($this->get_description()) . "'"; } else { $sql .= 'null'; } $sql .= ', user_id = ' . intval($this->get_user_id()) . ', course_code = '; if (isset($this->course_code)) { $sql .= "'" . Database::escape_string($this->get_course_code()) . "'"; } else { $sql .= 'null'; } $sql .= ', category_id = '; if (isset($this->category)) { $sql .= intval($this->get_category_id()); } else { $sql .= 'null'; } $sql .= ', weight = "' . Database::escape_string($this->get_weight()) . '" ' . ', max = ' . intval($this->get_max()) . ', visible = ' . intval($this->is_visible()) . ' WHERE id = ' . intval($this->id); //recorded history $eval_log = new Evaluation(); $eval_log->add_evaluation_log($this->id); Database::query($sql); }
/** * @param int $id * @param float $weight */ public static function updateEvaluationWeight($id, $weight) { $table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION); $id = intval($id); $evaluation = new Evaluation(); $evaluation->add_evaluation_log($id); $sql = 'UPDATE ' . $table_evaluation . ' SET weight = ' . "'" . Database::escape_string($weight) . "'" . ' WHERE id = ' . $id; Database::query($sql); }
$resource_name = Database::fetch_array($tempsql); if (isset($resource_name['lp_type'])) { $resource_name = $resource_name[2]; } else { $resource_name = $resource_name[1]; } $output .= '<tr><td>' . build_type_icon_tag($row['type']) . '</td><td> ' . $resource_name . ' ' . Display::label($table_evaluated[$row['type']][3], 'info') . ' </td>'; $output .= '<td><input type="hidden" name="link_' . $row['id'] . '" value="' . $resource_name . '" /><input size="10" type="text" name="link[' . $row['id'] . ']" value="' . $item_weight . '"/></td></tr>'; } $sql = Database::query('SELECT * FROM ' . $table_evaluation . ' WHERE category_id = ' . $my_selectcat); while ($row = Database::fetch_array($sql)) { $item_weight = $row['weight']; //$item_weight = $masked_total*$item_weight/$original_total; //update only if value changed if (isset($_POST['evaluation'][$row['id']])) { Evaluation::add_evaluation_log($row['id']); //$new_weight = trim($_POST['evaluation'][$row['id']]*$original_total/$masked_total); $new_weight = trim($_POST['evaluation'][$row['id']]); $update_sql = 'UPDATE ' . $table_evaluation . ' SET weight = ' . "'" . Database::escape_string($new_weight) . "'" . ' WHERE id = ' . $row['id']; Database::query($update_sql); $item_weight = trim($_POST['evaluation'][$row['id']]); } $type_evaluated = isset($row['type']) ? $table_evaluated[$type_evaluated][3] : null; $output .= '<tr><td>' . build_type_icon_tag('evalnotempty') . '</td><td>' . $row['name'] . ' ' . Display::label(get_lang('Evaluation') . $type_evaluated) . '</td>'; $output .= '<td><input type="hidden" name="eval_' . $row['id'] . '" value="' . $row['name'] . '" /><input type="text" size="10" name="evaluation[' . $row['id'] . ']" value="' . $item_weight . '"/></td></tr>'; } //by iflorespaz $my_api_cidreq = api_get_cidreq(); if ($my_api_cidreq == '') { $my_api_cidreq = 'cidReq=' . $my_category['course_code']; }
/** * Update the properties of this evaluation in the database */ public function save() { $em = Database::getManager(); $gradebookEvaluation = $em->find('ChamiloCoreBundle:GradebookEvaluation', $this->id); if (!$gradebookEvaluation) { return; } $eval_log = new Evaluation(); $eval_log->add_evaluation_log($this->id); $gradebookEvaluation->setName($this->get_name())->setUserId($this->get_user_id())->setWeight($this->get_weight())->setMax($this->get_max())->setVisible($this->is_visible()); if (isset($this->description)) { $gradebookEvaluation->setDescription($this->get_description()); } if (isset($this->course_code)) { $course = $em->getRepository('ChamiloCoreBundle:Course')->findOneBy(['code' => $this->get_course_code()]); $gradebookEvaluation->setCourse($course); } if (isset($this->category)) { $gradebookEvaluation->setCategoryId($this->get_category_id()); } //recorded history $em->persist($gradebookEvaluation); $em->flush(); }