Minor - flint fixes

pull/2818/head
Julio Montoya 6 years ago
parent a2489bb854
commit b4a67204b5
  1. 1
      main/course_info/infocours.php
  2. 1
      src/ContactBundle/Controller/ContactController.php
  3. 4
      src/CoreBundle/Entity/UserCourseCategory.php
  4. 1
      src/CoreBundle/Migrations/Schema/V200/Version20.php
  5. 219
      src/LtiBundle/Controller/CourseController.php
  6. 1
      src/LtiBundle/Controller/ServiceController.php
  7. 3
      src/LtiBundle/Util/Utils.php

@ -17,7 +17,6 @@ use Chamilo\CoreBundle\Framework\Container;
*
* @package chamilo.course_info
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_COURSE_SETTING;
$this_section = SECTION_COURSES;

@ -16,7 +16,6 @@ use Symfony\Component\Routing\Annotation\Route;
* @Route("/")
*
* @package Chamilo\ContactBundle\Controller
*
*/
class ContactController extends AbstractController
{

@ -44,8 +44,7 @@ class UserCourseCategory
protected $sort;
/**
*
* @var boolean
* @var bool
*
* @ORM\Column(name="collapsed", type="boolean", nullable=true)
*/
@ -132,5 +131,4 @@ class UserCourseCategory
{
return $this->id;
}
}

@ -773,7 +773,6 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE track_e_exercises CHANGE exe_result score DOUBLE PRECISION NOT NULL');
$this->addSql('ALTER TABLE c_lp CHANGE author author LONGTEXT NOT NULL');
$table = $schema->getTable('user_course_category');
if (!$table->hasColumn('collapsed')) {
$this->addSql('ALTER TABLE user_course_category ADD collapsed TINYINT(1) DEFAULT NULL');

@ -482,6 +482,115 @@ class CourseController extends BaseController
);
}
/**
* @Route("/grade/{catId}", name="chamilo_lti_grade", requirements={"catId"="\d+"})
*
* @Security("has_role('ROLE_TEACHER')")
*
* @param string $catId
*
* @throws \Exception
*/
public function gradeAction($catId)
{
$em = $this->getDoctrine()->getManager();
$toolRepo = $em->getRepository('ChamiloLtiBundle:ExternalTool');
$course = $this->getCourse();
/** @var User $user */
$user = $this->getUser();
$categories = \Category::load(null, null, $course->getCode());
if (empty($categories)) {
throw $this->createNotFoundException();
}
$evaladd = new \Evaluation();
$evaladd->set_user_id($user->getId());
if (!empty($catId)) {
$evaladd->set_category_id($catId);
$cat = \Category::load($catId);
$evaladd->set_course_code($course->getCode());
} else {
$evaladd->set_category_id(0);
}
$form = new \EvalForm(
\EvalForm::TYPE_ADD,
$evaladd,
null,
'add_eval_form',
null,
$this->generateUrl(
'chamilo_lti_grade',
['catId' => $catId, 'code' => $course->getCode()]
).'?'.api_get_cidreq()
);
$form->removeElement('name');
$form->removeElement('addresult');
/** @var \HTML_QuickForm_select $slcLtiTools */
$slcLtiTools = $form->createElement('select', 'name', $this->trans('External tool'));
$form->insertElementBefore($slcLtiTools, 'hid_category_id');
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
$tools = $toolRepo->findBy(['course' => $course, 'gradebookEval' => null]);
/** @var ExternalTool $tool */
foreach ($tools as $tool) {
$slcLtiTools->addOption($tool->getName(), $tool->getId());
}
if (!$form->validate()) {
$this->setConfigureBreadcrumb($course);
return $this->render(
'@ChamiloTheme/Lti/gradebook.html.twig',
[
'form' => $form->returnForm(),
]
);
}
$values = $form->exportValues();
$tool = $toolRepo->find($values['name']);
if (empty($tool)) {
throw $this->createNotFoundException();
}
$eval = new \Evaluation();
$eval->set_name($tool->getName());
$eval->set_description($values['description']);
$eval->set_user_id($values['hid_user_id']);
if (!empty($values['hid_course_code'])) {
$eval->set_course_code($values['hid_course_code']);
}
$eval->set_course_code($course->getCode());
$eval->set_category_id($values['hid_category_id']);
$values['weight'] = $values['weight_mask'];
$eval->set_weight($values['weight']);
$eval->set_max($values['max']);
$eval->set_visible(empty($values['visible']) ? 0 : 1);
$eval->add();
$gradebookEval = $em->find('ChamiloCoreBundle:GradebookEvaluation', $eval->get_id());
$tool->setGradebookEval($gradebookEval);
$em->persist($tool);
$em->flush();
$this->addFlash('success', $this->trans('Evaluation for external tool added'));
return $this->redirect(api_get_course_url());
}
/**
* @param Course $course
*/
@ -725,114 +834,4 @@ class CourseController extends BaseController
return $newTool;
}
/**
* @Route("/grade/{catId}", name="chamilo_lti_grade", requirements={"catId"="\d+"})
*
* @Security("has_role('ROLE_TEACHER')")
*
* @param string $catId
*
* @return void
* @throws \Exception
*/
public function gradeAction($catId)
{
$em = $this->getDoctrine()->getManager();
$toolRepo = $em->getRepository('ChamiloLtiBundle:ExternalTool');
$course = $this->getCourse();
/** @var User $user */
$user = $this->getUser();
$categories = \Category::load(null, null, $course->getCode());
if (empty($categories)) {
throw $this->createNotFoundException();
}
$evaladd = new \Evaluation();
$evaladd->set_user_id($user->getId());
if (!empty($catId)) {
$evaladd->set_category_id($catId);
$cat = \Category::load($catId);
$evaladd->set_course_code($course->getCode());
} else {
$evaladd->set_category_id(0);
}
$form = new \EvalForm(
\EvalForm::TYPE_ADD,
$evaladd,
null,
'add_eval_form',
null,
$this->generateUrl(
'chamilo_lti_grade',
['catId' => $catId, 'code' => $course->getCode()]
).'?'.api_get_cidreq()
);
$form->removeElement('name');
$form->removeElement('addresult');
/** @var \HTML_QuickForm_select $slcLtiTools */
$slcLtiTools = $form->createElement('select', 'name', $this->trans('External tool'));
$form->insertElementBefore($slcLtiTools, 'hid_category_id');
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
$tools = $toolRepo->findBy(['course' => $course, 'gradebookEval' => null]);
/** @var ExternalTool $tool */
foreach ($tools as $tool) {
$slcLtiTools->addOption($tool->getName(), $tool->getId());
}
if (!$form->validate()) {
$this->setConfigureBreadcrumb($course);
return $this->render(
'@ChamiloTheme/Lti/gradebook.html.twig',
[
'form' => $form->returnForm()
]
);
}
$values = $form->exportValues();
$tool = $toolRepo->find($values['name']);
if (empty($tool)) {
throw $this->createNotFoundException();
}
$eval = new \Evaluation();
$eval->set_name($tool->getName());
$eval->set_description($values['description']);
$eval->set_user_id($values['hid_user_id']);
if (!empty($values['hid_course_code'])) {
$eval->set_course_code($values['hid_course_code']);
}
$eval->set_course_code($course->getCode());
$eval->set_category_id($values['hid_category_id']);
$values['weight'] = $values['weight_mask'];
$eval->set_weight($values['weight']);
$eval->set_max($values['max']);
$eval->set_visible(empty($values['visible']) ? 0 : 1);
$eval->add();
$gradebookEval = $em->find('ChamiloCoreBundle:GradebookEvaluation', $eval->get_id());
$tool->setGradebookEval($gradebookEval);
$em->persist($tool);
$em->flush();
$this->addFlash('success', $this->trans('Evaluation for external tool added'));
return $this->redirect(api_get_course_url());
}
}

@ -9,7 +9,6 @@ use Chamilo\LtiBundle\Component\OutcomeReadRequest;
use Chamilo\LtiBundle\Component\OutcomeReplaceRequest;
use Chamilo\LtiBundle\Component\OutcomeUnsupportedRequest;
use Chamilo\LtiBundle\Entity\ExternalTool;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

@ -8,7 +8,8 @@ use Chamilo\SettingsBundle\Manager\SettingsManager;
use Chamilo\UserBundle\Entity\User;
/**
* Class Utils
* Class Utils.
*
* @package Chamilo\LtiBundle\Util
*/
class Utils

Loading…
Cancel
Save