Merge branch '1.10.x' into bootstrap

1.10.x
aragonc 11 years ago
commit 57eec79af4
  1. 2
      main/admin/course_list.php
  2. 1
      main/badge/criteria.php
  3. 120
      main/badge/issued.php
  4. 104
      main/coursecopy/classes/CourseRestorer.class.php
  5. 35
      main/exercice/TestCategory.php
  6. 1
      main/inc/lib/social.lib.php
  7. 2
      main/install/install.lib.php
  8. 53
      main/template/default/skill/issued.tpl
  9. 2
      main/template/default/social/skills_block.tpl

@ -368,7 +368,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
$form = new FormValidator('search_simple', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);
$form->addElement('text', 'keyword', null, array('id' => 'course-search-keyword'));
$form->addButtonSearch(get_lang('SearchCourse'));
$advanced = '<a class="btn btn-default" href="'. api_get_path(WEB_CODE_PATH).'admin/course_list.php?search=advanced"><em class="fa fa-search"></i> '.get_lang('AdvancedSearch').'</a>';
$advanced = '<a class="btn btn-default" href="'. api_get_path(WEB_CODE_PATH).'admin/course_list.php?search=advanced"><em class="fa fa-search"></em> '.get_lang('AdvancedSearch').'</a>';
// Create a filter by session
$sessionFilter = new FormValidator('course_filter', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);

@ -16,6 +16,7 @@ if (!$skill) {
);
header('Location: ' . api_get_path(WEB_PATH));
exit;
}
$skillInfo = [

@ -0,0 +1,120 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Show information about the issued badge
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.badge
*/
require_once '../inc/global.inc.php';
$userId = isset($_GET['user']) ? intval($_GET['user']) : 0;
$skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0;
if (!isset($_GET['user'], $_GET['skill'])) {
header('Location: ' . api_get_path(WEB_PATH));
exit;
}
$entityManager = Database::getManager();
$user = $entityManager->find('ChamiloUserBundle:User', $_GET['user']);
$skill = $entityManager->find('ChamiloCoreBundle:Skill', $_GET['skill']);
if (!$user || !$skill) {
Display::addFlash(
Display::return_message(get_lang('NoResults'), 'error')
);
header('Location: ' . api_get_path(WEB_PATH));
exit;
}
$skillUserRepo = $entityManager->getRepository('ChamiloCoreBundle:SkillRelUser');
$userSkills = $skillUserRepo->findBy([
'userId' => $user->getId(),
'skillId' => $skill->getId()
]);
if (!$userSkills) {
Display::addFlash(
Display::return_message(get_lang('TheUserXNotYetAchievedTheSkillX'), 'error')
);
header('Location: ' . api_get_path(WEB_PATH));
exit;
}
$userInfo = [
'id' => $user->getId(),
'complete_name' => $user->getCompleteName()
];
$skillInfo = [
'id' => $skill->getId(),
'name' => $skill->getName(),
'short_code' => $skill->getShortCode(),
'description' => $skill->getDescription(),
'criteria' => $skill->getCriteria(),
'badge_image' => $skill->getWebIconPath(),
'courses' => []
];
$badgeAssertions = [];
foreach ($userSkills as $userSkill) {
$sessionId = 0;
$course = $entityManager->find('ChamiloCoreBundle:Course', $userSkill->getCourseId());
$courseName = $course->getTitle();
if ($userSkill->getSessionId()) {
$session = $entityManager->find('ChamiloCoreBundle:Session', $userSkill->getSessionId());
$sessionId = $session->getId();
$courseName = "[{$session->getName()}] {$course->getTitle()}";
}
$userSkillDate = api_get_local_time($userSkill->getAcquiredSkillAt());
$skillInfo['courses'][] = [
'name' => $courseName,
'date_issued' => api_format_date($userSkillDate, DATE_TIME_FORMAT_LONG)
];
$assertionUrl = api_get_path(WEB_CODE_PATH) . "badge/assertion.php?";
$assertionUrl .= http_build_query(array(
'user' => $user->getId(),
'skill' => $skill->getId(),
'course' => $userSkill->getCourseId(),
'session' => $userSkill->getSessionId()
));
$badgeAssertions[] = $assertionUrl;
}
$allowExport = api_get_user_id() == $user->getId();
if ($allowExport) {
$backpack = 'https://backpack.openbadges.org/';
$configBackpack = api_get_setting('openbadges_backpack');
if (strcmp($backpack, $configBackpack) !== 0) {
$backpack = $configBackpack;
}
$htmlHeadXtra[] = '<script src="' . $backpack . 'issuer.js"></script>';
}
$template = new Template('');
$template->assign('skill_info', $skillInfo);
$template->assign('user_info', $userInfo);
$template->assign('allow_export', $allowExport);
if ($allowExport) {
$template->assign('assertions', $badgeAssertions);
}
$content = $template->fetch(
$template->get_template('skill/issued.tpl')
);
$template->assign('header', get_lang('IssuedBadgeInformation'));
$template->assign('content', $content);
$template->display_one_col_template();

@ -303,7 +303,6 @@ class CourseRestorer
$course_info = api_get_course_info($destination_course_code);
if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
$table = Database :: get_course_table(TABLE_DOCUMENT);
$resources = $this->course->resources;
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
@ -319,12 +318,6 @@ class CourseRestorer
if ($document->file_type == FOLDER) {
$visibility = $document->item_properties[0]['visibility'];
/*if (!empty($document->title)) {
$title = $document->title;
} else {
$title = basename($document->path);
}*/
$new = substr($document->path, 8);
$folderList = explode('/', $new);
@ -384,13 +377,13 @@ class CourseRestorer
} elseif ($document->file_type == DOCUMENT) {
//Checking if folder exists in the database otherwise we created it
$dir_to_create = dirname($document->path);
if (!empty($dir_to_create) && $dir_to_create != 'document' && $dir_to_create != '/') {
if (is_dir($path.dirname($document->path))) {
$sql = "SELECT id FROM $table
WHERE
c_id = ".$this->destination_course_id." AND
path = '/".self::DBUTF8escapestring(substr(dirname($document->path), 9))."'";
$res = Database::query($sql);
if (Database::num_rows($res) == 0) {
//continue;
@ -437,11 +430,13 @@ class CourseRestorer
WHERE
c_id = ".$this->destination_course_id." AND
path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'";
$res = Database::query($sql);
$count = Database::num_rows($res);
if ($count == 0) {
$params = [
'path' => self::DBUTF8("/".substr($document->path, 9)),
'path' => "/".self::DBUTF8(substr($document->path, 9)),
'c_id' => $this->destination_course_id,
'comment'=> self::DBUTF8($document->comment),
'title' => self::DBUTF8($document->title),
@ -449,15 +444,15 @@ class CourseRestorer
'size' => self::DBUTF8($document->size),
'session_id' => $my_session_id
];
$document_id = Database::insert($table, $params);
$document_id = Database::insert($table, $params, true);
if ($document_id) {
$sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
Database::query($sql);
}
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id;
api_item_property_update(
$course_info,
TOOL_DOCUMENT,
@ -473,20 +468,8 @@ class CourseRestorer
} else {
$obj = Database::fetch_object($res);
$document_id = $obj->id;
/*$sql = "UPDATE ".$table." SET
path = '/".self::DBUTF8escapestring(substr($document->path, 9))."',
c_id = ".$this->destination_course_id.",
comment = '".self::DBUTF8escapestring($document->comment)."',
title = '".self::DBUTF8escapestring($document->title)."' ,
filetype ='".$document->file_type."',
size = '".$document->size."',
session_id = '$my_session_id'
WHERE
c_id = ".$this->destination_course_id." AND
path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'";*/
$params = [
'path' => self::DBUTF8("/".substr($document->path, 9)),
'path' => "/".self::DBUTF8(substr($document->path, 9)),
'c_id' => $this->destination_course_id,
'comment'=> self::DBUTF8($document->comment),
'title' => self::DBUTF8($document->title),
@ -538,15 +521,6 @@ class CourseRestorer
file_put_contents($path.$document->path,$content);
}
/*$sql = "UPDATE $table SET
comment = '".self::DBUTF8escapestring($document->comment)."',
title='".self::DBUTF8escapestring($document->title)."',
size='".$document->size."'
WHERE
c_id = ".$this->destination_course_id." AND
id = '".$document_id."'";
Database::query($sql);*/
$params = [
'comment'=> self::DBUTF8($document->comment),
'title' => self::DBUTF8($document->title),
@ -635,7 +609,6 @@ class CourseRestorer
$dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
$basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
//$dest_filename = basename($dest_document_path); // e.g: "collaborative.png"
$base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document"
$path_title = '/'.$new_base_foldername.'/'.$document_path[2];
@ -672,15 +645,6 @@ class CourseRestorer
}
}
/*$sql = "INSERT INTO $table SET
path = '$path_title',
c_id = ".$this->destination_course_id.",
comment = '".self::DBUTF8escapestring($document->comment)."',
title = '".self::DBUTF8escapestring(basename($path_title))."' ,
filetype ='".$document->file_type."',
size = '".$document->size."',
session_id = '$my_session_id'";*/
$params = [
'path' => self::DBUTF8($path_title),
'c_id' => $this->destination_course_id,
@ -737,17 +701,6 @@ class CourseRestorer
}
}
/*$sql = "INSERT INTO ".$table." SET
c_id = ".$this->destination_course_id.",
path = '/".self::DBUTF8escapestring(substr($new_file_name, 9))."',
comment = '".self::DBUTF8escapestring($document->comment)."',
title = '".self::DBUTF8escapestring($document->title)."' ,
filetype ='".$document->file_type."',
size = '".$document->size."',
session_id = '$my_session_id'";
Database::query($sql);
$document_id = Database::insert_id();*/
$params = [
'path' => "/".self::DBUTF8escapestring(substr($new_file_name, 9)),
'c_id' => $this->destination_course_id,
@ -778,8 +731,6 @@ class CourseRestorer
$my_session_id
);
}
}
} else {
@ -804,18 +755,6 @@ class CourseRestorer
}
}
/*$sql = "INSERT INTO ".$table." SET
c_id = ".$this->destination_course_id.",
path = '/".self::DBUTF8escapestring(substr($new_file_name, 9))."',
comment = '".self::DBUTF8escapestring($document->comment)."',
title = '".self::DBUTF8escapestring($document->title)."' ,
filetype ='".$document->file_type."',
size = '".$document->size."',
session_id = '$my_session_id'";
Database::query($sql);
$document_id = Database::insert_id();*/
$params = [
'c_id' => $this->destination_course_id,
'path' => "/".self::DBUTF8escapestring(substr($new_file_name, 9)),
@ -880,20 +819,9 @@ class CourseRestorer
}
}
/*$sql = "INSERT INTO ".$table." SET
c_id = ".$this->destination_course_id.",
path = '/".substr($document->path, 9)."',
comment = '".self::DBUTF8escapestring($document->comment)."',
title = '".self::DBUTF8escapestring($document->title)."' ,
filetype='".$document->file_type."',
size= '".$document->size."',
session_id = '$my_session_id'";
Database::query($sql);
$document_id = Database::insert_id();*/
$params = [
'c_id' => $this->destination_course_id,
'path' => "/".self::DBUTF8("/".substr($document->path, 9)),
'path' => "/".self::DBUTF8(substr($document->path, 9)),
'comment'=> self::DBUTF8($document->comment),
'title' => self::DBUTF8($document->title),
'filetype' => self::DBUTF8($document->file_type),
@ -2057,8 +1985,7 @@ class CourseRestorer
$course_id = api_get_course_int_id();
// Let's restore the categories
$tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table
if ($this->course->has_resources(RESOURCE_TEST_CATEGORY))
{
if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) {
$resources = $this->course->resources;
foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory ) {
$tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $id;
@ -2296,7 +2223,6 @@ class CourseRestorer
}
}
}
}
}
}
@ -2379,7 +2305,8 @@ class CourseRestorer
];
$answerId = Database::insert($table_ans, $params);
if ($answerId) {
$sql = "UPDATE $table_ans SET question_option_id = iid WHERE iid = $answerId";
$sql = "UPDATE $table_ans SET question_option_id = iid
WHERE iid = $answerId";
Database::query($sql);
}
}
@ -2549,8 +2476,9 @@ class CourseRestorer
// we set the ref code here and then we update in a for loop
$ref = $item['ref'];
//Dealing with path the same way as ref as some data has been put into path when it's a local resource
//Only fix the path for no scos
// Dealing with path the same way as ref as some data has
// been put into path when it's a local resource
// Only fix the path for no scos
if ($item['item_type'] == 'sco') {
$path = $item['path'];
} else {
@ -2684,7 +2612,7 @@ class CourseRestorer
{
$sessionId = intval($sessionId);
$work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
// Query in student publication

@ -648,14 +648,16 @@ class TestCategory
*
* @return int is id of test category
*/
public static function get_category_id_for_title($in_title, $in_c_id = 0)
public static function get_category_id_for_title($title, $courseId = 0)
{
$out_res = 0;
if ($in_c_id == 0) {
$in_c_id = api_get_course_int_id();
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
$courseId = intval($courseId);
$tbl_cat = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
$sql = "SELECT id FROM $tbl_cat WHERE c_id=$in_c_id AND title = '".Database::escape_string($in_title)."'";
$sql = "SELECT id FROM $tbl_cat
WHERE c_id = $courseId AND title = '".Database::escape_string($title)."'";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$data = Database::fetch_array($res);
@ -666,23 +668,30 @@ class TestCategory
/**
* Add a relation between question and category in table c_quiz_question_rel_category
* @param int $in_category_id
* @param int $in_question_id
* @param int $in_course_c_id
* @param int $categoryId
* @param int $questionId
* @param int $courseId
*
* @return int
*/
public static function add_category_for_question_id($in_category_id, $in_question_id, $in_course_c_id)
public static function add_category_for_question_id($categoryId, $questionId, $courseId)
{
$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
// if question doesn't have a category
// @todo change for 1.10 when a question can have several categories
if (TestCategory::getCategoryForQuestion($in_question_id, $in_course_c_id) == 0 &&
$in_question_id > 0 &&
$in_course_c_id > 0
if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 &&
$questionId > 0 &&
$courseId > 0
) {
$sql = "INSERT INTO $table
VALUES (".intval($in_course_c_id).", ".intval($in_question_id).", ".intval($in_category_id).")";
$sql = "INSERT INTO $table (c_id, question_id, category_id)
VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")";
Database::query($sql);
$id = Database::insert_id();
return $id;
}
return false;
}
/**

@ -1885,6 +1885,7 @@ class SocialManager extends UserManager
$template = new Template(null, false, false, false, false, false);
$template->assign('ranking', $ranking);
$template->assign('skills', $skills);
$template->assign('user_id', $userId);
$template->assign(
'show_skills_report_link',
api_is_student() || api_is_student_boss() || api_is_drh()

@ -1242,7 +1242,7 @@ function get_contact_registration_form()
<div class="clear"></div>
<div class="form-group">
<div class="col-sm-3">&nbsp;</div>
<div class="col-sm-9"><button type="button" class="btn btn-default" onclick="javascript:send_contact_information();" value="'.get_lang('SendInformation').'" ><em class="fa fa-floppy-o"> </i> '.get_lang('SendInformation').'</button></div>
<div class="col-sm-9"><button type="button" class="btn btn-default" onclick="javascript:send_contact_information();" value="'.get_lang('SendInformation').'" ><em class="fa fa-floppy-o"></em> '.get_lang('SendInformation').'</button></div>
</div>
<div class="form-group">
<div class="col-sm-3">&nbsp;</div>

@ -0,0 +1,53 @@
<div class="row">
<div class="col-md-4">
<figure class="thumbnail">
<img class="img-responsive" src="{{ skill_info.badge_image }}" alt="{{ skill_info.name }}">
<figcaption class="caption text-center">
<p class="lead">{{ skill_info.name }}</p>
</figcaption>
</figure>
<h3>{{ 'SkillAcquiredAt'|get_lang }}</h3>
<ul class="fa-ul">
{% for course in skill_info.courses %}
<li>
<p>
<em class="fa fa-clock-o fa-fw"></em> {{ 'TimeXThroughCourseY'|get_lang|format(course.date_issued, course.name) }}
</p>
</li>
{% endfor %}
</ul>
{% if allow_export %}
<p class="text-center">
<a href="#" class="btn btn-success" id="badge-export-button">
<i class="fa fa-external-link-square fa-fw"></i> {{ 'ExportBadge'|get_lang }}
</a>
</p>
{% endif %}
</div>
<div class="col-md-8">
<h3>{{ 'RecipientDetails'|get_lang }}</h3>
<p class="lead">{{ user_info.complete_name }}</p>
<h3>{{ 'BadgeDetails'|get_lang }}</h3>
<h3>{{ 'Name'|get_lang }}</h3>
<p>{{ skill_info.name }}</p>
{% if skill_info.short_code %}
<h3>{{ 'ShortCode'|get_lang }}</h3>
<p>{{ skill_info.short_code }}</p>
{% endif %}
<h3>{{ 'Description'|get_lang }}</h3>
<p>{{ skill_info.description }}</p>
<h3>{{ 'CriteriaToEarnTheBadge'|get_lang }}</h3>
<p>{{ skill_info.criteria }}</p>
</div>
</div>
{% if allow_export %}
<script>
$(document).on('ready', function () {
$('#badge-export-button').on('click', function (e) {
e.preventDefault();
OpenBadges.issue({{ assertions|json_encode() }});
});
});
</script>
{% endif %}

@ -32,7 +32,7 @@
<ul class="list-unstyled list-badges">
{% for skill in skills %}
<li class="thumbnail">
<a href="{{ _p.web_main ~ 'badge/criteria.php?' ~ {'id': skill.id}|url_encode() }}" target="_blank">
<a href="{{ _p.web_main ~ 'badge/issued.php?' ~ {'skill': skill.id, 'user': user_id}|url_encode() }}" target="_blank">
<img title="{{ skill.name }}" class="img-responsive" src="{{ skill.icon ? skill.web_icon_thumb_path : 'badges-default.png'|icon(64) }}" width="64" height="64" alt="{{ skill.name }}">
<div class="caption">
<p class="text-center">{{ skill.name }}</p>

Loading…
Cancel
Save