Re: Permetti di rivedere le risposte per ogni domanda
Posted: Mon Apr 23, 2018 11:03 am
Ok, allora annulla quanto scritto per i file class.xxx.php
ti basta modificare il file do.test.php, in particolare riscrivi così la funzione review:
poi sostituisci
con:
ti basta modificare il file do.test.php, in particolare riscrivi così la funzione review:
Code: Select all
function review($object_test, $id_param) {
$lang = DoceboLanguage::createInstance('test');
require_once($GLOBALS['where_lms'].'/lib/lib.param.php' );
require_once($GLOBALS['where_lms'].'/class.module/track.test.php');
require_once($GLOBALS['where_lms'].'/lib/lib.test.php' );
$idTest = $object_test->getId();
$idTrack = importVar('idTrack', true, 0);
$idReference = getLOParam( $id_param, 'idReference' );
$test_man = new TestManagement($idTest);
$play_man = new PlayTestManagement($idTest, Docebo::user()->getIdst(), $idTrack, $test_man);
$test_info = $test_man->getTestAllInfo();
$score_status = $play_man->getScoreStatus();
if ($score_status == 'passed') $incomplete = FALSE;
elseif ($score_status == 'valid') {
$track_info = $play_man->getTrackAllInfo();
if ($track_info['score'] >= $test_info['point_required'])
$incomplete = FALSE;
else
$incomplete = TRUE;
} else {
$incomplete = TRUE;
}
$show_solution = false;
if( $test_info['show_solution'] == 1 )
$show_solution = true;
elseif($test_info['show_solution'] == 2 && !$incomplete )
$show_solution = true;
if($test_info['order_type'] >= 2) {
$re_visu_quest = sql_query("SELECT idQuest
FROM ".$GLOBALS['prefix_lms']."_testtrack_quest
WHERE idTrack = '".(int)$idTrack."' ");
while(list($id_q) = sql_fetch_row($re_visu_quest)) $quest_see[] = $id_q;
$query_question = "
SELECT q.idQuest, q.type_quest, t.type_file, t.type_class
FROM ".$GLOBALS['prefix_lms']."_testquest AS q JOIN ".$GLOBALS['prefix_lms']."_quest_type AS t
WHERE q.idTest = '".$idTest."' AND q.type_quest = t.type_quest AND q.idQuest IN (".implode($quest_see, ',').")
AND q.type_quest <> 'break_page' AND q.type_quest <> 'title'
ORDER BY q.sequence";
} else {
$query_question = "
SELECT q.idQuest, q.type_quest, t.type_file, t.type_class
FROM ".$GLOBALS['prefix_lms']."_testquest AS q JOIN ".$GLOBALS['prefix_lms']."_quest_type AS t
WHERE q.idTest = '".$idTest."' AND q.type_quest = t.type_quest
AND q.type_quest <> 'break_page'
ORDER BY q.sequence";
}
$reQuest = sql_query($query_question);
//display-----------------------------------------------------------
$GLOBALS['page']->add('<div class="std_block">'
.'<div class="test_title_play">'.$lang->def('_TITLE').' : '.$test_info['title'].'</div>'
.getBackUi(Util::str_replace_once('&', '&', $object_test->back_url), $lang->def('_BACK'))
.'<br />', 'content');
//page display---------------------------------------------------
$GLOBALS['page']->add('<div class="test_answer_space">', 'content');
$quest_sequence_number = 1;
while(list($idQuest, $type_quest, $type_file, $type_class) = sql_fetch_row($reQuest)) {
require_once($GLOBALS['where_lms'].'/modules/question/'.$type_file);
$quest_obj = eval("return new $type_class( $idQuest );");
$review = $quest_obj->displayUserResult( $idTrack,
( $type_quest != 'title' ? $quest_sequence_number++ : $quest_sequence_number ),
$show_solution );
$GLOBALS['page']->add('<div class="test_quest_review_container">'
.$review['quest'], 'content');
if($review['score'] !== false) {
$GLOBALS['page']->add(
'<div class="test_answer_comment">'
.'<div class="test_score_note">'.$lang->def('_SCORE').' : ', 'content');
if($quest_obj->getScoreSetType() == 'manual' && !$review['manual_assigned'] ) {
$GLOBALS['page']->add($lang->def('_NOT_ASSIGNED'), 'content');
} else {
if($review['score'] > 0) {
$GLOBALS['page']->add('<span class="test_score_positive">'.$review['score'].'</span>', 'content');
} else {
$GLOBALS['page']->add('<span class="test_score_negative">'.$review['score'].'</span>', 'content');
}
}
$GLOBALS['page']->add(
'</div>'
.( $review['comment'] != '' ? $review['comment'] : '' )
.'</div>', 'content');
}
$GLOBALS['page']->add(
'</div>', 'content');
}
$GLOBALS['page']->add('</div>', 'content');
$GLOBALS['page']->add(getBackUi(Util::str_replace_once('&', '&', $object_test->back_url), $lang->def('_BACK'))
.'</div>', 'content');
}
Code: Select all
elseif($test_info['show_doanswer'] == 2 && $points >= $test_info['point_required'])
{
$GLOBALS['page']->add(Form::openForm('test_show', 'index.php?modname=test&op=play')
.Form::getHidden('next_step', 'next_step', 'test_review')
.Form::getHidden('id_test', 'id_test', $id_test)
.Form::getHidden('id_param', 'id_param', $id_param)
.Form::getHidden('back_url', 'back_url', $url_coded)
.Form::getHidden('idTrack', 'idTrack', $id_track)
.Form::getButton('review', 'review', $lang->def('_TEST_REVIEW_ANSWER'))
.Form::closeForm(), 'content');
}
elseif($test_info['show_solution'] != 2 && $test_info['show_doanswer'] != 2)
if($test_info['show_solution'] || $test_info['show_doanswer'])
{
$GLOBALS['page']->add(Form::openForm('test_show', 'index.php?modname=test&op=play')
.Form::getHidden('next_step', 'next_step', 'test_review')
.Form::getHidden('id_test', 'id_test', $id_test)
.Form::getHidden('id_param', 'id_param', $id_param)
.Form::getHidden('back_url', 'back_url', $url_coded)
.Form::getHidden('idTrack', 'idTrack', $id_track)
.Form::getButton('review', 'review', $lang->def('_TEST_REVIEW_ANSWER'))
.Form::closeForm(), 'content');
}
Code: Select all
elseif(($test_info['show_doanswer'] == 2 && $points >= $test_info['point_required'])||$test_info['show_solution'] || $test_info['show_doanswer'])
{
$GLOBALS['page']->add(Form::openForm('test_show', 'index.php?modname=test&op=play')
.Form::getHidden('next_step', 'next_step', 'test_review')
.Form::getHidden('id_test', 'id_test', $id_test)
.Form::getHidden('id_param', 'id_param', $id_param)
.Form::getHidden('back_url', 'back_url', $url_coded)
.Form::getHidden('idTrack', 'idTrack', $id_track)
.Form::getButton('review', 'review', $lang->def('_TEST_REVIEW_ANSWER'))
.Form::closeForm(), 'content');
}