rating MDL-21657 updated version of ratings including forum and glossary integration
[moodle.git] / mod / workshop / loginas.php
CommitLineData
04f24757
DM
1<?php
2
3/**
4 * Temporary script to log-in as a random workshop participant - useful for testing
5 */
6
7require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
8require_once(dirname(__FILE__).'/locallib.php');
9
10$cmid = required_param('cmid', PARAM_INT); // course_module ID, or
11
12$cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
13$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
14$workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
15
16require_login($course, true, $cm);
17require_capability('moodle/user:loginas', get_context_instance(CONTEXT_COURSE, $course->id));
18
19$workshop = new workshop($workshop, $cm, $course);
20
21$authors = $workshop->get_potential_authors(false);
22$reviewers = $workshop->get_potential_reviewers(false);
23$participants = array_intersect_key($authors, $reviewers);
24$randomid = array_rand($participants);
25
26redirect("{$CFG->wwwroot}/course/loginas.php?id={$course->id}&user={$randomid}&return=1&sesskey=" . sesskey());