Comments (3)
I managed somehow to fix it. Here's the changes on locallib.php.
public static function has_role($rids, $courseid, $uid) { global $DB; $params = array(); //foreach ($rids as $role) { // array_push($params, (int)$role); //} array_push($params, $rids, $courseid, (int)$uid); $roles = join(',', array_fill(0, count($rids), '?')); $r = $DB->count_records_sql("SELECT COUNT(id) FROM {role_assignments} WHERE roleid IN($roles) AND contextid=? AND userid=?", $params); if ($r > 0) { return true; } else { return false; } }
from moodle-block_studentstracker.
Thanks for the report. This error has been fixed for a while (1.6 and 1.7 versions are ok).
from moodle-block_studentstracker.
Hi @Hipjea ,
Sorry to resurrect this thread again but I do appreciate your advise what could be wrong with my current situation...
I'm using version 1.7 and I have got a strange error below for the specific course only. The rest of the course were fine.
Warning: Invalid argument supplied for foreach() in /documentroot/blocks/studentstracker/locallib.php on line 237
Warning: count(): Parameter must be an array or an object that implements Countable in /documentroot/blocks/studentstracker/locallib.php on line 241
Error
ERROR: Incorrect number of query parameters. Expected 3, got 2.
Debug info:
Error code: invalidqueryparam
Stack trace:
line 945 of /lib/dml/moodle_database.php: dml_exception thrown
line 1268 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->fix_sql_params()
line 1671 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
line 1744 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
line 1954 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
line 243 of /blocks/studentstracker/locallib.php: call to moodle_database->count_records_sql()
line 168 of /blocks/studentstracker/locallib.php: call to studentstracker::has_role()
line 120 of /blocks/studentstracker/block_studentstracker.php: call to studentstracker->get_enrolled_users()
line 341 of /blocks/moodleblock.class.php: call to block_studentstracker->get_content()
line 235 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
line 1181 of /lib/blocklib.php: call to block_base->get_content_for_output()
line 1239 of /lib/blocklib.php: call to block_manager->create_block_contents()
line 374 of /lib/blocklib.php: call to block_manager->ensure_content_created()
line 3950 of /lib/outputrenderers.php: call to block_manager->region_has_content()
line 40 of /theme/boost/layout/columns2.php: call to core_renderer->blocks()
line 1374 of /lib/outputrenderers.php: call to include()
line 1304 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
line 253 of /course/view.php: call to core_renderer->header()
So I tried to print the value of variable $roles
at line 241 at file locallib.php
by adding the code below, it returns with roles = ?
.
$roles = join(',', array_fill(0, count($roleids), '?'));
print_object("roles = " . print_r($roles, true));
$r = $DB->count_records_sql("SELECT COUNT(id) FROM {role_assignments} WHERE roleid IN($roles) AND contextid=? AND userid=?",
$params);
Any advise is deeply appreciated.
Thanks!
from moodle-block_studentstracker.
Related Issues (10)
- Tracking only 1 group HOT 1
- Proposed modifications from a teacher HOT 1
- Version 1.7.0 (2021022601) layout problems HOT 12
- Can not translate some language strings HOT 12
- [New] - ERROR: Incorrect number of query parameters. Expected 3, got 2 HOT 2
- Groups to track not working HOT 1
- Can not update latest version (09 Nov) via web HOT 7
- Minor typos in English language strings HOT 3
- No need to include foreign language strings inside the ZIP file HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moodle-block_studentstracker.