Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/2790/head
Angel Fernando Quiroz Campos 7 years ago
commit 206dbbcec9
  1. 20
      main/exercise/export/aiken/aiken_classes.php
  2. 47
      main/exercise/question.class.php
  3. 7
      main/exercise/question_admin.inc.php
  4. 2
      main/inc/ajax/user_manager.ajax.php
  5. 4
      main/inc/lib/formvalidator/FormValidator.class.php
  6. 2
      main/ticket/course_user_list.php
  7. 1
      main/ticket/report.php
  8. 4
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

@ -32,26 +32,6 @@ class Aiken2Question extends Question
return $answer;
}
/**
* @param string $code
*
* @return bool
*/
public function addCode($code)
{
if (api_get_configuration_value('allow_question_code') && !empty($this->id)) {
$code = Database::escape_string($code);
$table = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "UPDATE $table SET code = '$code'
WHERE iid = {$this->id} AND c_id = {$this->course['real_id']}";
Database::query($sql);
return true;
}
return false;
}
public function createAnswersForm($form)
{
return true;

@ -38,6 +38,7 @@ abstract class Question
public $questionTypeWithFeedback;
public $extra;
public $export = false;
public $code;
public static $questionTypes = [
UNIQUE_ANSWER => ['unique_answer.class.php', 'UniqueAnswer'],
MULTIPLE_ANSWER => ['multiple_answer.class.php', 'MultipleAnswer'],
@ -165,6 +166,7 @@ abstract class Question
$objQuestion->course = $course_info;
$objQuestion->feedback = isset($object->feedback) ? $object->feedback : '';
$objQuestion->category = TestCategory::getCategoryForQuestion($id, $course_id);
$objQuestion->code = isset($object->code) ? $object->code : '';
$tblQuiz = Database::get_course_table(TABLE_QUIZ_TEST);
$sql = "SELECT DISTINCT q.exercice_id
@ -229,11 +231,16 @@ abstract class Question
public function getTitleToDisplay($itemNumber)
{
$showQuestionTitleHtml = api_get_configuration_value('save_titles_as_html');
$title = '';
if (!empty($this->code) && api_get_configuration_value('allow_question_code')) {
$title .= '<h4>'.$this->code.'</h4>';
}
$title = $showQuestionTitleHtml ? '' : '<strong>';
$title .= $showQuestionTitleHtml ? '' : '<strong>';
$title .= $itemNumber.'. '.$this->selectTitle();
$title .= $showQuestionTitleHtml ? '' : '</strong>';
return Display::div(
$title,
['class' => 'question_title']
@ -403,7 +410,7 @@ abstract class Question
*/
public function selectNbrExercises()
{
return sizeof($this->exerciseList);
return count($this->exerciseList);
}
/**
@ -423,7 +430,7 @@ abstract class Question
*/
public function updateParentId($id)
{
$this->parent_id = intval($id);
$this->parent_id = (int) $id;
}
/**
@ -1677,6 +1684,10 @@ abstract class Question
//$form->addElement('select', 'parent_id', get_lang('AttachToMedia'), $course_medias);
}
if (api_get_configuration_value('allow_question_code') && api_is_platform_admin()) {
$form->addText('code', get_lang('QuestionCode'));
}
$form->addElement('html', '</div>');
if (!isset($_GET['fromExercise'])) {
@ -1716,6 +1727,10 @@ abstract class Question
$defaults['questionCategory'] = $this->category;
$defaults['feedback'] = $this->feedback;
if (api_get_configuration_value('allow_question_code') && api_is_platform_admin()) {
$defaults['code'] = $this->code;
}
// Came from he question pool
if (isset($_GET['fromExercise'])) {
$form->setDefaults($defaults);
@ -1748,6 +1763,10 @@ abstract class Question
if ($this->type != MEDIA_QUESTION) {
$this->save($exercise);
if (api_is_platform_admin()) {
$this->addCode($form->getSubmitValue('code'));
}
// modify the exercise
$exercise->addToList($this->id);
$exercise->update_question_positions();
@ -2415,4 +2434,26 @@ abstract class Question
return false;
}
/**
* @param string $code
*
* @return bool
*/
public function addCode($code)
{
if (api_get_configuration_value('allow_question_code') && !empty($this->id)) {
$code = Database::escape_string($code);
$table = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "UPDATE $table SET code = '$code'
WHERE iid = {$this->id} AND c_id = {$this->course['real_id']}";
Database::query($sql);
return true;
}
return false;
}
}

@ -35,8 +35,13 @@ if (is_object($objQuestion)) {
$typesInformation = Question::get_question_type_list();
$form_title_extra = isset($typesInformation[$type][1]) ? get_lang($typesInformation[$type][1]) : null;
$code = '';
if (isset($objQuestion->code) && !empty($objQuestion->code)) {
$code = ' ('.$objQuestion->code.')';
}
// form title
$form->addHeader($text.': '.$form_title_extra);
$form->addHeader($text.': '.$form_title_extra.$code);
// question form elements
$objQuestion->createForm($form, $objExercise);

@ -14,6 +14,7 @@ $action = $_GET['a'];
switch ($action) {
case 'get_user_like':
if (api_is_platform_admin() || api_is_drh()) {
$query = $_REQUEST['q'];
$conditions = [
'username' => $query,
@ -29,6 +30,7 @@ switch ($action) {
$result['items'] = $result;
}
echo json_encode($result);
}
break;
case 'get_user_popup':
$courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0;

@ -914,6 +914,8 @@ EOT;
* @param string $label
* @param array $attributes
*
* @return HTML_QuickForm_file
*
* @throws Exception if the file doesn't have an id
*/
public function addFile($name, $label, $attributes = [])
@ -940,6 +942,8 @@ EOT;
$this->addHidden($id.'_crop_result', '');
$this->addHidden($id.'_crop_image_base_64', '');
}
return $element;
}
/**

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
exit;
/**
* @package chamilo.plugin.ticket
*/

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
exit;
use ChamiloSession as Session;
/**

@ -2712,8 +2712,8 @@ class CourseRestorer
'preview_image' => self::DBUTF8($lp->preview_image),
'use_max_score' => self::DBUTF8($lp->use_max_score),
'autolaunch' => self::DBUTF8(isset($lp->autolaunch) ? $lp->autolaunch : ''),
'created_on' => self::DBUTF8($lp->created_on),
'modified_on' => self::DBUTF8($lp->modified_on),
'created_on' => empty($lp->created_on) ? api_get_utc_datetime() : self::DBUTF8($lp->created_on),
'modified_on' => empty($lp->modified_on) ? api_get_utc_datetime() : self::DBUTF8($lp->modified_on),
'publicated_on' => empty($lp->publicated_on) ? api_get_utc_datetime() : self::DBUTF8($lp->publicated_on),
'expired_on' => self::DBUTF8($lp->expired_on),
'debug' => self::DBUTF8($lp->debug),

Loading…
Cancel
Save