add tpl overview exercises - ref BT#12684

pull/3063/head
Alex Aragon 9 years ago
parent 3374d45ed4
commit 4c6ce94f0a
  1. 5
      app/Resources/public/css/base.css
  2. 106
      main/exercise/overview.php
  3. 46
      main/template/rainbow/exercise/overview.tpl

@ -6055,6 +6055,11 @@ ul#toolnavbox-two li a.btn{
margin-right: 10px;
vertical-align: middle;
}
.exercise-btn{
padding-top: 10px;
padding-bottom: 10px;
margin-bottom: 10px;
}
/* CSS NEW TOP ******************************************************************************/
/* CSS Responsive */
@media (min-width: 1025px) and (max-width: 1200px) {

@ -56,7 +56,7 @@ if ($time_control) {
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
}
/*
if ($origin != 'learnpath') {
Display::display_header();
} else {
@ -66,36 +66,29 @@ if ($origin != 'learnpath') {
</style>
";
Display::display_reduced_header();
}
}*/
$tpl = new Template('Overview');
$list = array();
$html = '';
$message = '';
$html .= '<div class="exercise">';
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$edit_link = '';
if ($is_allowed_to_edit && $objExercise->sessionId == $sessionId) {
$edit_link = Display::url(
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL),
api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&exerciseId='.$objExercise->id
);
}
$iconExercise = Display::return_icon('test-quiz.png', null, array(), ICON_SIZE_MEDIUM);
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
$list['id'] = $objExercise->id;
$list['session_id'] = $objExercise->sessionId;
$list['edit'] = $isAllowedToEdit;
// Exercise name.
if (api_get_configuration_value('save_titles_as_html')) {
$html .= Display::div(
$objExercise->get_formated_title().PHP_EOL.$edit_link
);
$list['title'] = $objExercise->get_formated_title().PHP_EOL;
} else {
$html .= Display::page_header(
$iconExercise.PHP_EOL.$objExercise->selectTitle().PHP_EOL.$edit_link
);
$list['title'] = $objExercise->selectTitle().PHP_EOL;
}
//Exercise description
if (!empty($objExercise->description)) {
$html .= Display::div($objExercise->description, array('class'=>'exercise_description'));
$list['description'] = $objExercise->description;
}
$extra_params = '';
@ -103,35 +96,25 @@ if (isset($_GET['preview'])) {
$extra_params = '&preview=1';
}
$exercise_stat_info = $objExercise->get_stat_track_exercise_info(
$exerciseStatus = $objExercise->get_stat_track_exercise_info(
$learnpath_id,
$learnpath_item_id,
0
);
/*$attempt_list = null;
if (isset($exercise_stat_info['exe_id'])) {
$attempt_list = Event::getAllExerciseEventByExeId($exercise_stat_info['exe_id']);
}*/
//1. Check if this is a new attempt or a previous
$label = get_lang('StartTest');
if ($time_control && !empty($clock_expired_time) || isset($exercise_stat_info['exe_id'])) {
if ($time_control && !empty($clock_expired_time) || isset($exerciseStatus['exe_id'])) {
$label = get_lang('ContinueTest');
}
if (isset($exercise_stat_info['exe_id'])) {
$message = Display::return_message(get_lang('YouTriedToResolveThisExerciseEarlier'));
if (isset($exerciseStatus['exe_id'])) {
$msgStatus = get_lang('YouTriedToResolveThisExerciseEarlier');
}
// 2. Exercise button
// Notice we not add there the lp_item_view_id because is not already generated
$exercise_url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_item_view_id='.$learnpathItemViewId.$extra_params;
$exercise_url_button = Display::url(
$label,
$exercise_url,
array('class' => 'btn btn-success btn-large')
);
$list['url'] = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_item_view_id='.$learnpathItemViewId.$extra_params;
//3. Checking visibility of the exercise (overwrites the exercise button)
$visible_return = $objExercise->is_visible(
@ -147,7 +130,7 @@ if ($visible_return['value'] == false) {
$message = Display::return_message(get_lang('ThisItemIsInvisibleForStudentsButYouHaveAccessAsTeacher'), 'warning');
} else {
$message = $visible_return['message'];
$exercise_url_button = null;
//$exercise_url_button = null;
}
}
@ -163,7 +146,7 @@ $attempts = Event::getExerciseResultsByUser(
$counter = count($attempts);
$my_attempt_array = array();
$table_content = '';
$table_content = null;
/* Make a special case for IE, which doesn't seem to be able to handle the
* results popup -> send it to the full results page */
@ -183,7 +166,7 @@ if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANS
$blockShowAnswers = true;
}
}
$tableContent = null;
if (!empty($attempts)) {
$i = $counter;
foreach ($attempts as $attempt_result) {
@ -298,48 +281,23 @@ if (!empty($attempts)) {
$row++;
}
}
$table_content = $table->toHtml();
$tableContent = $table->toHtml();
}
if ($objExercise->selectAttempts()) {
$attempt_message = get_lang('Attempts').' '.$counter.' / '.$objExercise->selectAttempts();
if ($counter == $objExercise->selectAttempts()) {
$attempt_message = Display::return_message($attempt_message, 'error');
} else {
$attempt_message = Display::return_message($attempt_message, 'info');
}
if ($visible_return['value'] == true) {
$message .= $attempt_message;
}
if ($objExercise->selectAttempts() && $visible_return['value'] == true) {
$list['attempts'] = $objExercise->selectAttempts();
}
if ($time_control) {
$html .= $objExercise->return_time_left_div();
}
$html .= $message;
if (!empty($exercise_url_button)) {
$html .= Display::div(
Display::div(
$exercise_url_button,
array('class' => 'exercise_overview_options col-md-12')
),
array('class' => ' row')
);
$tpl->assign('time_control',$objExercise->return_time_left_div());
}
$html .= Display::tag(
'div',
$table_content,
['class' => 'table-responsive']
);
$html .= '</div>';
echo $html;
$tpl->assign('data',$list);
$tpl->assign('data', $list);
$tpl->assign('label', $label);
$tpl->assign('message', $message);
$tpl->assign('count', $counter);
$tpl->assign('status', $msgStatus);
$tpl->assign('table_result', $tableContent);
$layout = $tpl->get_template('exercise/overview.tpl');
$tpl->display($layout);
Display::display_footer();
$tpl->assign('content', $tpl->fetch($layout));
$tpl->display_one_col_template();

@ -1,4 +1,44 @@
<div>
{{ dump(data) }}
</div>
<div class="exercise">
{{ time_control }}
{% if status is not empty %}
<div class="alert alert-warning" role="alert">
{{ status }}
</div>
{% endif %}
{% if data.edit and data.session_id == api_get_session_id %}
<div class="pull-right">
<a class="btn btn-default" title="{{ "Edit"|get_lang }}" href="{{ _p.web_main }}exercise/admin.php?{{ _p.web_cid_query }}&id_session={{ _c.session_id }}&exerciseId={{ data.id }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
</div>
{% endif %}
<div class="page-header">
<h2>{{ "test-quiz.png" |img(32) }} {{ data.title }}</h2>
</div>
<div class="exercise_description">
{{ data.description }}
</div>
{% if count == data.attempts %}
<div class="alert alert-error" role="alert">
{{ "Attempts" |get_lang }} {{ count }} / {{ data.attempts }}
</div>
{% else %}
<div class="alert alert-info" role="alert">
{{ "Attempts" |get_lang }} {{ count }} / {{ data.attempts }}
</div>
{% endif %}
{% if data.url is not empty %}
<div class="exercise-btn text-center">
<a href="{{ data.url }}" class="btn btn-success btn-lg">
{{ label }}
</a>
</div>
{% endif %}
{% if table_result is not empty %}
<div class="table-responsive">
{{ table_result }}
</div>
{% endif %}
</div>

Loading…
Cancel
Save