mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-82349 course: fix guest access to course
This commit is contained in:
parent
cccacbdc04
commit
0d04567882
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -13,6 +13,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import Config from 'core/config';
|
||||
import {getString} from 'core/str';
|
||||
import {Reactive} from 'core/reactive';
|
||||
import notification from 'core/notification';
|
||||
@ -218,6 +219,16 @@ export default class extends Reactive {
|
||||
* @returns {Object} the current course state
|
||||
*/
|
||||
async getServerCourseState() {
|
||||
// Only logged users can get the course state. Filtering here will prevent unnecessary
|
||||
// calls to the server and login page redirects. Especially for home activities with
|
||||
// guest access.
|
||||
if (Config.userId == 0) {
|
||||
return {
|
||||
course: {},
|
||||
section: [],
|
||||
cm: [],
|
||||
};
|
||||
}
|
||||
const courseState = await ajax.call([{
|
||||
methodname: 'core_courseformat_get_state',
|
||||
args: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user