Gradebook: Fix classroom activity edition - refs #5231

pull/5238/head
christianbeeznst 2 years ago
parent c6eb8ab57b
commit e17e67a452
  1. 53
      public/main/gradebook/gradebook_edit_eval.php
  2. 2
      public/main/inc/lib/gradebook.lib.php

@ -2,6 +2,11 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Entity\GradebookEvaluation;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Entity\Course;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users(); api_block_anonymous_users();
GradebookUtils::block_students(); GradebookUtils::block_students();
@ -20,37 +25,45 @@ $form = new EvalForm(
); );
if ($form->validate()) { if ($form->validate()) {
$values = $form->exportValues(); $values = $form->exportValues();
$eval = new Evaluation();
$eval->set_id($values['hid_id']); $entityManager = Database::getManager();
$eval->set_name($values['name']);
$eval->set_description($values['description']); $evaluationId = $values['hid_id'];
$eval->set_user_id($values['hid_user_id']); if ($evaluationId) {
$eval->set_course_code($values['hid_course_code']); $evaluation = $entityManager->getRepository(GradebookEvaluation::class)->find($evaluationId);
$eval->set_category_id($values['hid_category_id']);
$parent_cat = Category :: load($values['hid_category_id']);
$final_weight = $values['weight_mask'];
$eval->set_weight($final_weight);
$eval->set_max($values['max']);
if (empty($values['visible'])) {
$visible = 0;
} else { } else {
$visible = 1; $evaluation = new GradebookEvaluation();
$entityManager->persist($evaluation);
} }
$eval->set_visible($visible);
$eval->save(); $evaluation->setTitle($values['name']);
$evaluation->setDescription($values['description']);
$user = $entityManager->getRepository(User::class)->find($values['hid_user_id']);
$evaluation->setUser($user);
$course = $entityManager->getRepository(Course::class)->findOneBy(['code' => $values['hid_course_code']]);
$evaluation->setCourse($course);
$category = $entityManager->getRepository(GradebookCategory::class)->find($values['hid_category_id']);
$evaluation->setCategory($category);
$evaluation->setWeight($values['weight_mask']);
$evaluation->setMax($values['max']);
$evaluation->setVisible(empty($values['visible']) ? 0 : 1);
$entityManager->flush();
$logInfo = [ $logInfo = [
'tool' => TOOL_GRADEBOOK, 'tool' => TOOL_GRADEBOOK,
'tool_id' => 0, 'tool_id' => 0,
'tool_id_detail' => 0, 'tool_id_detail' => 0,
'action' => 'edit-eval', 'action' => $evaluationId ? 'edit-eval' : 'new-eval',
'action_details' => '', 'action_details' => '',
]; ];
Event::registerLog($logInfo); Event::registerLog($logInfo);
header('Location: '.Category::getUrl().'editeval=&selectcat='.$eval->get_category_id()); header('Location: '.Category::getUrl().'editeval=&selectcat='.$evaluation->getCategory()->getId());
exit; exit;
} }
$selectcat_inter = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : 0; $selectcat_inter = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : 0;

@ -204,7 +204,7 @@ class Gradebook extends Model
public function getSkillsByGradebook($id) public function getSkillsByGradebook($id)
{ {
$id = (int) $id; $id = (int) $id;
$sql = "SELECT skill.id, skill.name $sql = "SELECT skill.id, skill.title as name
FROM {$this->table_skill} skill FROM {$this->table_skill} skill
INNER JOIN {$this->table_skill_rel_gradebook} skill_rel_gradebook INNER JOIN {$this->table_skill_rel_gradebook} skill_rel_gradebook
ON skill.id = skill_rel_gradebook.skill_id ON skill.id = skill_rel_gradebook.skill_id

Loading…
Cancel
Save