Skip to content

Commit

Permalink
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jan 25, 2019
2 parents eb46f47 + f1c3ea8 commit 206dbbc
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 39 deletions.
20 changes: 0 additions & 20 deletions main/exercise/export/aiken/aiken_classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,6 @@ public function setAnswer()
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;
Expand Down
47 changes: 44 additions & 3 deletions main/exercise/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -165,6 +166,7 @@ public static function read($id, $course_id = null)
$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
Expand Down Expand Up @@ -229,11 +231,16 @@ public function selectTitle()
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']
Expand Down Expand Up @@ -403,7 +410,7 @@ public function selectExerciseList()
*/
public function selectNbrExercises()
{
return sizeof($this->exerciseList);
return count($this->exerciseList);
}

/**
Expand All @@ -423,7 +430,7 @@ public function updateTitle($title)
*/
public function updateParentId($id)
{
$this->parent_id = intval($id);
$this->parent_id = (int) $id;
}

/**
Expand Down Expand Up @@ -1677,6 +1684,10 @@ public function createForm(&$form, $exercise)
//$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'])) {
Expand Down Expand Up @@ -1716,6 +1727,10 @@ public function createForm(&$form, $exercise)
$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);
Expand Down Expand Up @@ -1748,6 +1763,10 @@ public function processCreation($form, $exercise)
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();
Expand Down Expand Up @@ -2415,4 +2434,26 @@ private function resizePicture($Dimension, $Max)

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;
}

}
7 changes: 6 additions & 1 deletion main/exercise/question_admin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@
$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);
Expand Down
28 changes: 15 additions & 13 deletions main/inc/ajax/user_manager.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@

switch ($action) {
case 'get_user_like':
$query = $_REQUEST['q'];
$conditions = [
'username' => $query,
'firstname' => $query,
'lastname' => $query,
];
$users = UserManager::getUserListLike($conditions, [], false, 'OR');
$result = [];
if (!empty($users)) {
foreach ($users as $user) {
$result[] = ['id' => $user['id'], 'text' => $user['complete_name'].' ('.$user['username'].')'];
if (api_is_platform_admin() || api_is_drh()) {
$query = $_REQUEST['q'];
$conditions = [
'username' => $query,
'firstname' => $query,
'lastname' => $query,
];
$users = UserManager::getUserListLike($conditions, [], false, 'OR');
$result = [];
if (!empty($users)) {
foreach ($users as $user) {
$result[] = ['id' => $user['id'], 'text' => $user['complete_name'].' ('.$user['username'].')'];
}
$result['items'] = $result;
}
$result['items'] = $result;
echo json_encode($result);
}
echo json_encode($result);
break;
case 'get_user_popup':
$courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0;
Expand Down
4 changes: 4 additions & 0 deletions main/inc/lib/formvalidator/FormValidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,8 @@ public function addHeader($text)
* @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 = [])
Expand All @@ -940,6 +942,8 @@ public function addFile($name, $label, $attributes = [])
$this->addHidden($id.'_crop_result', '');
$this->addHidden($id.'_crop_image_base_64', '');
}

return $element;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions main/ticket/course_user_list.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */

exit;

/**
* @package chamilo.plugin.ticket
*/
Expand Down
1 change: 1 addition & 0 deletions main/ticket/report.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */

exit;
use ChamiloSession as Session;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2712,8 +2712,8 @@ public function restore_learnpaths($session_id = 0, $respect_base_content = fals
'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),
Expand Down

0 comments on commit 206dbbc

Please sign in to comment.