Test feedback not behaving as expected

Anything about what happens on the user and teacher side
Post Reply
jamesd
Newbie
Posts: 20
Joined: Thu Sep 10, 2020 2:18 pm

Test feedback not behaving as expected

Post by jamesd »

Hi, this is the last thing that i'm confused about right now hopefully the community have seen it before or can help?

On a test I can configure Feedback in Feedback management.

We've set up messages for the following scores: 0-30, 31-49 and 50-100 and the test is set to express the score as a percentage.

When someone finishes the test they are shown the appropriate message but for some reason they are also always shown the message for 0-30 as well (see second attachment).

Any ideas anyone?
Attachments
Screenshot 2020-09-15 at 13.55.13.png
Screenshot 2020-09-15 at 14.00.16.png
alfa24
Senior Boarder
Posts: 1979
Joined: Fri Nov 24, 2017 8:45 am

Re: Test feedback not behaving as expected

Post by alfa24 »

In /appLms/lib/lib.assessment_rule.php

find:

Code: Select all

function  __construct($test_id) {
		$this->test_id =(int)$test_id;
		$this->db =DbConn::getInstance();
	}
replace with:

Code: Select all

function  __construct($test_id) {
		$this->test_id =(int)$test_id;
		require_once(_lms_.'/lib/lib.test.php' );
		$test_man       = new TestManagement($this->test_id);
		$this->test_info = $test_man->getTestAllInfo();
		$this->db =DbConn::getInstance();
	}
find:

Code: Select all

public function setRulesFromScore($score_arr) {
		require_once(_base_.'/lib/lib.json.php');
		require_once(_lms_.'/lib/lib.subscribe.php');

		$res =true;

		$where_score_arr =array();
		foreach($score_arr as $val) {
			$where_score_arr[]="(category_id = '".(int)$val['category_id']."' ".
				"AND from_score <= '".(int)$val['score']."' AND to_score >= '".(int)$val['score']."')";
		}
replace with:

Code: Select all

public function setRulesFromScore($score_arr) {
		require_once(_base_.'/lib/lib.json.php');
		require_once(_lms_.'/lib/lib.subscribe.php');

		$res =true;

		$where_score_arr =array();
		$where_score_arr[]="(category_id = '".(int)$score_arr[$this->test_info['point_type']]['category_id']."' ".
					"AND from_score <= '".(int)$score_arr[$this->test_info['point_type']]['score']."' AND to_score >= '".(int)$score_arr[$this->test_info['point_type']]['score']."')";
Per supporto GRATUITO contattatemi in privato qui
jamesd
Newbie
Posts: 20
Joined: Thu Sep 10, 2020 2:18 pm

Re: Test feedback not behaving as expected

Post by jamesd »

Yay! That worked perfectly. Thank you.
g.nucifora
Newbie
Posts: 3
Joined: Fri Dec 17, 2021 3:49 pm

Re: Test feedback not behaving as expected

Post by g.nucifora »

Hi everyone,
the applied fix is actually not correct becasue it does not take the calculation rules related to the categories.
If you have 3 categories for questions "$score_arr" has this values :

Code: Select all

array (
  0 => 
  array (
    'score' => 100.0,
    'category_id' => 0,
  ),
   1 => 
  array (
    'score' => 100.0,
    'category_id' => 1,
  ),
   2 => 
  array (
    'score' => 100.0,
    'category_id' => 3,
  ),
   3 => 
  array (
    'score' => 100.0,
    'category_id' => 5,
  ),
)
and you take $score_arr[$test_info['point_type']] to calculate the where clausule the result is not correct because possible values for $test_info['point_type'] are only 0 and 1.

The problem is upstream of that function and precisely in the file with path

Code: Select all

'appLms/modules/test/do.test.php
' in particular before the function 'setRulesFromScore' is called on line 1276 approximately.

find :

Code: Select all

    foreach ($point_do_cat as $cat_id => $score) {
        $score_arr[$i]['score'] = $score;
        $score_arr[$i]['category_id'] = $cat_id;
        ++$i;
    }
    // final score:
    $score_arr[$i]['score'] = $point_do;
    $score_arr[$i]['category_id'] = 0;

and replace with :

Code: Select all

if ($test_info['point_type'] == '1') {
        $score_arr[$i]['score'] = $point_do;
        $score_arr[$i]['category_id'] = 0;
    } else {
        foreach ($point_do_cat as $cat_id => $score) {
            $score_arr[$i]['score'] = $score;
            $score_arr[$i]['category_id'] = $cat_id;
            ++$i;
        }
    }
This allow to use and calculate feedback based on question category values if point_type is numerical and in perc if point_type is in percentage.
Post Reply