Fix php errors, use entities

pull/3924/head
Julio Montoya 4 years ago
parent fed015d26b
commit 028435b3e1
  1. 2
      public/main/admin/user_edit.php
  2. 2
      public/main/auth/profile.php
  3. 2
      public/main/exercise/exercise.class.php
  4. 27
      public/main/exercise/question_create.php

@ -61,7 +61,7 @@ function show_image(image,width,height) {
} }
function confirmation(name) { function confirmation(name) {
if (confirm("'.get_lang('AreYouSureToDeleteJS', '').' " + name + " ?")) { if (confirm("'.get_lang('Are you sure to delete?').' " + name + " ?")) {
document.forms["profile"].submit(); document.forms["profile"].submit();
} else { } else {
return false; return false;

@ -56,7 +56,7 @@ $(function() {
}); });
function confirmation(name) { function confirmation(name) {
if (confirm("'.get_lang('AreYouSureToDeleteJS', '').' " + name + " ?")) { if (confirm("'.get_lang('Are you sure to delete?').' " + name + " ?")) {
document.forms["profile"].submit(); document.forms["profile"].submit();
} else { } else {
return false; return false;

@ -9278,7 +9278,7 @@ class Exercise
'', '',
[ [
'onclick' => "javascript:if(!confirm('".addslashes( 'onclick' => "javascript:if(!confirm('".addslashes(
api_htmlentities(get_lang('AreYouSureToDeleteJS'), ENT_QUOTES, $charset) api_htmlentities(get_lang('Are you sure to delete?'))
)." ".addslashes($exercise->getUnformattedTitle())."?"."')) return false;", )." ".addslashes($exercise->getUnformattedTitle())."?"."')) return false;",
'href' => 'exercise.php?'.api_get_cidreq( 'href' => 'exercise.php?'.api_get_cidreq(
).'&action=delete&sec_token='.$token.'&exerciseId='.$exerciseId, ).'&action=delete&sec_token='.$token.'&exerciseId='.$exerciseId,

@ -2,6 +2,9 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
// the section (tabs) // the section (tabs)
@ -45,21 +48,27 @@ $session_id = api_get_session_id();
// the exercises // the exercises
$tbl_exercises = Database::get_course_table(TABLE_QUIZ_TEST); $tbl_exercises = Database::get_course_table(TABLE_QUIZ_TEST);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$course = api_get_course_entity();
$session = api_get_session_entity();
$repo = Container::getQuizRepository();
$qb = $repo->getResourcesByCourse($course, $session);
$exercises = $qb->getQuery()->getResult();
$sql = "SELECT iid,title,type,description, results_disabled /*$sql = "SELECT iid,title,type,description, results_disabled
FROM $tbl_exercises FROM $tbl_exercises
WHERE c_id = $course_id AND active<>'-1' AND session_id=".$session_id.' WHERE c_id = $course_id AND active<>'-1' AND session_id=".$session_id.'
ORDER BY title ASC'; ORDER BY title ASC';
$result = Database::query($sql); $result = Database::query($sql);*/
$exercises['-'] = '-'.get_lang('Select exercise').'-'; $list['-'] = '-'.get_lang('Select exercise').'-';
while ($row = Database :: fetch_array($result)) { /** @var CQuiz $exercise */
$exercises[$row['iid']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE); foreach ($exercises as $exercise) {
$list[$exercise->getIid()] = cut($exercise->getTitle(), EXERCISE_MAX_NAME_SIZE);
} }
$form->addSelect('exercise', get_lang('Test'), $exercises); $form->addSelect('exercise', get_lang('Test'), $list);
// generate default content // generate default content
$form->addElement( $form->addCheckBox(
'checkbox',
'is_content', 'is_content',
null, null,
get_lang('Generate default content'), get_lang('Generate default content'),
@ -82,7 +91,7 @@ if ($form->validate()) {
// check feedback_type from current exercise for type of question delineation // check feedback_type from current exercise for type of question delineation
$exercise_id = (int) ($values['exercise']); $exercise_id = (int) ($values['exercise']);
$sql = "SELECT feedback_type FROM $tbl_exercises $sql = "SELECT feedback_type FROM $tbl_exercises
WHERE c_id = $course_id AND iid = '$exercise_id'"; WHERE iid = '$exercise_id'";
$rs_feedback_type = Database::query($sql); $rs_feedback_type = Database::query($sql);
$row_feedback_type = Database::fetch_row($rs_feedback_type); $row_feedback_type = Database::fetch_row($rs_feedback_type);
$feedback_type = $row_feedback_type[0]; $feedback_type = $row_feedback_type[0];

Loading…
Cancel
Save