Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 75... Línea 75...
75
 
75
 
76
        $this->assertEquals($expectedsql, $sql);
76
        $this->assertEquals($expectedsql, $sql);
77
        $this->assertEquals($expectedparams, $params);
77
        $this->assertEquals($expectedparams, $params);
Línea 78... Línea 78...
78
    }
78
    }
79
 
79
 
80
    public function test_qubaid_list_one_join() {
80
    public function test_qubaid_list_one_join(): void {
81
        $qubaids = new qubaid_list(array(1));
81
        $qubaids = new qubaid_list(array(1));
82
        $this->check_typical_question_attempts_query($qubaids,
82
        $this->check_typical_question_attempts_query($qubaids,
83
                "SELECT qa.id, qa.maxmark
83
                "SELECT qa.id, qa.maxmark
84
            FROM {question_attempts} qa
84
            FROM {question_attempts} qa
85
            WHERE qa.questionusageid = :qubaid1 AND qa.slot = :slot",
85
            WHERE qa.questionusageid = :qubaid1 AND qa.slot = :slot",
Línea 86... Línea 86...
86
            array('qubaid1' => 1, 'slot' => 1));
86
            array('qubaid1' => 1, 'slot' => 1));
87
    }
87
    }
88
 
88
 
89
    public function test_qubaid_list_several_join() {
89
    public function test_qubaid_list_several_join(): void {
90
        $qubaids = new qubaid_list(array(1, 3, 7));
90
        $qubaids = new qubaid_list(array(1, 3, 7));
91
        $this->check_typical_question_attempts_query($qubaids,
91
        $this->check_typical_question_attempts_query($qubaids,
92
                "SELECT qa.id, qa.maxmark
92
                "SELECT qa.id, qa.maxmark
93
            FROM {question_attempts} qa
93
            FROM {question_attempts} qa
Línea 94... Línea 94...
94
            WHERE qa.questionusageid IN (:qubaid2,:qubaid3,:qubaid4) AND qa.slot = :slot",
94
            WHERE qa.questionusageid IN (:qubaid2,:qubaid3,:qubaid4) AND qa.slot = :slot",
95
            array('qubaid2' => 1, 'qubaid3' => 3, 'qubaid4' => 7, 'slot' => 1));
95
            array('qubaid2' => 1, 'qubaid3' => 3, 'qubaid4' => 7, 'slot' => 1));
Línea 96... Línea 96...
96
    }
96
    }
97
 
97
 
98
    public function test_qubaid_join() {
98
    public function test_qubaid_join(): void {
99
        $qubaids = new qubaid_join("{other_table} ot", 'ot.usageid', 'ot.id = 1');
99
        $qubaids = new qubaid_join("{other_table} ot", 'ot.usageid', 'ot.id = 1');
100
 
100
 
101
        $this->check_typical_question_attempts_query($qubaids,
101
        $this->check_typical_question_attempts_query($qubaids,
Línea 102... Línea 102...
102
                "SELECT qa.id, qa.maxmark
102
                "SELECT qa.id, qa.maxmark
103
            FROM {other_table} ot
103
            FROM {other_table} ot
Línea 104... Línea 104...
104
                JOIN {question_attempts} qa ON qa.questionusageid = ot.usageid
104
                JOIN {question_attempts} qa ON qa.questionusageid = ot.usageid
105
            WHERE ot.id = 1 AND qa.slot = :slot", array('slot' => 1));
105
            WHERE ot.id = 1 AND qa.slot = :slot", array('slot' => 1));
106
    }
106
    }
107
 
107
 
108
    public function test_qubaid_join_no_where_join() {
108
    public function test_qubaid_join_no_where_join(): void {
109
        $qubaids = new qubaid_join("{other_table} ot", 'ot.usageid');
109
        $qubaids = new qubaid_join("{other_table} ot", 'ot.usageid');
Línea 110... Línea 110...
110
 
110
 
111
        $this->check_typical_question_attempts_query($qubaids,
111
        $this->check_typical_question_attempts_query($qubaids,
112
                "SELECT qa.id, qa.maxmark
112
                "SELECT qa.id, qa.maxmark
113
            FROM {other_table} ot
113
            FROM {other_table} ot
114
                JOIN {question_attempts} qa ON qa.questionusageid = ot.usageid
114
                JOIN {question_attempts} qa ON qa.questionusageid = ot.usageid
115
            WHERE 1 = 1 AND qa.slot = :slot", array('slot' => 1));
115
            WHERE 1 = 1 AND qa.slot = :slot", array('slot' => 1));
116
    }
116
    }
117
 
117
 
Línea 118... Línea 118...
118
    public function test_qubaid_list_one_in() {
118
    public function test_qubaid_list_one_in(): void {
119
        global $CFG;
119
        global $CFG;
120
        $qubaids = new qubaid_list(array(1));
120
        $qubaids = new qubaid_list(array(1));
121
        $this->check_typical_in_query($qubaids,
121
        $this->check_typical_in_query($qubaids,
122
                "SELECT qa.id, qa.maxmark
122
                "SELECT qa.id, qa.maxmark
123
            FROM {question_attempts} qa
123
            FROM {question_attempts} qa
124
            WHERE qa.questionusageid = :qubaid5", array('qubaid5' => 1));
124
            WHERE qa.questionusageid = :qubaid5", array('qubaid5' => 1));
125
    }
125
    }
126
 
126
 
Línea 127... Línea 127...
127
    public function test_qubaid_list_several_in() {
127
    public function test_qubaid_list_several_in(): void {
128
        global $CFG;
128
        global $CFG;
129
        $qubaids = new qubaid_list(array(1, 2, 3));
129
        $qubaids = new qubaid_list(array(1, 2, 3));
Línea 130... Línea 130...
130
        $this->check_typical_in_query($qubaids,
130
        $this->check_typical_in_query($qubaids,
131
                "SELECT qa.id, qa.maxmark
131
                "SELECT qa.id, qa.maxmark
132
            FROM {question_attempts} qa
132
            FROM {question_attempts} qa
133
            WHERE qa.questionusageid IN (:qubaid6,:qubaid7,:qubaid8)",
133
            WHERE qa.questionusageid IN (:qubaid6,:qubaid7,:qubaid8)",
134
                array('qubaid6' => 1, 'qubaid7' => 2, 'qubaid8' => 3));
134
                array('qubaid6' => 1, 'qubaid7' => 2, 'qubaid8' => 3));
135
    }
135
    }
Línea 136... Línea 136...
136
 
136
 
137
    public function test_qubaid_join_in() {
137
    public function test_qubaid_join_in(): void {
138
        global $CFG;
138
        global $CFG;
Línea 139... Línea 139...
139
        $qubaids = new qubaid_join("{other_table} ot", 'ot.usageid', 'ot.id = 1');
139
        $qubaids = new qubaid_join("{other_table} ot", 'ot.usageid', 'ot.id = 1');
140
 
140