';
break;
@@ -3842,7 +3883,7 @@ class Exercise
} else {
Event::saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
}
- } elseif ($answerType == MATCHING) {
+ } elseif (in_array($answerType, [MATCHING, DRAGGABLE])) {
if (isset($matching)) {
foreach ($matching as $j => $val) {
Event::saveQuestionAttempt($questionScore, $val, $quesId, $exeId, $j, $this->id);
diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php
index 5356e5b2bf..52bdc1ee9c 100755
--- a/main/exercice/exercise_show.php
+++ b/main/exercice/exercise_show.php
@@ -343,7 +343,7 @@ foreach ($questionList as $questionId) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
- } elseif ($answerType == MATCHING) {
+ } elseif (in_array($answerType, [MATCHING, DRAGGABLE])) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
diff --git a/main/exercice/exercise_submit.php b/main/exercice/exercise_submit.php
index 3dd10fc16c..f85b84fa92 100755
--- a/main/exercice/exercise_submit.php
+++ b/main/exercice/exercise_submit.php
@@ -57,6 +57,8 @@ $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
+$htmlHeadXtra[] = (new Template())->fetch('default/exercise/submit.js.tpl');
+
// General parameters passed via POST/GET
$learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : 0;
diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php
index b21b55279c..fa55d43668 100755
--- a/main/exercice/question.class.php
+++ b/main/exercice/question.class.php
@@ -49,7 +49,8 @@ abstract class Question
),
GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'),
- UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage']
+ UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'],
+ DRAGGABLE => ['Draggable.php', 'Draggable']
//MEDIA_QUESTION => array('media_question.class.php' , 'MediaQuestion')
);
diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php
index dcf9e0a128..e08b1c0ea0 100644
--- a/main/inc/lib/api.lib.php
+++ b/main/inc/lib/api.lib.php
@@ -473,6 +473,7 @@ define('GLOBAL_MULTIPLE_ANSWER', 14);
define('MEDIA_QUESTION', 15);
define('CALCULATED_ANSWER', 16);
define('UNIQUE_ANSWER_IMAGE', 17);
+define('DRAGGABLE', 18);
//Some alias used in the QTI exports
define('MCUA', 1);
diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php
index 9f3743e007..7522553fff 100755
--- a/main/inc/lib/course.lib.php
+++ b/main/inc/lib/course.lib.php
@@ -3122,7 +3122,7 @@ class CourseManager
relation_type=" . COURSE_RELATION_TYPE_RRHH . " AND
access_url_id = " . api_get_current_access_url_id() . "";
} else {
- $sql = "SELECT course_code FROM $tbl_course_rel_user
+ $sql = "SELECT c_id FROM $tbl_course_rel_user
WHERE user_id = $hr_manager_id AND relation_type=" . COURSE_RELATION_TYPE_RRHH . " ";
}
$result = Database::query($sql);
diff --git a/main/inc/lib/course_description.lib.php b/main/inc/lib/course_description.lib.php
index 95c6178b66..63d80743cc 100755
--- a/main/inc/lib/course_description.lib.php
+++ b/main/inc/lib/course_description.lib.php
@@ -14,55 +14,55 @@
*/
class CourseDescription
{
- private $id;
+ private $id;
private $course_id;
- private $title;
- private $content;
+ private $title;
+ private $content;
private $session_id;
private $description_type;
private $progress;
- /**
- * Constructor
- */
- public function __construct()
+ /**
+ * Constructor
+ */
+ public function __construct()
{
}
- /**
- * Returns an array of objects of type CourseDescription corresponding to
+ /**
+ * Returns an array of objects of type CourseDescription corresponding to
* a specific course, without session ids (session id = 0)
- *
- * @param int Course id
- * @return array Array of CourseDescriptions
- */
- public static function get_descriptions($course_id)
+ *
+ * @param int Course id
+ * @return array Array of CourseDescriptions
+ */
+ public static function get_descriptions($course_id)
{
- // Get course code
- $course_info = api_get_course_info_by_id($course_id);
+ // Get course code
+ $course_info = api_get_course_info_by_id($course_id);
if (!empty($course_info)) {
$course_id = $course_info['real_id'];
} else {
return array();
}
- $t_course_desc = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
- $sql = "SELECT * FROM $t_course_desc
- WHERE c_id = $course_id AND session_id = '0'";
- $sql_result = Database::query($sql);
- $results = array();
- while($row = Database::fetch_array($sql_result)) {
- $desc_tmp = new CourseDescription();
- $desc_tmp->set_id($row['id']);
- $desc_tmp->set_title($row['title']);
- $desc_tmp->set_content($row['content']);
- $desc_tmp->set_session_id($row['session_id']);
- $desc_tmp->set_description_type($row['description_type']);
- $desc_tmp->set_progress($row['progress']);
- $results[] = $desc_tmp;
- }
- return $results;
- }
+ $t_course_desc = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $sql = "SELECT * FROM $t_course_desc
+ WHERE c_id = $course_id AND session_id = '0'";
+ $sql_result = Database::query($sql);
+ $results = array();
+ while ($row = Database::fetch_array($sql_result)) {
+ $desc_tmp = new CourseDescription();
+ $desc_tmp->set_id($row['id']);
+ $desc_tmp->set_title($row['title']);
+ $desc_tmp->set_content($row['content']);
+ $desc_tmp->set_session_id($row['session_id']);
+ $desc_tmp->set_description_type($row['description_type']);
+ $desc_tmp->set_progress($row['progress']);
+ $results[] = $desc_tmp;
+ }
+ return $results;
+ }
/**
@@ -70,87 +70,90 @@ class CourseDescription
* first you must set session_id property with the object CourseDescription
* @return array
*/
- public function get_description_data()
+ public function get_description_data()
{
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
- $condition_session = api_get_session_condition($this->session_id, true, true);
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $condition_session = api_get_session_condition($this->session_id, true, true);
$course_id = api_get_course_int_id();
- $sql = "SELECT * FROM $tbl_course_description
+ $sql = "SELECT * FROM $tbl_course_description
WHERE c_id = $course_id $condition_session
ORDER BY id ";
- $rs = Database::query($sql);
- $data = array();
- while ($description = Database::fetch_array($rs)) {
- $data['descriptions'][$description['id']] = Security::remove_XSS($description, STUDENT);
- //reload titles to ensure we have the last version (after edition)
- //$data['default_description_titles'][$description['id']] = Security::remove_XSS($description['title'], STUDENT);
- }
- return $data;
- }
-
- /**
+ $rs = Database::query($sql);
+ $data = array();
+ while ($description = Database::fetch_array($rs)) {
+ $data['descriptions'][$description['id']] = Security::remove_XSS($description, STUDENT);
+ //reload titles to ensure we have the last version (after edition)
+ //$data['default_description_titles'][$description['id']] = Security::remove_XSS($description['title'], STUDENT);
+ }
+ return $data;
+ }
+
+ /**
* Get all data of course description by session id,
* first you must set session_id property with the object CourseDescription
* @deprecated
* @return array
*/
- public function get_description_history($description_type)
+ public function get_description_history($description_type)
{
- $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
- $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
+ $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
+ $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
- $description_id = $this->get_id_by_description_type($description_type);
- $item_property_id = api_get_item_property_id($course_id, TOOL_COURSE_DESCRIPTION, $description_id);
+ $description_id = $this->get_id_by_description_type($description_type);
+ $item_property_id = api_get_item_property_id(api_get_course_id(), TOOL_COURSE_DESCRIPTION, $description_id);
- $course_id = api_get_course_int_id();
+ $course_id = api_get_course_int_id();
- $sql = "SELECT tip.id, tip.course_id, tip.item_property_id, tip.title, tip.content, tip.progress, tip.lastedit_date, tip.session_id
+ $sql = "SELECT tip.id, tip.course_id, tip.item_property_id, tip.title, tip.content, tip.progress, tip.lastedit_date, tip.session_id
FROM $tbl_stats_item_property tip INNER JOIN $tbl_item_property ip
- ON ip.tool = '".TOOL_COURSE_DESCRIPTION."' AND ip.id = tip.item_property_id
- WHERE ip.c_id = $course_id AND tip.course_id = '$course_id' AND tip.session_id = '".intval($this->session_id)."'
+ ON ip.tool = '" . TOOL_COURSE_DESCRIPTION . "' AND ip.id = tip.item_property_id
+ WHERE ip.c_id = $course_id AND tip.course_id = '$course_id' AND tip.session_id = '" . intval($this->session_id) . "'
ORDER BY tip.lastedit_date DESC";
- $rs = Database::query($sql);
- $data = array();
- while ($description = Database::fetch_array($rs)) {
- $data['descriptions'][] = $description;
- }
- return $data;
- }
+ $rs = Database::query($sql);
+ $data = array();
+ while ($description = Database::fetch_array($rs)) {
+ $data['descriptions'][] = $description;
+ }
+ return $data;
+ }
- /**
+ /**
* Get all data by description and session id,
* first you must set session_id property with the object CourseDescription
- * @param int description type
+ * @param int description type
* @param string course code (optional)
- * @param int session id (optional)
+ * @param int session id (optional)
* @return array
*/
- public function get_data_by_description_type($description_type, $course_code = '', $session_id = null)
- {
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
- $course_id = api_get_course_int_id();
-
- if (!isset($session_id)) {
- $session_id = $this->session_id;
- }
- $condition_session = api_get_session_condition($session_id);
- if (!empty($course_code)) {
- $course_info = api_get_course_info($course_code);
+ public function get_data_by_description_type(
+ $description_type,
+ $course_code = '',
+ $session_id = null
+ ) {
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $course_id = api_get_course_int_id();
+
+ if (!isset($session_id)) {
+ $session_id = $this->session_id;
+ }
+ $condition_session = api_get_session_condition($session_id);
+ if (!empty($course_code)) {
+ $course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
- }
+ }
$description_type = intval($description_type);
- $sql = "SELECT * FROM $tbl_course_description
+ $sql = "SELECT * FROM $tbl_course_description
WHERE c_id = $course_id AND description_type='$description_type' $condition_session ";
- $rs = Database::query($sql);
- $data = array();
- if ($description = Database::fetch_array($rs)) {
- $data['description_title'] = $description['title'];
- $data['description_content'] = $description['content'];
- $data['progress'] = $description['progress'];
- }
- return $data;
- }
+ $rs = Database::query($sql);
+ $data = array();
+ if ($description = Database::fetch_array($rs)) {
+ $data['description_title'] = $description['title'];
+ $data['description_content'] = $description['content'];
+ $data['progress'] = $description['progress'];
+ }
+ return $data;
+ }
/**
* @param int $id
@@ -160,149 +163,147 @@ class CourseDescription
*/
public function get_data_by_id($id, $course_code = '', $session_id = null)
{
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
- $course_id = api_get_course_int_id();
-
- if (!isset($session_id)) {
- $session_id = $this->session_id;
- }
- $condition_session = api_get_session_condition($session_id);
- if (!empty($course_code)) {
- $course_info = api_get_course_info($course_code);
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $course_id = api_get_course_int_id();
+
+ if (!isset($session_id)) {
+ $session_id = $this->session_id;
+ }
+ $condition_session = api_get_session_condition($session_id);
+ if (!empty($course_code)) {
+ $course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
- }
+ }
$id = intval($id);
- $sql = "SELECT * FROM $tbl_course_description
+ $sql = "SELECT * FROM $tbl_course_description
WHERE c_id = $course_id AND id='$id' $condition_session ";
- $rs = Database::query($sql);
- $data = array();
- if ($description = Database::fetch_array($rs)) {
- $data['description_type'] = $description['description_type'];
- $data['description_title'] = $description['title'];
- $data['description_content'] = $description['content'];
- $data['progress'] = $description['progress'];
- }
+ $rs = Database::query($sql);
+ $data = array();
+ if ($description = Database::fetch_array($rs)) {
+ $data['description_type'] = $description['description_type'];
+ $data['description_title'] = $description['title'];
+ $data['description_content'] = $description['content'];
+ $data['progress'] = $description['progress'];
+ }
- return $data;
- }
+ return $data;
+ }
- /**
+ /**
* Get maximum description type by session id,
* first you must set session_id properties with the object CourseDescription
* @return int maximum description time adding one
*/
- public function get_max_description_type()
+ public function get_max_description_type()
{
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_id = api_get_course_int_id();
- $sql = "SELECT MAX(description_type) as MAX FROM $tbl_course_description
- WHERE c_id = $course_id AND session_id='".$this->session_id."'";
- $rs = Database::query($sql);
- $max = Database::fetch_array($rs);
- $description_type = $max['MAX']+1;
- if ($description_type < ADD_BLOCK) {
- $description_type = ADD_BLOCK;
- }
- return $description_type;
- }
-
- /**
+ $sql = "SELECT MAX(description_type) as MAX FROM $tbl_course_description
+ WHERE c_id = $course_id AND session_id='" . $this->session_id . "'";
+ $rs = Database::query($sql);
+ $max = Database::fetch_array($rs);
+ $description_type = $max['MAX'] + 1;
+ if ($description_type < ADD_BLOCK) {
+ $description_type = ADD_BLOCK;
+ }
+ return $description_type;
+ }
+
+ /**
* Insert a description to the course_description table,
* first you must set description_type, title, content, progress and
* session_id properties with the object CourseDescription
* @return int affected rows
*/
- public function insert()
+ public function insert()
{
if (empty($this->course_id)) {
- $course_id = api_get_course_int_id();
+ $course_id = api_get_course_int_id();
} else {
$course_id = $this->course_id;
}
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
- $sql = "INSERT IGNORE INTO $tbl_course_description SET
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $sql = "INSERT IGNORE INTO $tbl_course_description SET
c_id = $course_id,
- description_type = '".intval($this->description_type)."',
- title = '".Database::escape_string($this->title)."',
- content = '".Database::escape_string($this->content)."',
- progress = '".intval($this->progress)."',
- session_id = '".intval($this->session_id)."' ";
- $result = Database::query($sql);
- $last_id = Database::insert_id();
- $affected_rows = Database::affected_rows($result);
- if ($last_id > 0) {
+ description_type = '" . intval($this->description_type) . "',
+ title = '" . Database::escape_string($this->title) . "',
+ content = '" . Database::escape_string($this->content) . "',
+ progress = '" . intval($this->progress) . "',
+ session_id = '" . intval($this->session_id) . "' ";
+ $result = Database::query($sql);
+ $last_id = Database::insert_id();
+ $affected_rows = Database::affected_rows($result);
+ if ($last_id > 0) {
$sql = "UPDATE $tbl_course_description SET id = iid WHERE iid = $last_id";
Database::query($sql);
- //insert into item_property
- api_item_property_update(
- api_get_course_info(),
- TOOL_COURSE_DESCRIPTION,
- $last_id,
- 'CourseDescriptionAdded',
- api_get_user_id()
- );
- }
+ //insert into item_property
+ api_item_property_update(
+ api_get_course_info(),
+ TOOL_COURSE_DESCRIPTION,
+ $last_id,
+ 'CourseDescriptionAdded',
+ api_get_user_id()
+ );
+ }
- return $affected_rows;
- }
+ return $affected_rows;
+ }
- /**
+ /**
* Insert a row like history inside track_e_item_property table
* first you must set description_type, title, content, progress and
* session_id properties with the object CourseDescription
- * @param int description type
- * @return int affected rows
+ * @param int description type
+ * @return int affected rows
*/
- public function insert_stats($description_type)
+ public function insert_stats($description_type)
{
- $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
- $description_id = $this->get_id_by_description_type($description_type);
- $course_id = api_get_real_course_id();
- $course_code = api_get_course_id();
- $item_property_id = api_get_item_property_id($course_code, TOOL_COURSE_DESCRIPTION, $description_id);
- $sql = "INSERT IGNORE INTO $tbl_stats_item_property SET
- c_id = ".api_get_course_int_id().",
+ $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
+ $description_id = $this->get_id_by_description_type($description_type);
+ $course_id = api_get_real_course_id();
+ $course_code = api_get_course_id();
+ $item_property_id = api_get_item_property_id($course_code,
+ TOOL_COURSE_DESCRIPTION, $description_id);
+ $sql = "INSERT IGNORE INTO $tbl_stats_item_property SET
+ c_id = " . api_get_course_int_id() . ",
course_id = '$course_id',
item_property_id = '$item_property_id',
- title = '".Database::escape_string($this->title)."',
- content = '".Database::escape_string($this->content)."',
- progress = '".intval($this->progress)."',
- lastedit_date = '".date('Y-m-d H:i:s')."',
- lastedit_user_id = '".api_get_user_id()."',
- session_id = '".intval($this->session_id)."'";
- $result = Database::query($sql);
- $affected_rows = Database::affected_rows($result);
-
- $sql = "UPDATE $tbl_course_description SET id = iid WHERE iid = $last_id";
- Database::query($sql);
-
- return $affected_rows;
- }
-
- /**
+ title = '" . Database::escape_string($this->title) . "',
+ content = '" . Database::escape_string($this->content) . "',
+ progress = '" . intval($this->progress) . "',
+ lastedit_date = '" . date('Y-m-d H:i:s') . "',
+ lastedit_user_id = '" . api_get_user_id() . "',
+ session_id = '" . intval($this->session_id) . "'";
+ $result = Database::query($sql);
+ $affected_rows = Database::affected_rows($result);
+
+ return $affected_rows;
+ }
+
+ /**
* Update a description, first you must set description_type, title, content, progress
* and session_id properties with the object CourseDescription
- * @return int affected rows
+ * @return int affected rows
*/
- public function update()
+ public function update()
{
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
- $sql = "UPDATE $tbl_course_description SET
- title = '".Database::escape_string($this->title)."',
- content = '".Database::escape_string($this->content)."',
- progress = '".$this->progress."'
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $sql = "UPDATE $tbl_course_description SET
+ title = '" . Database::escape_string($this->title) . "',
+ content = '" . Database::escape_string($this->content) . "',
+ progress = '" . $this->progress . "'
WHERE
- id = '".intval($this->id)."' AND
- session_id = '".$this->session_id."' AND
- c_id = ".api_get_course_int_id();
- $result = Database::query($sql);
- $affected_rows = Database::affected_rows($result);
-
- if ($this->id > 0) {
- //insert into item_property
+ id = '" . intval($this->id) . "' AND
+ session_id = '" . $this->session_id . "' AND
+ c_id = " . api_get_course_int_id();
+ $result = Database::query($sql);
+ $affected_rows = Database::affected_rows($result);
+
+ if ($this->id > 0) {
+ //insert into item_property
api_item_property_update(
api_get_course_info(),
TOOL_COURSE_DESCRIPTION,
@@ -310,28 +311,28 @@ class CourseDescription
'CourseDescriptionUpdated',
api_get_user_id()
);
- }
- return $affected_rows;
- }
+ }
+ return $affected_rows;
+ }
- /**
+ /**
* Delete a description, first you must set description_type and session_id
* properties with the object CourseDescription
- * @return int affected rows
+ * @return int affected rows
*/
- public function delete()
+ public function delete()
{
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
- $course_id = api_get_course_int_id();
- $sql = "DELETE FROM $tbl_course_description
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $course_id = api_get_course_int_id();
+ $sql = "DELETE FROM $tbl_course_description
WHERE
c_id = $course_id AND
- id = '".intval($this->id)."' AND
- session_id = '".intval($this->session_id)."'";
- $result = Database::query($sql);
- $affected_rows = Database::affected_rows($result);
- if ($this->id > 0) {
- //insert into item_property
+ id = '" . intval($this->id) . "' AND
+ session_id = '" . intval($this->session_id) . "'";
+ $result = Database::query($sql);
+ $affected_rows = Database::affected_rows($result);
+ if ($this->id > 0) {
+ //insert into item_property
api_item_property_update(
api_get_course_info(),
TOOL_COURSE_DESCRIPTION,
@@ -339,164 +340,167 @@ class CourseDescription
'CourseDescriptionDeleted',
api_get_user_id()
);
- }
+ }
- return $affected_rows;
- }
+ return $affected_rows;
+ }
- /**
- * Get description id by description type
- * @param int description type
- * @return int description id
- */
- public function get_id_by_description_type($description_type)
+ /**
+ * Get description id by description type
+ * @param int description type
+ * @return int description id
+ */
+ public function get_id_by_description_type($description_type)
{
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_id = api_get_course_int_id();
- $sql = "SELECT id FROM $tbl_course_description
- WHERE c_id = $course_id AND description_type = '".intval($description_type)."'";
- $rs = Database::query($sql);
- $row = Database::fetch_array($rs);
- $description_id = $row['id'];
- return $description_id;
- }
-
- /**
- * get thematic progress in porcent for a course,
- * first you must set session_id property with the object CourseDescription
- * @param bool true for showing a icon about the progress, false otherwise (optional)
- * @param int Description type (optional)
- * @return string img html
- */
- public function get_progress_porcent($with_icon = false, $description_type = THEMATIC_ADVANCE)
- {
- $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
- $session_id = intval($session_id);
+ $sql = "SELECT id FROM $tbl_course_description
+ WHERE c_id = $course_id AND description_type = '" . intval($description_type) . "'";
+ $rs = Database::query($sql);
+ $row = Database::fetch_array($rs);
+ $description_id = $row['id'];
+ return $description_id;
+ }
+
+ /**
+ * get thematic progress in porcent for a course,
+ * first you must set session_id property with the object CourseDescription
+ * @param bool true for showing a icon about the progress, false otherwise (optional)
+ * @param int Description type (optional)
+ * @return string img html
+ */
+ public function get_progress_porcent(
+ $with_icon = false,
+ $description_type = THEMATIC_ADVANCE
+ ) {
+ $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+ $session_id = api_get_session_id();
$course_id = api_get_course_int_id();
- $sql = "SELECT progress FROM $tbl_course_description
+ $sql = "SELECT progress FROM $tbl_course_description
WHERE
c_id = $course_id AND
- description_type = '".intval($description_type)."' AND
- session_id = '".intval($this->session_id)."' ";
- $rs = Database::query($sql);
- $progress = '';
- $img = '';
- $title = '0%';
- $image = 'level_0.png';
- if (Database::num_rows($rs) > 0) {
- $row = Database::fetch_array($rs);
- $progress = $row['progress'].'%';
- $image = 'level_'.$row['progress'].'.png';
- }
- if ($with_icon) {
- $img = Display::return_icon($image,get_lang('ThematicAdvance'),array('style'=>'vertical-align:middle'));
- }
- $progress = $img.$progress;
- return $progress;
- }
-
- /**
- * Get description titles by default
- * @return array
- */
- public function get_default_description_title()
+ description_type = '" . intval($description_type) . "' AND
+ session_id = '" . intval($this->session_id) . "' ";
+ $rs = Database::query($sql);
+ $progress = '';
+ $img = '';
+ $title = '0%';
+ $image = 'level_0.png';
+ if (Database::num_rows($rs) > 0) {
+ $row = Database::fetch_array($rs);
+ $progress = $row['progress'] . '%';
+ $image = 'level_' . $row['progress'] . '.png';
+ }
+ if ($with_icon) {
+ $img = Display::return_icon($image, get_lang('ThematicAdvance'),
+ array('style' => 'vertical-align:middle'));
+ }
+ $progress = $img . $progress;
+ return $progress;
+ }
+
+ /**
+ * Get description titles by default
+ * @return array
+ */
+ public function get_default_description_title()
{
- $default_description_titles = array();
- $default_description_titles[1]= get_lang('GeneralDescription');
- $default_description_titles[2]= get_lang('Objectives');
- $default_description_titles[3]= get_lang('Topics');
- $default_description_titles[4]= get_lang('Methodology');
- $default_description_titles[5]= get_lang('CourseMaterial');
- $default_description_titles[6]= get_lang('HumanAndTechnicalResources');
- $default_description_titles[7]= get_lang('Assessment');
-
- $default_description_titles[8]= get_lang('Other');
- return $default_description_titles;
- }
-
- /**
- * Get description titles editable by default
- * @return array
- */
- public function get_default_description_title_editable()
+ $default_description_titles = array();
+ $default_description_titles[1] = get_lang('GeneralDescription');
+ $default_description_titles[2] = get_lang('Objectives');
+ $default_description_titles[3] = get_lang('Topics');
+ $default_description_titles[4] = get_lang('Methodology');
+ $default_description_titles[5] = get_lang('CourseMaterial');
+ $default_description_titles[6] = get_lang('HumanAndTechnicalResources');
+ $default_description_titles[7] = get_lang('Assessment');
+
+ $default_description_titles[8] = get_lang('Other');
+ return $default_description_titles;
+ }
+
+ /**
+ * Get description titles editable by default
+ * @return array
+ */
+ public function get_default_description_title_editable()
{
- $default_description_title_editable = array();
- $default_description_title_editable[1] = true;
- $default_description_title_editable[2] = true;
- $default_description_title_editable[3] = true;
- $default_description_title_editable[4] = true;
- $default_description_title_editable[5] = true;
- $default_description_title_editable[6] = true;
- $default_description_title_editable[7] = true;
- //$default_description_title_editable[8] = true;
- return $default_description_title_editable;
- }
-
- /**
- * Get description icons by default
- * @return array
- */
- public function get_default_description_icon()
+ $default_description_title_editable = array();
+ $default_description_title_editable[1] = true;
+ $default_description_title_editable[2] = true;
+ $default_description_title_editable[3] = true;
+ $default_description_title_editable[4] = true;
+ $default_description_title_editable[5] = true;
+ $default_description_title_editable[6] = true;
+ $default_description_title_editable[7] = true;
+ //$default_description_title_editable[8] = true;
+ return $default_description_title_editable;
+ }
+
+ /**
+ * Get description icons by default
+ * @return array
+ */
+ public function get_default_description_icon()
{
- $default_description_icon = array();
- $default_description_icon[1]= 'info.png';
- $default_description_icon[2]= 'objective.png';
- $default_description_icon[3]= 'topics.png';
- $default_description_icon[4]= 'strategy.png';
- $default_description_icon[5]= 'laptop.png';
- $default_description_icon[6]= 'teacher.png';
- $default_description_icon[7]= 'assessment.png';
- //$default_description_icon[8]= 'porcent.png';
- $default_description_icon[8]= 'wizard.png';
- return $default_description_icon;
- }
-
- /**
- * Get questions by default for help
- * @return array
- */
- public function get_default_question()
+ $default_description_icon = array();
+ $default_description_icon[1] = 'info.png';
+ $default_description_icon[2] = 'objective.png';
+ $default_description_icon[3] = 'topics.png';
+ $default_description_icon[4] = 'strategy.png';
+ $default_description_icon[5] = 'laptop.png';
+ $default_description_icon[6] = 'teacher.png';
+ $default_description_icon[7] = 'assessment.png';
+ //$default_description_icon[8]= 'porcent.png';
+ $default_description_icon[8] = 'wizard.png';
+ return $default_description_icon;
+ }
+
+ /**
+ * Get questions by default for help
+ * @return array
+ */
+ public function get_default_question()
{
- $question = array();
- $question[1]= get_lang('GeneralDescriptionQuestions');
- $question[2]= get_lang('ObjectivesQuestions');
- $question[3]= get_lang('TopicsQuestions');
- $question[4]= get_lang('MethodologyQuestions');
- $question[5]= get_lang('CourseMaterialQuestions');
- $question[6]= get_lang('HumanAndTechnicalResourcesQuestions');
- $question[7]= get_lang('AssessmentQuestions');
- //$question[8]= get_lang('ThematicAdvanceQuestions');
- return $question;
- }
-
- /**
- * Get informations by default for help
- * @return array
- */
- public function get_default_information()
+ $question = array();
+ $question[1] = get_lang('GeneralDescriptionQuestions');
+ $question[2] = get_lang('ObjectivesQuestions');
+ $question[3] = get_lang('TopicsQuestions');
+ $question[4] = get_lang('MethodologyQuestions');
+ $question[5] = get_lang('CourseMaterialQuestions');
+ $question[6] = get_lang('HumanAndTechnicalResourcesQuestions');
+ $question[7] = get_lang('AssessmentQuestions');
+ //$question[8]= get_lang('ThematicAdvanceQuestions');
+ return $question;
+ }
+
+ /**
+ * Get informations by default for help
+ * @return array
+ */
+ public function get_default_information()
{
- $information = array();
- $information[1]= get_lang('GeneralDescriptionInformation');
- $information[2]= get_lang('ObjectivesInformation');
- $information[3]= get_lang('TopicsInformation');
- $information[4]= get_lang('MethodologyInformation');
- $information[5]= get_lang('CourseMaterialInformation');
- $information[6]= get_lang('HumanAndTechnicalResourcesInformation');
- $information[7]= get_lang('AssessmentInformation');
- //$information[8]= get_lang('ThematicAdvanceInformation');
- return $information;
- }
-
- /**
- * Set description id
- * @return void
- */
- public function set_id($id)
+ $information = array();
+ $information[1] = get_lang('GeneralDescriptionInformation');
+ $information[2] = get_lang('ObjectivesInformation');
+ $information[3] = get_lang('TopicsInformation');
+ $information[4] = get_lang('MethodologyInformation');
+ $information[5] = get_lang('CourseMaterialInformation');
+ $information[6] = get_lang('HumanAndTechnicalResourcesInformation');
+ $information[7] = get_lang('AssessmentInformation');
+ //$information[8]= get_lang('ThematicAdvanceInformation');
+ return $information;
+ }
+
+ /**
+ * Set description id
+ * @return void
+ */
+ public function set_id($id)
{
- $this->id = $id;
- }
+ $this->id = $id;
+ }
/**
* Set description's course id
@@ -508,102 +512,102 @@ class CourseDescription
$this->course_id = intval($id);
}
- /**
- * Set description title
- * @return void
- */
- public function set_title($title)
+ /**
+ * Set description title
+ * @return void
+ */
+ public function set_title($title)
{
- $this->title = $title;
- }
+ $this->title = $title;
+ }
/**
- * Set description content
- * @return void
- */
- public function set_content($content)
+ * Set description content
+ * @return void
+ */
+ public function set_content($content)
{
- $this->content = $content;
- }
-
- /**
- * Set description session id
- * @return void
- */
- public function set_session_id($session_id)
+ $this->content = $content;
+ }
+
+ /**
+ * Set description session id
+ * @return void
+ */
+ public function set_session_id($session_id)
{
- $this->session_id = $session_id;
- }
-
- /**
- * Set description type
- * @return void
- */
- public function set_description_type($description_type)
+ $this->session_id = $session_id;
+ }
+
+ /**
+ * Set description type
+ * @return void
+ */
+ public function set_description_type($description_type)
{
- $this->description_type = $description_type;
- }
-
- /**
- * Set progress of a description
- * @return void
- */
- public function set_progress($progress)
+ $this->description_type = $description_type;
+ }
+
+ /**
+ * Set progress of a description
+ * @return void
+ */
+ public function set_progress($progress)
{
- $this->progress = $progress;
- }
-
- /**
- * get description id
- * @return int
- */
- public function get_id()
+ $this->progress = $progress;
+ }
+
+ /**
+ * get description id
+ * @return int
+ */
+ public function get_id()
{
- return $this->id;
- }
-
- /**
- * get description title
- * @return string
- */
- public function get_title()
+ return $this->id;
+ }
+
+ /**
+ * get description title
+ * @return string
+ */
+ public function get_title()
{
- return $this->title;
- }
-
- /**
- * get description content
- * @return string
- */
- public function get_content()
+ return $this->title;
+ }
+
+ /**
+ * get description content
+ * @return string
+ */
+ public function get_content()
{
- return $this->content;
- }
-
- /**
- * get session id
- * @return int
- */
- public function get_session_id()
+ return $this->content;
+ }
+
+ /**
+ * get session id
+ * @return int
+ */
+ public function get_session_id()
{
- return $this->session_id;
- }
-
- /**
- * get description type
- * @return int
- */
- public function get_description_type()
+ return $this->session_id;
+ }
+
+ /**
+ * get description type
+ * @return int
+ */
+ public function get_description_type()
{
- return $this->description_type;
- }
-
- /**
- * get progress of a description
- * @return int
- */
- public function get_progress()
+ return $this->description_type;
+ }
+
+ /**
+ * get progress of a description
+ * @return int
+ */
+ public function get_progress()
{
- return $this->progress;
- }
+ return $this->progress;
+ }
}
diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php
index cb046e5a1d..eb3e99b495 100755
--- a/main/inc/lib/display.lib.php
+++ b/main/inc/lib/display.lib.php
@@ -1754,8 +1754,8 @@ class Display
if (!empty($list)) {
$html = '
';
foreach ($list as $item) {
- $html .= '
'.$item['title'].'';
- $html .= '
'.$item['content'].'';
+ $html .= '
' . $item['title'] . '
';
+ $html .= '
' . $item['content'] . '
';
}
$html .= '
';
}
diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php
index 5236ba0eb0..dd81897ac5 100644
--- a/main/inc/lib/exercise.lib.php
+++ b/main/inc/lib/exercise.lib.php
@@ -104,8 +104,14 @@ class ExerciseLib
// on the right side are called answers
$num_suggestions = 0;
- if ($answerType == MATCHING) {
- $s .= '
';
+ if (in_array($answerType, [MATCHING, DRAGGABLE])) {
+ if ($answerType == DRAGGABLE) {
+ $s .= '
+
+
';
+ } else {
+ $s .= '
';
+ }
// Iterate through answers
$x = 1;
//mark letters for each answer
@@ -908,6 +914,94 @@ class ExerciseLib
} // end if()
$matching_correct_answer++;
}
+ } elseif ($answerType == DRAGGABLE) {
+ if ($answerCorrect != 0) {
+ $parsed_answer = $answer;
+ $windowId = $questionId . '_' . $lines_count;
+
+ $s .= '