Project

General

Profile

Bug #8077

getFillTheBlankTabResult() is not defined

Added by Torkil Zachariassen almost 4 years ago. Updated almost 4 years ago.

Status:
Bug resolved
Priority:
Normal
Category:
Exercises
Target version:
Start date:
11/02/2016
Due date:
% Done:

100%

Estimated time:
Complexity:
Normal
SCRUM pts - complexity:
?

Description

While calling "Report question" in the "Learner score" screen, like this

http://192.168.0.134/main/exercice/stats.php?cidReq=EITTFYRSTASKEID&id_session=0&gidReq=0&gradebook=0&origin=&exerciseId=1

we get a new screen with no content.

http response was: [HTTP/1.0 500 Internal Server Error 626ms]

Request headers were:
Host: 192.168.0.134
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fo,da;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://192.168.0.134/main/exercice/exercise_report.php?cidReq=EITTFYRSTASKEID&id_session=0&gidReq=0&gradebook=0&origin=&exerciseId=1
Cookie: ch_sid=dodnro5525q6st3d97jmsifuc4; defaultMyCourseView1=0
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

Response headers:
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection: close
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Thu, 11 Feb 2016 19:00:29 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Server: Apache/2.4.6 (CentOS) PHP/5.4.16
X-Powered-By: PHP/5.4.16

The error log says:

  1. [Thu Feb 11 18:50:15.369123 2016] [:error] [pid 30021] [client 192.168.0.102:53591] PHP Fatal error: Call to undefined function getFillTheBlankTabResult() in /var/www/chamilo-lms-1.10.2/main/inc/lib/exercise.lib.php on line 2910, referer: http://192.168.0.134/main/exercice/exercise_report.php?cidReq=EITTFYRSTASKEID&id_session=0&gidReq=0&gradebook=0&origin=&exerciseId=1

and after searching for "getFillTheBlankTabResult()" the only file mentioning this was indeed exercise_report.php.

Thus the function getFillTheBlankTabResult() seems to be missing somehow.


Files

FillBlanks.png (32.1 KB) FillBlanks.png Missing graphics and numbers in "Report by question" Torkil Zachariassen, 18/02/2016 14:48

Related issues

Related to Chamilo LMS - Feature #7598: [1.9.10.x] Add feature menu and several choice for Fill the blank question - for 1.9.10.xFeature implemented07/04/2015

Actions
Related to Repository - Bug #718: repository breadcrumbsFeature implemented12/03/2010

Actions

Associated revisions

Revision 2954d4db (diff)
Added by José Loguercio almost 4 years ago

Fix getFillTheBlankTabResult() and getNbResultFillBlankAll() is not defined - Refs #8077

Revision 7004bc14 (diff)
Added by José Loguercio almost 4 years ago

Fix all Stats report for fill Blanks - Refs #8077

Revision 8156dea0
Added by Yannick Warnier almost 4 years ago

Merge pull request #1020 from jloguercio/8077

Fix getFillTheBlankTabResult() and getNbResultFillBlankAll() is not defined - Refs #8077

History

#1

Updated by Torkil Zachariassen almost 4 years ago

This might help resolving the issue:

In https://github.com/chamilo/chamilo-lms/pull/718
baelmyhu indicates the following functions to be appended to main/exercice/exercise.lib.php

There are some errors in the code:

  • TABLE_STATISTIC_TRACK_E_EXERCICES should be TABLE_STATISTIC_TRACK_E_EXERCISES
  • the field 'exe_cours_id' does not exist
  • course_code is empty in the table track_e_attempt
/**
 * Return an array of student state answers for fill the blank questions
 * for each students that answered the question
 * -2  : didn't answer
 * -1  : student answer is wrong
 *  0  : student answer is correct
 * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
 *
 * @param $testId
 * @param $questionId
 * @param $studentsIdList
 * @param $startDate
 * @param $endDate
 * @param bool $useLastAnswerredAttempt
 * @return array
 * (
 *     [student_id] => Array
 *         (
 *             [first fill the blank for question] => -1
 *             [second fill the blank for question] => 2
 *             [third fill the blank for question] => -1
 *         )
 * )
 */
function getFillTheBlankTabResult($testId, $questionId, $studentsIdList, $startDate, $endDate, $useLastAnswerredAttempt = true) {

    $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
    $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
    $tblCQuizAnswer = Database::get_course_table(TABLE_QUIZ_ANSWER);
    $courseCode = api_get_course_id();

    require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php';

    // request to have all the answers of student for this question
    // student may have doing it several time
    // student may have not answered the bracket id, in this case, is result of the answer is empty

    // we got the less recent attempt first
    $sql = '
        SELECT * FROM '.$tblTrackEAttempt.' tea

        LEFT JOIN '.$tblTrackEExercise.' tee
        ON tee.exe_id = tea.exe_id
        AND exe_cours_id = "'.$courseCode.'" 
        AND exe_exo_id = '.$testId.'

        WHERE course_code = "'.$courseCode.'" 
        AND question_id = '.$questionId.'
        AND tea.user_id IN ('.implode(',', $studentsIdList).')
        AND tea.tms >= "'.$startDate.'" 
        AND tea.tms <= "'.$endDate.'" 
        ORDER BY user_id, tea.exe_id;
    ';

    $res = Database::query($sql);
    $tabUserResult = array();
    $bracketNumber = 0;
    // foreach attempts for all students starting with his older attempt
    while ($data = Database::fetch_array($res)) {
        $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);

        // for each bracket to find in this question
        foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {

            if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
                // student has answered this bracket, cool
                switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
                    case FILL_THE_BLANK_MENU :
                        // get the indice of the choosen answer in the menu
                        // we know that the right answer is the first entry of the menu, ie 0
                        // (remember, menu entries are shuffled when taking the test)
                        $tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum($tabAnswer['tabwords'][$bracketNumber], $tabAnswer['studentanswer'][$bracketNumber]);
                        break;
                    default :
                        if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) {
                            $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
                        } else {
                            $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
                        }
                }
            } else {
                // student didn't answer this bracket
                if ($useLastAnswerredAttempt) {
                    // if we take into account the last answered attempt
                    if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
                        $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
                    }
                } else {
                    // we take the last attempt, even if the student answer the question before
                    $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
                }
            }
        }

    }
    return $tabUserResult;
}

/**
 * Return the number of student that give at leat an answer in the fill the blank test
 * @param $resultList
 * @return int
 */
function getNbResultFillBlankAll($resultList)
{
    $outRes = 0;
    // for each student in group
    foreach($resultList as $userId => $tabValue) {
        $trouve = false;
        // for each bracket, if student has at leat one answer ( choice > -2) then he pass the question
        foreach($tabValue as $i => $choice) {
            if ($choice > -2 && !$trouve) {
                $outRes++;
                $trouve = true;
            }
        }
    }
    return $outRes;
}
#2

Updated by José Loguercio almost 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Yannick Warnier
  • % Done changed from 0 to 90

This PR contains the solution to this issue with some modifications to works in 1.10.x :

https://github.com/chamilo/chamilo-lms/pull/1020

Thank You

#3

Updated by Torkil Zachariassen almost 4 years ago

Tested on 1.10.2, replacing exercise.lib.php and fill_blanks.class.php with the ones in the PR.
The original error is now gone, which is nice.

Still we have other issues as graphics and numbers are missing in the report as shown in the screendump.

One reason might be the SQL, which returns an empty set:

SELECT * FROM track_e_attempt tea

  LEFT JOIN track_e_exercises tee
  ON tee.exe_id = tea.exe_id
  AND tea.c_id = "EITTFYRSTASKEID" /* This is problematic as c_id is int(11) */
  AND exe_exo_id = 3

  WHERE course_code = "EITTFYRSTASKEID" /* This is problematic as course_code is empty in the track_e_attempt */
  AND question_id = 3
  AND tea.user_id IN (4302)
  AND tea.tms >= "1970-01-01" 
  AND tea.tms <= "3000-01-01" 
  ORDER BY user_id, tea.exe_id;

course_code may not have be written properly int track_e_attempt, as all it contains by now are 34 empty values.
track_e_attempt currently contains 34 records.
track_e_exercises currently contains 8 records.

#4

Updated by José Loguercio almost 4 years ago

Yep ! , you right, i updated the same PR to correctly works with Fill Blanks

Thank You

#5

Updated by José Loguercio almost 4 years ago

José Loguercio wrote:

Yep ! , you right, i updated the same PR to correctly works with Fill Blanks

Thank You

EDIT : for the "correct" column, in fill the blanks this field it remains in "-" because all the shown answers are correct, only the report shows the count.

#6

Updated by José Loguercio almost 4 years ago

  • Status changed from Assigned to Needs testing
#7

Updated by Yannick Warnier almost 4 years ago

  • Category set to Exercises
  • Status changed from Needs testing to Bug resolved
  • Assignee changed from Yannick Warnier to José Loguercio
  • % Done changed from 90 to 100

This error has been fixed. Thanks to the both of you.

Also available in: Atom PDF