Permetti di rivedere le risposte per ogni domanda

Questioni sulle funzionalità di frontend come teacher area, registro valutazioni, ecc? Scrivetele qui!
alfa24
FormaLms Master
Posts: 499
Joined: Fri Nov 24, 2017 8:45 am
Version: forma.lms 1.4.2

Re: Permetti di rivedere le risposte per ogni domanda

Post by alfa24 » 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:

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('&', '&amp;', $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('&', '&amp;', $object_test->back_url), $lang->def('_BACK'))
		.'</div>', 'content');
}
poi sostituisci

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&amp;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&amp;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');
		}
con:

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&amp;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');
	}
I'm Jasmines, the One. If you need, you can contact me.

alfa24
FormaLms Master
Posts: 499
Joined: Fri Nov 24, 2017 8:45 am
Version: forma.lms 1.4.2

Re: Permetti di rivedere le risposte per ogni domanda

Post by alfa24 » Mon Apr 30, 2018 7:06 am

Hai testato?
I'm Jasmines, the One. If you need, you can contact me.

danilo
FormaLms User
Posts: 65
Joined: Wed Feb 04, 2015 5:33 pm

Re: Permetti di rivedere le risposte per ogni domanda

Post by danilo » Thu May 03, 2018 12:05 pm

Ciao, ti aggiorno. Con la seguente impostazione ottengo:
Permetti di rivedere le risposte per ogni domanda
No Si Si, se il test è stato superato

Mostra le risposte corrette
No Si Si, se il test è stato superato
  • Compilo il test senza superarlo, poi vado su l'icona a forma di grafico che si trova nei materiali, in corrispondenza del test e vedo anche le risposte correte (che invece non dovrei vedere).
  • Se, invece, provo a rifare il test e clicco su "Visualizza risultato precedente", vedo la compilazione effettuata senza le risposte corrette (così e giusto).
Permetti di rivedere le risposte per ogni domanda
No Si Si, se il test è stato superato

Mostra le risposte corrette
No Si Si, se il test è stato superato

In questo modo si verifica solo il secondo punto dell'esempio precedente. Mentre andando sull'icona a forma di grafico vedo solo il punteggio, senza vedere la compilazione (potrebbe andare bene...)

alfa24
FormaLms Master
Posts: 499
Joined: Fri Nov 24, 2017 8:45 am
Version: forma.lms 1.4.2

Re: Permetti di rivedere le risposte per ogni domanda

Post by alfa24 » Fri May 04, 2018 10:42 am

Perché quella funzione sta da un'altra parte.
Riscrivi la funzione getCompilationTable in /appLms/modules/organization/orgresults.php come segue:

Code: Select all

function getCompilationTable($id_user, $id_test)
{
    require_once(_base_.'/lib/lib.table.php');
    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' );

    	$test_man       = new TestManagement($id_test);


    if(isset($_GET['back']) && $_GET['back'])
        $back = getBackUi( 'index.php?modname=course&amp;op=mycourses&amp;sop=unregistercourse' , Lang::t('_BACK', 'standard', 'framework') );
    else
        $back = getBackUi( 'index.php?modname=organization' , Lang::t('_BACK', 'standard', 'framework') );

    // Parch per link in reportcard
    if(isset($_GET['back']) && $_GET['back'] && $_GET['back'] == "gradebook" )
        $back = getBackUi( 'index.php?modname=gradebook&op=showgrade' , Lang::t('_BACK', 'standard', 'framework') );

    $query =    "SELECT *"
                ." FROM %lms_testtrack"
                ." WHERE idTest = ".(int)$id_test
                ." AND idUser = ".(int)$id_user;

    $result = sql_query($query);

    cout(   getTitleArea('')
            .'<div class="std_block">'
            .$back, 'content');

    if(sql_num_rows($result) > 0)
    {
      $track_info = sql_fetch_assoc($result);
      $play_man       = new PlayTestManagement($id_test, Docebo::user()->getIdst(), $track_info['idTrack'], $test_man);
      $test_info      = $test_man->getTestAllInfo();
      $score_status   = $play_man->getScoreStatus();

        if ($score_status == 'passed') $incomplete = FALSE;
        elseif ($score_status == 'valid') {


            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;






        cout(   '<b>'.Lang::t('_DATE', 'organization').':</b> '.Format::date($track_info['date_end_attempt'], 'datetime').'<br/>'
                .'<b>'.Lang::t('_SCORE', 'organization').':</b> '.($track_info['score'] == '' ? '0' : $track_info['score']).'<br/>', 'content');

        $query =    "SELECT date_attempt, score"
                    ." FROM %lms_testtrack_times"
                    ." WHERE idTrack = ".(int)$track_info['idTrack'];

        $result = sql_query($query);

        if(sql_num_rows($result) > 1)
        {
            cout('<div id="hystoric">', 'content');

            $tb = new Table(0, Lang::t('_HYSTORIC_TABLE', 'organization'), Lang::t('_HYSTORIC_TABLE', 'organization'));

            $tb_h = array(Lang::t('_DATE', 'organization'), Lang::t('_SCORE', 'organization'));
            $tb_s = array('align-center', 'align-center');

            $tb->setColsStyle($tb_s);
            $tb->addHead($tb_h);

            while($row = sql_fetch_assoc($result))
                $tb->addBody(array(Format::date($row['date_attempt'], 'datetime'), $row['score']));

            cout(   $tb->getTable()
                    .'</div>', 'content');
        }
        $query_passed = "SELECT status FROM %lms_commontrack WHERE idTrack = ".(int)$track_info['idTrack']." AND objectType = 'test' AND idUser = ".(int)$id_user;
        $result_passed = sql_query($query_passed);
        $test_passed = false;
        if(sql_num_rows($result_passed)>0)
            {
                list($test_status) = sql_fetch_row($result_passed);
                if ($test_status == "passed")
                    $test_passed = true;
            }
        if($test_info['show_doanswer'] == 1 || ($test_info['show_doanswer'] == 2 && $test_passed ))
        {
            cout('<br/><br/>', 'content');
            cout('<div align="center"><a href="index.php?modname=organization&op=printtest&idTrack='.$track_info['idTrack'].'">'.Lang::t('_PRINT_TEST','test').'</a></div>','content');
            cout('<br/><br/>', 'content');
            $re_visu_quest = sql_query("SELECT idQuest
            FROM %lms_testtrack_quest
            WHERE idTrack = '".(int)$track_info['idTrack']."' ");

            $quest_see = array();
            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 %lms_testquest AS q JOIN %lms_quest_type AS t
            WHERE q.idTest = '".$id_test."' 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";

            $reQuest = sql_query($query_question);

            cout('<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(_lms_.'/modules/question/'.$type_file);
                $quest_obj = eval("return new $type_class( $idQuest );");

                $review = $quest_obj->displayUserResult(    $track_info['idTrack'],
                                                            ($type_quest != 'title' ? $quest_sequence_number++ : $quest_sequence_number),
                                                            $show_solution );

                cout(   '<div class="test_quest_review_container">'
                        .$review['quest'], 'content');

                if($review['score'] !== false)
                {
                    cout(   '<div class="test_answer_comment">'
                            .'<div class="test_score_note">'.Lang::t('_SCORE', 'test').' : ', 'content');

                    if($quest_obj->getScoreSetType() == 'manual' && !$review['manual_assigned'] )
                        cout(Lang::t('_NOT_ASSIGNED', 'test'), 'content');
                    else
                    {
                        if($review['score'] > 0)
                            cout('<span class="test_score_positive">'.$review['score'].'</span>', 'content');
                        else
                            cout('<span class="test_score_negative">'.$review['score'].'</span>', 'content');
                    }

                    cout(   '</div>'
                            .( $review['comment'] != '' ? $review['comment'] : '' )
                            .'</div>', 'content');
                }

                cout('</div>', 'content');
            }

            cout('</div>', 'content');
            cout('<div align="center"><a href="index.php?modname=organization&op=printtest&idTrack='.$track_info['idTrack'].'">'.Lang::t('_PRINT_TEST','test').'</a></div>','content');
        }
    }
    else
        cout(Lang::t('_NO_TEST_STATS', 'organization'), 'content');

    cout(   $back
            .'</div>', 'content');
}
I'm Jasmines, the One. If you need, you can contact me.

danilo
FormaLms User
Posts: 65
Joined: Wed Feb 04, 2015 5:33 pm

Re: Permetti di rivedere le risposte per ogni domanda

Post by danilo » Fri May 11, 2018 1:37 pm

Grazie! Ora con questa combinazione funziona correttamente:
Permetti di rivedere le risposte per ogni domanda
No Si Si, se il test è stato superato

Mostra le risposte corrette
No Si Si, se il test è stato superato

Solo un piccolo appunto, ora compare questa scritta che prima non c'era:
Cattura2.PNG
Cattura2.PNG (11.14 KiB) Viewed 636 times

alfa24
FormaLms Master
Posts: 499
Joined: Fri Nov 24, 2017 8:45 am
Version: forma.lms 1.4.2

Re: Permetti di rivedere le risposte per ogni domanda

Post by alfa24 » Fri May 11, 2018 3:51 pm

c'era ma non veniva mostrata per via di un bug, corretto anche quello nella funzione che ti ho postato
ovviamente devi tradurre la chiave _PRINT_TEST nel modulo lingua
I'm Jasmines, the One. If you need, you can contact me.

danilo
FormaLms User
Posts: 65
Joined: Wed Feb 04, 2015 5:33 pm

Re: Permetti di rivedere le risposte per ogni domanda

Post by danilo » Fri May 11, 2018 4:45 pm

Grazie per il chiarimento.
Tuttavia la stampa non viene effettuata, cliccando, si torna ai Materiali.

alfa24
FormaLms Master
Posts: 499
Joined: Fri Nov 24, 2017 8:45 am
Version: forma.lms 1.4.2

Re: Permetti di rivedere le risposte per ogni domanda

Post by alfa24 » Sat May 12, 2018 9:39 am

Mea culpa. Quel print test punta a una funzione di stampa non presente in forma, l'ho aggiunta io nella mia versione. Togli pure il link.
I'm Jasmines, the One. If you need, you can contact me.

Post Reply