Fix a possible race condition in the PaintWeb DML code.
[moodle/mihaisucan.git] / admin / report / question / index.php
blobd327900606cb7312f570343e921dfbe581b2e41b
1 <?php // $Id$
3 require_once('../../../config.php');
4 require_once($CFG->dirroot.'/question/upgrade.php');
5 require_once($CFG->libdir.'/adminlib.php');
7 admin_externalpage_setup('reportquestion');
8 admin_externalpage_print_header();
10 print_heading(get_string('adminreport', 'question'));
12 $probstr = '';
13 $contextupgradeversion = 2007081000;
14 if ($CFG->version < $contextupgradeversion){
15 ///cwrqpfs issue
16 $probstr = print_heading(get_string('cwrqpfs', 'question'), '', 3, 'main', true);
18 if ($updates = question_cwqpfs_to_update()){
20 $probstr .=get_string('cwrqpfsinfo', 'question');
21 $probstr .= '<ul>';
22 $catlist = join(array_keys($updates), ',');
23 //get info about cateogries and no of questions used outside category's course
24 $categories = get_records_sql('SELECT qc.*, c.fullname as coursename FROM '.$CFG->prefix.'question_categories as qc, '
25 .$CFG->prefix.'course as c WHERE qc.course = c.id AND qc.id IN ('.$catlist.')');
26 foreach ($updates as $id => $publish){
27 $categories[$id]->caturl = "$CFG->wwwroot/question/category.php?sesskey=".sesskey().
28 "&amp;edit=$id&amp;courseid=".$categories[$id]->course;
29 if ($categories[$id]->publish){
30 $categories[$id]->changefrom = get_string('published', 'question');
31 $categories[$id]->changeto = get_string('unpublished', 'question');
32 } else {
33 $categories[$id]->changefrom = get_string('unpublished', 'question');
34 $categories[$id]->changeto = get_string('published', 'question');
36 $probstr .= '<li>'.get_string('changepublishstatuscat', 'question', $categories[$id]);
37 if ($questions = get_records_sql('SELECT q.*, qui.id as quizid, qui.name as quizname, cm.id as cmid, '
38 .'qui.course, c.fullname as coursename FROM '.$CFG->prefix.'question q, '
39 .$CFG->prefix.'quiz_question_instances qqi, '
40 .$CFG->prefix.'quiz qui, '
41 .$CFG->prefix.'course_modules cm, '
42 .$CFG->prefix.'modules m, '
43 .$CFG->prefix.'course c '
44 .'WHERE (q.category = '.$id.' AND qqi.question = q.id '
45 .'AND qqi.quiz = qui.id '
46 .'AND qui.course = c.id '
47 .'AND cm.instance = qui.id '
48 .'AND cm.module = m.id '
49 .'AND m.name = \'quiz\''
50 .'AND ('.$categories[$id]->course.' <> qui.course)) ORDER BY qui.id ASC')){
52 $probstr .= '<ul>';
53 foreach ($questions as $question){
54 $question->quizurl = "$CFG->wwwroot/mod/quiz/edit.php?cmid=".$question->cmid;
55 $question->qurl = "$CFG->wwwroot/question/question.php?cmid={$question->cmid}&amp;id={$question->id}&amp;returnurl=".urlencode($FULLME);
56 $probstr .= '<li>'.get_string('questionaffected', 'question', $question).'</li>';
58 $probstr .= '</ul>';
60 $probstr .= '</li>';
62 $probstr .= '</ul>';
63 } else {
64 $probstr .=('<p>'.get_string('cwrqpfsnoprob', 'question').'</p>');
67 if ($probstr) {
68 print_box($probstr);
69 } else {
70 print_box(get_string('noprobs', 'question'), 'boxwidthnarrow boxaligncenter generalbox');
72 admin_externalpage_print_footer();