Merge remote-tracking branch 'upstream/1.11.x' into 1.11.x.hide-teachers-name-from-catalog

pull/4067/head
Juan Cortizas Ponte 5 years ago
commit 9fe5bdb3ed
  1. 78
      main/exercise/exercise.class.php
  2. 12
      main/exercise/overview.php
  3. 4
      main/install/configuration.dist.php
  4. 4
      main/lang/english/trad4all.inc.php
  5. 4
      main/lang/french/trad4all.inc.php
  6. 4
      main/lang/spanish/trad4all.inc.php
  7. 26
      main/mySpace/student_follow_export.php
  8. 2
      plugin/questionoptionsevaluation/evaluation.php
  9. 12
      plugin/xapi/README.md
  10. 2
      plugin/xapi/src/Entity/InternalLog.php
  11. 4
      plugin/xapi/src/Entity/ToolLaunch.php
  12. 2
      plugin/xapi/src/XApiPlugin.php

@ -97,6 +97,7 @@ class Exercise
public $hideExpectedAnswer;
public $forceShowExpectedChoiceColumn;
public $disableHideCorrectAnsweredQuestions;
public $hideAttemptsTableOnStartPage;
/**
* Constructor of the class.
@ -142,6 +143,7 @@ class Exercise
$this->hideNoAnswer = false;
$this->hideExpectedAnswer = false;
$this->disableHideCorrectAnsweredQuestions = false;
$this->hideAttemptsTableOnStartPage = 0;
if (!empty($courseId)) {
$courseInfo = api_get_course_info_by_id($courseId);
@ -227,6 +229,10 @@ class Exercise
$this->hideQuestionNumber = $object->hide_question_number == 1;
}
if (isset($object->hide_attempts_table)) {
$this->hideAttemptsTableOnStartPage = $object->hide_attempts_table == 1;
}
if (isset($object->show_previous_button)) {
$this->showPreviousButton = $object->show_previous_button == 1;
}
@ -1680,6 +1686,9 @@ class Exercise
if ($showHideConfiguration) {
$paramsExtra['hide_question_number'] = $this->hideQuestionNumber;
}
if (true === api_get_configuration_value('quiz_hide_attempts_table_on_start_page')) {
$paramsExtra['hide_attempts_table'] = $this->getHideAttemptsTableOnStartPage();
}
$params = array_merge($params, $paramsExtra);
@ -2466,6 +2475,15 @@ class Exercise
get_lang('UpdateTitleInLps')
);
$allowHideAttempts = api_get_configuration_value('quiz_hide_attempts_table_on_start_page');
if ($allowHideAttempts) {
$group = [
$form->createElement('radio', 'hide_attempts_table', null, get_lang('Yes'), '1'),
$form->createElement('radio', 'hide_attempts_table', null, get_lang('No'), '0'),
];
$form->addGroup($group, null, get_lang('HideAttemptsTableOnStartPage'));
}
$defaults = [];
if (api_get_setting('search_enabled') === 'true') {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
@ -2667,6 +2685,7 @@ class Exercise
$this->setPageResultConfigurationDefaults($defaults);
$this->setHideQuestionNumberDefaults($defaults);
$this->setHideAttemptsTableOnStartPageDefaults($defaults);
$form->setDefaults($defaults);
// Freeze some elements.
@ -2840,6 +2859,9 @@ class Exercise
if ($showHideConfiguration) {
$this->setHideQuestionNumber($form->getSubmitValue('hide_question_number'));
}
$this->setHideAttemptsTableOnStartPage($form->getSubmitValue('hide_attempts_table'));
$this->preventBackwards = (int) $form->getSubmitValue('prevent_backwards');
$this->start_time = null;
@ -8552,6 +8574,34 @@ class Exercise
return 0;
}
/**
* Set the value to 1 to hide the attempts table on start page.
*
* @param int $value
*/
public function setHideAttemptsTableOnStartPage($value = 0)
{
$showHideAttemptsTableOnStartPage = api_get_configuration_value('quiz_hide_attempts_table_on_start_page');
if ($showHideAttemptsTableOnStartPage) {
$this->hideAttemptsTableOnStartPage = (int) $value;
}
}
/**
* Gets the value to hide or show the attempts table on start page. If it does not exist, it is set to 0.
*
* @return int 1 if the attempts table must be hidden
*/
public function getHideAttemptsTableOnStartPage()
{
$showHideAttemptsTableOnStartPage = api_get_configuration_value('quiz_hide_attempts_table_on_start_page');
if ($showHideAttemptsTableOnStartPage) {
return (int) $this->hideAttemptsTableOnStartPage;
}
return 0;
}
/**
* @param array $values
*/
@ -8596,6 +8646,19 @@ class Exercise
}
}
/**
* Sets the value to show or hide the attempts table on start page in the default settings of the forms.
*
* @param array $defaults
*/
public function setHideAttemptsTableOnStartPageDefaults(&$defaults)
{
$configuration = $this->getHideAttemptsTableOnStartPageConfiguration();
if (!empty($configuration) && !empty($defaults)) {
$defaults = array_merge($defaults, $configuration);
}
}
/**
* @return array
*/
@ -8627,6 +8690,21 @@ class Exercise
return [];
}
/**
* Get the value to show or hide the attempts table on start page in the default settings of the forms.
*
* @return array
*/
public function getHideAttemptsTableOnStartPageConfiguration()
{
$pageConfig = api_get_configuration_value('quiz_hide_attempts_table_on_start_page');
if ($pageConfig) {
return ['hide_attempts_table' => $this->hideAttemptsTableOnStartPage];
}
return [];
}
/**
* @param string $attribute
*

@ -510,11 +510,13 @@ if ($isLimitReached) {
);
}
$html .= Display::tag(
'div',
$table_content,
['class' => 'table-responsive']
);
if (0 == $objExercise->getHideAttemptsTableOnStartPage()) {
$html .= Display::tag(
'div',
$table_content,
['class' => 'table-responsive']
);
}
$html .= '</div>';
if ($certificateBlock) {

@ -1363,6 +1363,10 @@ $_configuration['required_extra_fields_in_profile'] = [
// ALTER TABLE c_quiz ADD COLUMN hide_question_number int NULL DEFAULT 0 COMMENT 'Show/Hide question number in quiz';
//$_configuration['quiz_hide_question_number'] = false;
// Allows you to show or hide the attempts table of an exercise on start page
// ALTER TABLE c_quiz ADD COLUMN hide_attempts_table int NULL DEFAULT 0 COMMENT 'Show/Hide attempts table of an exercise on start page';
//$_configuration['quiz_hide_attempts_table_on_start_page'] = false;
// Allow multiple options for the exercise "save answer" option
// ALTER TABLE c_quiz MODIFY COLUMN save_correct_answers INT NULL DEFAULT NULL;
//$_configuration['allow_quiz_save_correct_options'] = false;

@ -8814,4 +8814,8 @@ $TokenExpiredActionAlreadyRealized = "Token expired, action already realized";
$Corrector = "Corrector";
$CorrectionDate = "Correction date";
$HideAttemptsTableOnStartPage = "Hide attempts table on start page";
$ScormAndLPMaxProgress = "Maximum progress in learning paths";
$ HideSkills = "Hide skills";
$OptionsToHideInExport = "Options for hiding in export";
$HideAssignment = "Hide assignments";
?>

@ -8746,4 +8746,8 @@ $TokenExpiredActionAlreadyRealized = "Token expiré, action déjà réalisée";
$Corrector = "Correcteur";
$CorrectionDate = "Date de correction";
$HideAttemptsTableOnStartPage = "Masquer le tableau des tentatives sur la page de démarrage";
$ScormAndLPMaxProgress = "Progrès maximum dans les parcours";
$ HideSkills = "Masquer les compétences";
$OptionsToHideInExport = "Options pour masquer dans l'export";
$HideAssignment = "Masquer les travaux";
?>

@ -8842,4 +8842,8 @@ $TokenExpiredActionAlreadyRealized = "Token expirado, acción ya realizada";
$Corrector = "Corrector";
$CorrectionDate = "Fecha de corrección";
$HideAttemptsTableOnStartPage = "Ocultar la tabla de intentos en la página de inicio";
$ScormAndLPMaxProgress = "Progreso máximo en lecciones";
$ HideSkills = "Ocultar competencias";
$OptionsToHideInExport = "Opciones para esconder en el reporte";
$HideAssignment = "Esconder tareas";
?>

@ -74,8 +74,12 @@ function generateForm(int $studentId, array $coursesInSessions): FormValidator
[],
FormValidator::LAYOUT_BOX
);
// Option to hide the column Time in lp tables
$form->addCheckBox('hide_connection_time', null, get_lang('HideConnectionTime'));
// Options to hide columns or blocks in export pdf
$hideOptionsExport['connection_time'] = get_lang('HideConnectionTime');
$hideOptionsExport['skills'] = get_lang('HideSkills');
$hideOptionsExport['assignment'] = get_lang('HideAssignment');
$form->addCheckBoxGroup("hide_options", get_lang('OptionsToHideInExport'), $hideOptionsExport);
foreach ($coursesInSessions as $sId => $courses) {
if (empty($courses)) {
continue;
@ -459,7 +463,7 @@ function generateHtmlForTasks(int $studentId, array $courseInfo, int $sessionId)
.Export::convert_array_to_html($taskTable);
}
function generateHtmlForCourse(int $studentId, array $coursesInSessions, int $courseId, int $sessionId, bool $hideConnectionTime = false): ?string
function generateHtmlForCourse(int $studentId, array $coursesInSessions, int $courseId, int $sessionId, bool $hideConnectionTime = false, bool $hideAssignment = false): ?string
{
if (empty($coursesInSessions[$sessionId]) || !in_array($courseId, $coursesInSessions[$sessionId])) {
return null;
@ -484,7 +488,9 @@ function generateHtmlForCourse(int $studentId, array $coursesInSessions, int $co
$courseHtml[] = generateHtmlForLearningPaths($studentId, $courseInfo, $sessionId, $hideConnectionTime);
$courseHtml[] = generateHtmlForQuizzes($studentId, $courseInfo, $sessionId);
$courseHtml[] = generateHtmlForTasks($studentId, $courseInfo, $sessionId);
if (!$hideAssignment) {
$courseHtml[] = generateHtmlForTasks($studentId, $courseInfo, $sessionId);
}
return implode(PHP_EOL, $courseHtml);
}
@ -509,19 +515,25 @@ if ($form->validate()) {
);
$coursesInfo = [];
$hideConnectionTime = isset($values['hide_connection_time']);
$hideConnectionTime = isset($values['hide_options']['connection_time']);
$hideSkills = isset($values['hide_options']['skills']);
$hideAssignment = isset($values['hide_options']['assignment']);
if (!empty($values['sc'])) {
foreach ($values['sc'] as $courseKey) {
[$sessionId, $courseId] = explode('_', $courseKey);
$coursesInfo[] = generateHtmlForCourse($studentInfo['id'], $coursesInSessions, $courseId, $sessionId, $hideConnectionTime);
$coursesInfo[] = generateHtmlForCourse($studentInfo['id'], $coursesInSessions, $courseId, $sessionId, $hideConnectionTime, $hideAssignment);
}
}
$skills = Tracking::displayUserSkills($studentInfo['id']);
if ($hideSkills) {
$skills = '';
}
$view = new Template('', false, false, false, true, false, false);
$view->assign('user_info', $studentInfo);
$view->assign('careers', MyStudents::userCareersTable($studentInfo['id']));
$view->assign('skills', Tracking::displayUserSkills($studentInfo['id']));
$view->assign('skills', $skills);
$view->assign('classes', MyStudents::getBlockForClasses($studentInfo['id']));
$view->assign('courses_info', $coursesInfo);

@ -65,7 +65,7 @@ if ($formEvaluation->validate()) {
exit;
}
$formEvaluation->setDefaults(['formula' => $plugin->getFormulaForExercise($exercise->iId)]);
$formEvaluation->setDefaults(['formula' => $plugin->getFormulaForExercise($exercise->iid)]);
echo Display::return_message(
$plugin->get_lang('QuizQuestionsScoreRulesTitleConfirm'),

@ -70,10 +70,20 @@ CREATE TABLE xapi_activity_profile (id INT AUTO_INCREMENT NOT NULL, profile_id V
```
**From 0.2 (beta) [2021-10-15]**
With the LRS an internal log is registered based on the actor mbox's email or the actor account's name coming from the statement
- With the LRS an internal log is registered based on the actor mbox's email or the actor account's name coming from the statement
To update, execute this queries:
```sql
CREATE TABLE xapi_internal_log (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, statement_id VARCHAR(255) NOT NULL, verb VARCHAR(255) NOT NULL, object_id VARCHAR(255) NOT NULL, activity_name VARCHAR(255) DEFAULT NULL, activity_description VARCHAR(255) DEFAULT NULL, score_scaled DOUBLE PRECISION DEFAULT NULL, score_raw DOUBLE PRECISION DEFAULT NULL, score_min DOUBLE PRECISION DEFAULT NULL, score_max DOUBLE PRECISION DEFAULT NULL, created_at DATETIME DEFAULT NULL, INDEX IDX_C1C667ACA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
ALTER TABLE xapi_internal_log ADD CONSTRAINT FK_C1C667ACA76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
```
- asda
**From 0.3 (beta) [2021-11-11]**
- Fix: Add foreign keys with course/session in tool_launch table and foreign key with user in internal_log table.
```sql
ALTER TABLE xapi_internal_log ADD CONSTRAINT FK_C1C667ACA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE;
ALTER TABLE xapi_tool_launch ADD CONSTRAINT FK_E18CB58391D79BD3 FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE;
ALTER TABLE xapi_tool_launch ADD CONSTRAINT FK_E18CB583613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE CASCADE;
```

@ -24,7 +24,7 @@ class InternalLog
private $id;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $user;
/**

@ -43,14 +43,14 @@ class ToolLaunch
* @var \Chamilo\CoreBundle\Entity\Course
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false)
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
private $course;
/**
* @var \Chamilo\CoreBundle\Entity\Session|null
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $session;
/**

@ -45,7 +45,7 @@ class XApiPlugin extends Plugin implements HookPluginInterface
*/
protected function __construct()
{
$version = '0.2 (beta)';
$version = '0.3 (beta)';
$author = [
'Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>',
];

Loading…
Cancel
Save