rating MDL-21657 updated version of ratings including forum and glossary integration
[moodle.git] / mod / workshop / loginas.php
1 <?php
3 /**
4  * Temporary script to log-in as a random workshop participant - useful for testing
5  */
7 require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
8 require_once(dirname(__FILE__).'/locallib.php');
10 $cmid       = required_param('cmid', PARAM_INT); // course_module ID, or
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);
16 require_login($course, true, $cm);
17 require_capability('moodle/user:loginas', get_context_instance(CONTEXT_COURSE, $course->id));
19 $workshop = new workshop($workshop, $cm, $course);
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);
26 redirect("{$CFG->wwwroot}/course/loginas.php?id={$course->id}&user={$randomid}&return=1&sesskey=" . sesskey());