Minor - remove unused code, add LP link, add intro #3644

pull/3565/head^2
Julio Montoya 5 years ago
parent 9dff93545c
commit 5c4c62f134
  1. 5
      plugin/positioning/lang/english.php
  2. 44
      plugin/positioning/src/ajax.php
  3. 17
      plugin/positioning/start.php
  4. 13
      plugin/positioning/start_student.php
  5. 2
      plugin/positioning/view/start.tpl
  6. 21
      plugin/positioning/view/start_student.tpl

@ -3,14 +3,11 @@
$strings['plugin_title'] = 'Positioning';
$strings['plugin_comment'] = 'Adds positioning tests to the course homepage';
$strings['tool_enable'] = 'Enable plugin';
$strings['block_course_if_initial_exercise_not_attempted'] = 'Block other course tools';
$strings['block_course_if_initial_exercise_not_attempted_help'] = 'When this option is enabled, if an initial positioning test has been configured, the learner will not be able to use the rest of the course on the course homepage until he/she has completed the initial test.';
$strings['average_percentage_to_unlock_final_exercise'] = 'End test unlock threshold';
$strings['average_percentage_to_unlock_final_exercise_help'] = 'Learners *must* have an average progress of at least this percentage (e.g. \'75\' for a 75% progress required) in the combined learning paths of this course.';
$strings['PositioningIntroduction'] = 'Please select one initial test and one final test below. Only tests that match the 3 following criteria will be available for selection: use at least 3 question categories, use the radar report mode *and* have only one possible attempt allowed. Once these are selected, the student will only be able to pass the final test if he/she has completed the average of all learning paths in this course to %S or more.';
$strings['PositioningIntroduction'] = 'Please select one initial test and one final test below. Only tests that match the 3 following criteria will be available for selection: use at least 3 question categories, use the radar report mode *and* have only one possible attempt allowed. Once these are selected, the student will only be able to pass the final test if he/she has completed the average of all learning paths in this course.';
$strings['SelectAsInitialTest'] = 'Select as initial test';
$strings['UnselectAsInitialTest'] = 'Unselect as initial test';
$strings['SelectAsFinalTest'] = 'Select as final test';

@ -1,44 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../../../main/inc/global.inc.php';
api_protect_admin_script();
$plugin = Positioning::create();
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
switch ($action) {
case 'delete-file':
$path = isset($_REQUEST['path']) ? $_REQUEST['path'] : null;
if (empty($path)) {
echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorEmptyPath')]);
exit;
}
if (unlink($path)) {
Display::addFlash($plugin->get_lang("DeletedSuccess"), 'success');
echo json_encode(["status" => "true"]);
} else {
echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorDeleteFile')]);
}
break;
case 'delete-files-list':
$list = isset($_REQUEST['list']) ? $_REQUEST['list'] : [];
if (empty($list)) {
echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorEmptyPath')]);
exit;
}
foreach ($list as $value) {
if (empty($value)) {
continue;
}
unlink($value);
}
Display::addFlash($plugin->get_lang("DeletedSuccess"), 'success');
echo json_encode(["status" => "true"]);
break;
}

@ -6,22 +6,23 @@ require_once __DIR__.'/../../main/inc/global.inc.php';
api_protect_course_script(true);
if (!api_is_allowed_to_edit()) {
// Students are redirected to the start_student.php
api_location(api_get_path(WEB_PLUGIN_PATH).'positioning/start_student.php?'.api_get_cidreq());
}
$plugin = Positioning::create();
if (!$plugin->isEnabled()) {
api_not_allowed(true);
}
if (!api_is_allowed_to_edit()) {
// Students are redirected to the start_student.php
api_location(api_get_path(WEB_PLUGIN_PATH).'positioning/start_student.php?'.api_get_cidreq());
}
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$formToString = '';
$currentUrl = api_get_self().'?'.api_get_cidreq();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$courseInfo = api_get_course_info();
switch ($action) {
case 'set_initial':
@ -109,6 +110,12 @@ if (!empty($users) && $initialData && $initialData['exercise_id']) {
$table->set_form_actions([]);
$exercises = $table->return_table();
$template->assign(
'positioning_introduction',
//Display::return_message(sprintf($plugin->get_lang('PositioningIntroduction'), $courseInfo['title']))
Display::return_message($plugin->get_lang('PositioningIntroduction'))
);
$template->assign('grid', $exercises);
$template->assign('radars', $radars);
$template->assign('initial_exercise', $initialExerciseTitle);

@ -13,9 +13,6 @@ if (!$plugin->isEnabled()) {
$htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js');
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$formToString = '';
$currentUrl = api_get_self().'?'.api_get_cidreq();
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();
@ -53,6 +50,7 @@ $studentAverage = (int) Tracking::getAverageStudentScore($currentUserId, $course
$averageToUnlock = (int) $plugin->get('average_percentage_to_unlock_final_exercise');
$finalExerciseTitle = '';
$lpUrl = '';
if ($finalData) {
$exerciseId = $finalData['exercise_id'];
$finalExercise = new Exercise();
@ -66,6 +64,8 @@ if ($finalData) {
$finalExerciseTitle = $finalExercise->get_formated_title();
if (!empty($initialResults)) {
$lpUrl = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq();
$lpUrl = Display::url(get_lang('LearningPath'),$lpUrl);
if ($studentAverage >= $averageToUnlock) {
$url = api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&exerciseId='.$exerciseId;
if (empty($finalResults)) {
@ -83,12 +83,9 @@ $template = new Template($nameTools);
$template->assign('initial_exercise', $initialExerciseTitle);
$template->assign('final_exercise', $finalExerciseTitle);
$template->assign(
'average_percentage_to_unlock_final_exercise',
$averageToUnlock
);
$template->assign('average_percentage_to_unlock_final_exercise', $averageToUnlock);
$template->assign('average', $studentAverage);
$template->assign('lp_url', $lpUrl);
$template->assign('radars', $radars);
$template->assign('content', $template->fetch('positioning/view/start_student.tpl'));
$template->display_one_col_template();

@ -1,4 +1,6 @@
{{ positioning_introduction }}
{{ grid }}
{% if radars %}

@ -1,11 +1,18 @@
<h3>{{ "InviteToTakePositioningTest"| get_plugin_lang('Positioning') }}</h3>
<div class="row">
<div class="col-md-4">
<h3>{{ "InviteToTakePositioningTest"| get_plugin_lang('Positioning') }}</h3>
<p>{{ "InitialTest"| get_plugin_lang('Positioning') }}: {{ initial_exercise }}</p>
</div>
<p>{{ "InitialTest"| get_plugin_lang('Positioning') }}: {{ initial_exercise }}</p>
<div class="col-md-4">
<h3>{{ "YouMustCompleteAThresholdToTakeFinalTest"| get_plugin_lang('Positioning') | format(average_percentage_to_unlock_final_exercise) }}</h3>
<p>{{ "Average"| get_lang }}: {{ average }} %</p>
<p>{{ lp_url }}</p>
</div>
<h3>{{ "YouMustCompleteAThresholdToTakeFinalTest"| get_plugin_lang('Positioning') | format(average_percentage_to_unlock_final_exercise) }}</h3>
<p>{{ "Average"| get_lang }}: {{ average }}</p>
<p>{{ "FinalTest"| get_plugin_lang('Positioning') }}: {{ final_exercise }}</p>
<div class="col-md-4">
<p>{{ "FinalTest"| get_plugin_lang('Positioning') }}: {{ final_exercise }}</p>
</div>
</div>
{{ radars }}

Loading…
Cancel
Save