Improve question list for teacher (#1982)

* Improve action from question list for teacher

* Improve question list for teacher

* Minor - Format code - codeeclimate
pull/2487/head
Angel Fernando Quiroz Campos 9 years ago committed by GitHub
parent d815efeaff
commit 1828b2c227
  1. 42
      app/Resources/public/css/base.css
  2. 234
      main/exercise/question_list_admin.inc.php

@ -1564,11 +1564,9 @@ div.admin_section h4 {
border: 1px dashed #B0B0B0
}
#question_list .header_operations {
height:30px;
margin-bottom:5px;
clear: both;
background: #F5F5F5;
font-size: 12px;
padding: 2px;
}
#question_list .header_operations:hover{
@ -1582,46 +1580,6 @@ div.admin_section h4 {
background: #D9EDF7;
border-color: #bce8f1;
}
#question_list .header_operations .table tbody tr td{
padding: 0;
border: none;
vertical-align: middle;
}
#question_list .header_operations .table .question{
width: 40%;
padding-left: 5px;
}
#question_list .header_operations .table .type{
width: 10%;
}
#question_list .header_operations .table .category{
width: 20%;
}
#question_list .header_operations .table .level{
width: 10%;
text-align: center;
}
#question_list .header_operations .table .score{
width: 10%;
text-align: center;
}
#question_list .header_operations .table .btn-actions{
width: 10%;
}
#question_list .edition{
padding-top: 3px;
text-align: center;
}
#question_list .edition .items{
padding:2px;
margin:0 3px 0 0;
border: 1px solid #CCC;
border-radius: 5px;
background: #FFF;
}
#question_list .edition .items img{
width: 16px;
}
#question_list .question-list-description-block .question_options .radio{
min-height: 0;
margin-left: 30px;

@ -30,25 +30,10 @@ if ($deleteQuestion) {
$ajax_url = api_get_path(WEB_AJAX_PATH)."exercise.ajax.php?".api_get_cidreq()
."&exercise_id=".intval($exerciseId);
?>
<style>
.ui-state-highlight {
height: 30px;
line-height: 1.2em;
}
/*Fixes edition buttons*/
.ui-accordion-icons .ui-accordion-header .edition a {
padding-left: 4px;
}
</style>
<div id="dialog-confirm"
title="<?php echo get_lang("ConfirmYourChoice"); ?>"
style="display:none;">
<p>
<span class="ui-icon ui-icon-alert"
style="float:left; margin:0 7px 20px 0; display:none;">
</span>
<?php echo get_lang("AreYouSureToDelete"); ?>
</p>
</div>
@ -94,7 +79,7 @@ $ajax_url = api_get_path(WEB_AJAX_PATH)."exercise.ajax.php?".api_get_cidreq()
/* We can add links in the accordion header */
$(".btn-actions .edition .items a").click(function () {
$(".btn-actions .edition a.btn").click(function () {
//Avoid the redirecto when selecting the delete button
if (this.id.indexOf('delete') == -1) {
newWind = window.open(this.href, "_self");
@ -164,7 +149,6 @@ Question:: display_type_menu($objExercise);
// Re sets the question list
$objExercise->setQuestionList();
echo '<div style="clear:both;"></div>';
echo '<div id="message"></div>';
$token = Security::get_token();
//deletes a session when using don't know question type (ugly fix)
@ -177,20 +161,18 @@ if (!$inATest) {
.get_lang("ChoiceQuestionType")
."</div>";
} else {
// Title line
echo "<div class='table-responsive'>";
echo "<table class='table table-condensed'>";
echo "<tr>";
echo "<th style=\"width: 40%;\">".get_lang('Questions')."</th>";
echo "<th style=\"width: 10%;\">".get_lang('Type')."</th>";
echo "<th style=\"width: 20%;\">".get_lang('Category')."</th>";
echo "<th style=\"width: 10%;\">".get_lang('Difficulty')."</th>";
echo "<th style=\"width: 10%;\">".get_lang('MaximumScore')."</th>";
echo "<th style=\"width: 10%;\">".get_lang('Actions')."</th>";
echo "</tr>";
echo "</table>";
echo "</div>";
echo '<div id="question_list">';
echo '
<div class="row hidden-xs">
<div class="col-sm-5"><strong>'.get_lang('Questions').'</strong></div>
<div class="col-sm-1"><strong>'.get_lang('Type').'</strong></div>
<div class="col-sm-2"><strong>'.get_lang('Category').'</strong></div>
<div class="col-sm-1"><strong>'.get_lang('Difficulty').'</strong></div>
<div class="col-sm-1"><strong>'.get_lang('MaximumScore').'</strong></div>
<div class="col-sm-2"><strong>'.get_lang('Actions').'</strong></div>
</div>
<div id="question_list">
';
if ($nbrQuestions) {
// Always getting list from DB
//$questionList = $objExercise->selectQuestionList(true);
@ -207,13 +189,6 @@ if (!$inATest) {
// Get question list
$questionList = $objExercise->selectQuestionList(true, true);
// Style for columns
$styleQuestion = "question";
$styleType = "type";
$styleCat = "category";
$styleLevel = "level";
$styleScore = "score";
$category_list = TestCategory::getListOfCategoriesNameForTest(
$objExercise->id,
false
@ -228,81 +203,82 @@ if (!$inATest) {
/** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($id);
$clone_link = '<a href="'.api_get_self().'?'.api_get_cidreq()
.'&clone_question='.$id.'">'
.Display::return_icon(
$clone_link = Display::url(
Display::return_icon(
'cd.png',
get_lang('Copy'),
array(),
ICON_SIZE_SMALL
)
.'</a>';
[],
ICON_SIZE_TINY
),
api_get_self().'?'.api_get_cidreq().'&clone_question='.$id,
['class' => 'btn btn-default btn-sm']
);
$edit_link = ($objQuestionTmp->type == CALCULATED_ANSWER && $objQuestionTmp->isAnswered())
? '<a>'
.Display::return_icon(
? Display::button(
'edit',
Display::return_icon(
'edit_na.png',
get_lang('QuestionEditionNotAvailableBecauseItIsAlreadyAnsweredHoweverYouCanCopyItAndModifyTheCopy'),
array(),
ICON_SIZE_SMALL
)
.'</a>'
: '<a href="'.api_get_self().'?'.api_get_cidreq().'&type='
.$objQuestionTmp->selectType().'&myid=1&editQuestion='.$id.'">'
.Display::return_icon(
[],
ICON_SIZE_TINY
),
['class' => 'btn btn-default btn-sm']
)
: Display::url(
Display::return_icon(
'edit.png',
get_lang('Modify'),
array(),
ICON_SIZE_SMALL
)
.'</a>';
[],
ICON_SIZE_TINY
),
api_get_self().'?'.api_get_cidreq().'&'
.http_build_query([
'type' => $objQuestionTmp->selectType(),
'myid' => 1,
'editQuestion' => $id
]),
['class' => 'btn btn-default btn-sm']
);
$delete_link = null;
if ($objExercise->edit_exercise_in_lp == true) {
$delete_link = '<a id="delete_'.$id.'" class="opener" href="'
.api_get_self().'?'.api_get_cidreq().'&exerciseId='
.$exerciseId.'&deleteQuestion='.$id.'" >'
.Display::return_icon(
$delete_link = Display::url(
Display::return_icon(
'delete.png',
get_lang('RemoveFromTest'),
array(),
ICON_SIZE_SMALL
)
.'</a>';
[],
ICON_SIZE_TINY
),
api_get_self().'?'.api_get_cidreq()
.http_build_query([
'exerciseId' => $exerciseId,
'deleteQuestion' => $id
]),
[
'id' => "delete_$id",
'class' => 'opener btn btn-default btn-sm'
]
);
}
$edit_link = Display::tag('span', $edit_link, array('class' => 'items'));
$clone_link = Display::tag('span', $clone_link, array('class' => 'items'));
$delete_link = Display::tag('span', $delete_link, array('class' => 'items'));
$btnActions = Display::tag('td', Display::tag(
'div',
$edit_link.$clone_link.$delete_link,
array('class' => 'edition')
), array('class' => 'btn-actions'));
$btnActions = implode(
PHP_EOL,
[$edit_link, $clone_link, $delete_link]
);
$title = Security::remove_XSS($objQuestionTmp->selectTitle());
$title = strip_tags($title);
$move = Display::returnFontAwesomeIcon("arrows moved", 'lg');
$move = Display::returnFontAwesomeIcon("arrows moved", 1, true);
// Question name
$questionName = Display::tag(
'td',
$questionName =
'<a href="#" title = "'.Security::remove_XSS($title).'">
'.$move.' '.cut($title, 42).'
</a>',
array('class' => $styleQuestion)
);
</a>';
// Question type
list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html();
$questionType = Display::tag(
'td',
Display::return_icon(
$typeImg,
$typeExpl,
array(),
ICON_SIZE_SMALL
),
array('class' => $styleType)
);
$questionType = Display::return_icon($typeImg, $typeExpl);
// Question category
$txtQuestionCat = Security::remove_XSS(
@ -311,56 +287,50 @@ if (!$inATest) {
if (empty($txtQuestionCat)) {
$txtQuestionCat = "-";
}
$questionCategory = Display::tag(
'td',
'<a href="#" style="padding:0px; margin:0px;" title="'
.$txtQuestionCat.'">'.cut($txtQuestionCat, 42).'</a>',
array('class' => $styleCat)
);
// Question level
$txtQuestionLevel = $objQuestionTmp->level;
if (empty($objQuestionTmp->level)) {
$txtQuestionLevel = '-';
}
$questionLevel = Display::tag(
'td',
$txtQuestionLevel,
array('class' => $styleLevel)
);
$questionLevel = $txtQuestionLevel;
// Question score
$questionScore = Display::tag(
'td',
$objQuestionTmp->selectWeighting(),
array('class' => $styleScore)
);
echo '<div id="question_id_list_'.$id.'" >';
echo '<div class="header_operations" data-exercise="'
.$objExercise->selectId().'" data-question="'.$id.'">';
echo "<div class='table-responsive'>";
echo "<table class='table'>";
echo "<tr>";
echo $questionName;
echo $questionType;
echo $questionCategory;
echo $questionLevel;
echo $questionScore;
echo $btnActions;
echo "</tr>";
echo "</table>";
echo "</div>";
echo '</div>';
echo Display::tag(
'div',
null,
[
'class' => 'question-list-description-block',
'id' => "pnl-question-$id"
]
);
echo '</div>';
$questionScore = $objQuestionTmp->selectWeighting();
echo '
<div id="question_id_list_'.$id.'">
<div class="header_operations" data-exercise="'.$objExercise->selectId().'"
data-question="'.$id.'">
<div class="row">
<div class="question col-sm-5 col-xs-12">'
.$questionName.'
</div>
<div class="type col-sm-1 col-xs-12">
<span class="visible-xs-inline">'.get_lang('Type').' </span>'
.$questionType.'
</div>
<div class="category col-sm-2 col-xs-12" title="'.$txtQuestionCat.'">
<span class="visible-xs-inline">'.get_lang('Category').' </span>'
.cut($txtQuestionCat, 42).'
</div>
<div class="level col-sm-1 col-xs-6">
<span class="visible-xs-inline">'.get_lang('Difficulty').' </span>'
.$questionLevel.'
</div>
<div class="score col-sm-1 col-xs-6">
<span class="visible-xs-inline">'.get_lang('Score').' </span>'
.$questionScore.'
</div>
<div class="btn-actions col-sm-2 col-xs-6">
<div class="edition">'.$btnActions.'</div>
</div>
</div>
</div>
<div class="question-list-description-block" id="pnl-question-'.$id.'">
</div>
</div>
';
unset($objQuestionTmp);
}
}

Loading…
Cancel
Save