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. 232
      main/exercise/question_list_admin.inc.php

@ -1564,11 +1564,9 @@ div.admin_section h4 {
border: 1px dashed #B0B0B0 border: 1px dashed #B0B0B0
} }
#question_list .header_operations { #question_list .header_operations {
height:30px;
margin-bottom:5px; margin-bottom:5px;
clear: both; clear: both;
background: #F5F5F5; background: #F5F5F5;
font-size: 12px;
padding: 2px; padding: 2px;
} }
#question_list .header_operations:hover{ #question_list .header_operations:hover{
@ -1582,46 +1580,6 @@ div.admin_section h4 {
background: #D9EDF7; background: #D9EDF7;
border-color: #bce8f1; 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{ #question_list .question-list-description-block .question_options .radio{
min-height: 0; min-height: 0;
margin-left: 30px; margin-left: 30px;

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

Loading…
Cancel
Save