Merge pull request #779 from AngelFQC/1.10.x

Fix and improve Session About page - refs BT#9889 #TMI
1.10.x
Angel Fernando Quiroz Campos 10 years ago
commit 9bd03c19a1
  1. 16
      main/auth/courses.php
  2. 27
      main/auth/courses_controller.php
  3. 29
      main/gradebook/lib/be/category.class.php
  4. 5
      main/inc/lib/SequenceResourceManager.php
  5. 9
      main/template/default/auth/confirm_session_subscription.tpl
  6. 2
      main/template/default/layout/head.tpl
  7. 2
      main/template/default/sequence_resource/session_requirements.tpl
  8. 18
      main/template/default/session/about.tpl

@ -211,9 +211,21 @@ switch ($action) {
break;
case 'subscribe_to_session':
$userId = api_get_user_id();
$confirmed = isset($_GET['confirm']);
$sessionId = intval($_GET['session_id']);
if (empty($userId)) {
header('Location: ' . api_get_path(WEB_PATH));
api_not_allowed();
exit;
}
if (!$confirmed) {
$template = new Template(null, false, false, false, false, false);
$template->assign('session_id', $sessionId);
$layout = $template->get_template('auth/confirm_session_subscription.tpl');
echo $template->fetch($layout);
exit;
}
@ -223,7 +235,7 @@ switch ($action) {
$repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
$sequences = $repository->getRequirements(
$_GET['session_id'],
$sessionId,
SequenceResource::SESSION_TYPE
);

@ -534,23 +534,32 @@ class CoursesController
$url .= 'auth/courses.php?';
$url .= http_build_query([
'action' => 'subscribe_to_session',
'session_id' => intval($sessionId)
'session_id' => intval($sessionId),
'modal_size' => 'md'
]);
$result = Display::toolbarButton(
get_lang('Subscribe'),
$url,
'check-circle',
'primary',
['class' => 'btn-lg btn-block ajax']
);
} else {
$url .= 'inc/email_editor.php?';
$url .= http_build_query([
'action' => 'subscribe_me_to_session',
'session' => Security::remove_XSS($sessionName)
]);
}
$result = Display::toolbarButton(
get_lang('Subscribe'),
$url,
'check-circle',
'primary',
['class' => 'btn-lg btn-block']
);
$result = Display::toolbarButton(
get_lang('Subscribe'),
$url,
'check-circle',
'primary',
['class' => 'btn-lg btn-block']
);
}
$hook = HookResubscribe::create();
if (!empty($hook)) {

@ -2006,17 +2006,28 @@ class Category implements GradebookItem
/**
* Check whether a user has finished a course by its gradebook
* @param int $userId The user ID
* @param \Category $category The gradebook category
* @param \Category $category Optional. The gradebook category.
* To check by the gradebook category
* @param int $categoryId Optional. The gradebook category ID.
* To check by the category ID
* @param string $courseCode Optional. The course code
* @param int $sessionId Optional. The session ID
* @return boolean
*/
public static function userFinishedCourse($userId, \Category $category = null, $categoryId = 0)
public static function userFinishedCourse(
$userId,
\Category $category = null,
$categoryId = 0,
$courseCode = null,
$sessionId = 0
)
{
if (is_null($category) && empty($categoryId)) {
return false;
}
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$courseCode = empty($courseCode) ? api_get_course_id() : $courseCode;
$sessionId = empty($sessionId) ? api_get_session_id() : $sessionId;
if (is_null($category) && !empty($categoryId)) {
$cats_course = Category::load(
@ -2029,10 +2040,14 @@ class Category implements GradebookItem
false
);
if (empty($cats_course)) {
return false;
}
$category = $cats_course[0];
}
$currentScore = self::getCurrentScore($userId, $category->get_id(), $courseCode, $sessionId, true);
$currentScore = self::getCurrentScore($userId, $category->get_id(), $courseCode, $sessionId);
$minCertificateScore = $category->get_certificate_min_score();
@ -2093,6 +2108,10 @@ class Category implements GradebookItem
false
);
if (empty($cats_course)) {
return 0;
}
$category = $cats_course[0];
$courseEvaluations = $category->get_evaluations($userId, true);

@ -78,7 +78,10 @@ class SequenceResourceManager
if (!empty($userId)) {
$itemSession['status'] = $itemSession['status'] && Category::userFinishedCourse(
$userId,
$category
$category,
null,
$course->getCode(),
$sessionRequired->getId()
);
}
}

@ -0,0 +1,9 @@
<p class="text-center lead">{{ 'AreYouSureToSubscribe'|get_lang }}</p>
<div class="row">
<div class="col-sm-3 col-sm-offset-3">
<a href="{{ _p.web_main }}auth/courses.php?{{ {'action':'subscribe_to_session', 'session_id':session_id, 'confirm':'1'}|url_encode() }}" class="btn btn-success btn-block">{{ 'Yes'|get_lang }}</a>
</div>
<div class="col-sm-3">
<button type="button" class="btn btn-danger btn-block" data-dismiss="modal">{{ 'No'|get_lang }}</button>
</div>
</div>

@ -349,7 +349,7 @@ $(function() {
});
// Global popup
$('a.ajax').on('click', function(e) {
$('body').on('click', 'a.ajax', function(e) {
e.preventDefault();
var contentUrl = this.href,

@ -1,4 +1,4 @@
<h2 class="page-header">{{ 'SessionRequirements'|get_lang }}</h2>
<h2 class="page-header">{{ 'RequiredSessions'|get_lang }}</h2>
{% for item in sequences %}
<h4>{{ item.name }}</h4>

@ -80,12 +80,6 @@
<div class="description-course">
{{ course_data.description.getContent }}
</div>
{% if courses|length == 1 and not is_subscribed %}
<div class="subscribe">
{{ subscribe_button }}
</div>
{% endif %}
</div>
</div>
@ -180,19 +174,9 @@
</div>
</div>
</div>
{% if courses|length == 1 and not is_subscribed %}
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="text-center">
{{ subscribe_button }}
</div>
</div>
</div>
{% endif %}
{% endfor %}
{% if courses|length > 1 and not is_subscribed %}
{% if _u.logged and not is_subscribed %}
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="text-center">

Loading…
Cancel
Save