Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POET - Fixing CI identified errors: https://travis-ci.org/POETGroup/m… #15

Open
wants to merge 1 commit into
base: MOODLE_31_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache

php:
- 5.6
- 7.0

env:
global:
- MOODLE_BRANCH=MOODLE_31_STABLE
- IGNORE_PATHS=amd/src/list.js


matrix:
- DB=pgsql
- DB=mysqli

before_install:
- phpenv config-rm xdebug.ini
- cd ../..
- composer selfupdate
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci dev-poet
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"

install:
- moodle-plugin-ci install

script:
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
- moodle-plugin-ci codechecker
- moodle-plugin-ci codechecker --standard poet
- moodle-plugin-ci csslint
- moodle-plugin-ci shifter
- moodle-plugin-ci jshint
- moodle-plugin-ci validate
- moodle-plugin-ci phpunit
- moodle-plugin-ci behat
- moodle-plugin-ci phpunit --coverage-text
30 changes: 16 additions & 14 deletions block_grade_me.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
class block_grade_me extends block_base {

public function init() {
global $CFG;
$this->title = get_string('pluginname', 'block_grade_me', array());
}

Expand All @@ -48,7 +47,7 @@ public function get_content() {
$PAGE->requires->jquery();
$PAGE->requires->js('/blocks/grade_me/javascript/grademe.js');

// create the content class
// Create the content class.
$this->content = new stdClass;
$this->content->text = '';
$this->content->footer = '';
Expand All @@ -57,11 +56,9 @@ public function get_content() {
return $this->content;
}

// setup arrays
$grader = array();
// Setup arrays.
$gradeables = array();

$excess = false;
$groups = null;

$enabledplugins = block_grade_me_enabled_plugins();
Expand All @@ -85,15 +82,18 @@ public function get_content() {
$gradeables = array();
$gradebookusers = array();
$context = context_course::instance($courseid);
foreach (explode(',', $CFG->gradebookroles) AS $roleid) {
foreach (explode(',', $CFG->gradebookroles) as $roleid) {
$roleid = trim($roleid);
if (groups_get_course_groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
if ((groups_get_course_groupmode($course) == SEPARATEGROUPS) &&
!has_capability('moodle/site:accessallgroups', $context)) {
$groups = groups_get_user_groups($courseid, $USER->id);
foreach ($groups[0] as $groupid) {
$gradebookusers = array_merge($gradebookusers, array_keys(get_role_users($roleid, $context, false, 'u.id', 'u.id ASC', null, $groupid)));
$gradebookusers = array_merge($gradebookusers,
array_keys(get_role_users($roleid, $context, false, 'u.id', 'u.id ASC', null, $groupid)));
}
} else {
$gradebookusers = array_merge($gradebookusers, array_keys(get_role_users($roleid, $context, false, 'u.id', 'u.id ASC')));
$gradebookusers = array_merge($gradebookusers,
array_keys(get_role_users($roleid, $context, false, 'u.id', 'u.id ASC')));
}
}

Expand Down Expand Up @@ -135,7 +135,7 @@ public function get_content() {
}
}
foreach ($graderroles as $roleid => $value) {
if (user_has_role_assignment($USER->id, $roleid) or is_siteadmin()) {
if (user_has_role_assignment($USER->id, $roleid) || is_siteadmin()) {
$showempty = true;
} else {
$showempty = false;
Expand All @@ -144,7 +144,8 @@ public function get_content() {

if (!empty($this->content->text)) {
// Expand/Collapse button.
$expand = '<button class="btn btn-mini btn-primary" type="button" onclick="togglecollapseall();">'.get_string('expand','block_grade_me').'</button>';
$expand = '<button class="btn btn-mini btn-primary" type="button" onclick="togglecollapseall();">' .
get_string('expand', 'block_grade_me') . '</button>';

$this->content->text = '<dl>'.$expand.$this->content->text.'<div class="excess">'.$additional.'</div></dl>';
} else if (empty($this->content->text) && $showempty) {
Expand All @@ -163,7 +164,7 @@ public function cron() {
global $CFG, $DB;
require_once($CFG->dirroot.'/blocks/grade_me/lib.php');

// We are going to measure execution times
// We are going to measure execution times.
$starttime = microtime();

$params = array();
Expand Down Expand Up @@ -193,7 +194,8 @@ public function cron() {
'iteminstance' => $rec->iteminstance,
'courseid' => $rec->courseid
);
$fragment = 'itemtype = :itemtype AND itemmodule = :itemmodule AND iteminstance = :iteminstance AND courseid = :courseid';
$fragment = 'itemtype = :itemtype AND itemmodule = :itemmodule AND '.
'iteminstance = :iteminstance AND courseid = :courseid';
$params = array(
'itemname' => $rec->itemname,
'itemtype' => $rec->itemtype,
Expand All @@ -215,7 +217,7 @@ public function cron() {
}
}

// Show times
// Show times.
mtrace('');
mtrace('Updated block_grade_me cache in ' . microtime_diff($starttime, microtime()) . ' seconds');
}
Expand Down
3 changes: 2 additions & 1 deletion classes/quiz_observers.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public static function question_manually_graded($event) {
$count = $DB->get_record_sql($sql, [$event->other['attemptid']]);
// Delete attempts if all questions are graded for attempt, leave other attempts by user for quiz untouched.
if (empty($count->attempts)) {
$DB->delete_records('block_grade_me_quiz_ngrade', ['attemptid' => $event->other['attemptid'], 'quizid' => $event->other['quizid']]);
$DB->delete_records('block_grade_me_quiz_ngrade',
['attemptid' => $event->other['attemptid'], 'quizid' => $event->other['quizid']]);
}
}
}
3 changes: 2 additions & 1 deletion classes/quiz_util.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public static function update_quiz_ngrade($attemptid = null) {
$attemptsql = "AND qna1.questionusageid = (SELECT uniqueid FROM {quiz_attempts} WHERE id = ?)";
$params[] = $attemptid;
}
$sql = "INSERT INTO {block_grade_me_quiz_ngrade} ( attemptid, userid, quizid, questionattemptstepid, courseid ) SELECT qza.uniqueid, qza.userid, qza.quiz, qas.id, q.course
$sql = "INSERT INTO {block_grade_me_quiz_ngrade} ( attemptid, userid, quizid, questionattemptstepid, courseid )
SELECT qza.uniqueid, qza.userid, qza.quiz, qas.id, q.course
FROM {question_attempt_steps} qas
JOIN {question_attempts} qna ON qas.questionattemptid = qna.id
JOIN {quiz_attempts} qza ON qna.questionusageid = qza.uniqueid
Expand Down
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function xmldb_block_grade_me_upgrade($oldversion, $block) {

}

// grade_me savepoint reached
// Grade_me savepoint reached.
upgrade_block_savepoint(true, 2013022600, 'grade_me');
}

Expand Down
34 changes: 17 additions & 17 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function block_grade_me_array2str($array) {
* @return string $query
*/
function block_grade_me_query_prefix() {
$query = 'SELECT bgm.courseid, bgm.coursename, bgm.itemmodule, bgm.iteminstance, bgm.itemname, bgm.coursemoduleid, bgm.itemsortorder';
$query = 'SELECT bgm.courseid, bgm.coursename, bgm.itemmodule, bgm.iteminstance, bgm.itemname, ' .
'bgm.coursemoduleid, bgm.itemsortorder';
return $query;
}

Expand All @@ -65,7 +66,7 @@ function block_grade_me_enabled_plugins() {
$plugins = get_list_of_plugins('blocks/grade_me/plugins');
foreach ($plugins as $plugin) {
if (file_exists($CFG->dirroot.'/blocks/grade_me/plugins/'.$plugin.'/'.$plugin.'_plugin.php')
and $CFG->{'block_grade_me_enable'.$plugin} == true) {
&& ($CFG->{'block_grade_me_enable'.$plugin} == true)) {
include_once($CFG->dirroot.'/blocks/grade_me/plugins/'.$plugin.'/'.$plugin.'_plugin.php');
if (function_exists('block_grade_me_required_capability_'.$plugin)) {
$requiredcapability = 'block_grade_me_required_capability_'.$plugin;
Expand Down Expand Up @@ -104,11 +105,11 @@ function block_grade_me_array($gradeables, $r) {
function block_grade_me_tree($course) {
global $CFG, $DB, $OUTPUT, $SESSION;

// get time format string
// Get time format string.
$datetimestring = get_string('datetime', 'block_grade_me', array());
// Grading image
// Grading image.
$gradeimg = $CFG->wwwroot.'/blocks/grade_me/pix/check_mark.png';
// Define text variable
// Define text variable.
$text = '';

$courseid = $course['meta']['courseid'];
Expand All @@ -132,8 +133,7 @@ function block_grade_me_tree($course) {

ksort($course);

foreach ($course as $l2 => $item) {
$iteminstance = $item['meta']['iteminstance'];
foreach ($course as $item) {
$itemmodule = $item['meta']['itemmodule'];
$itemname = $item['meta']['itemname'];
$coursemoduleid = $item['meta']['coursemoduleid'];
Expand All @@ -148,11 +148,10 @@ function block_grade_me_tree($course) {
} else {
$gradelink = $modulelink;
}
$moduleimgtitle = get_string('link_mod_img', 'block_grade_me', array('mod_name' => $itemmodule));
$moduletitle = get_string('link_mod', 'block_grade_me', array('mod_name' => $itemmodule));
$moduleicon = $OUTPUT->pix_icon('icon', $moduletitle, $itemmodule, array('class' => 'gm_icon'));

$text .= '<dd id="cmid'.$coursemoduleid.'" class="module">'."\n"; // open module
$text .= '<dd id="cmid'.$coursemoduleid.'" class="module">'."\n"; // Open module.
$text .= '<div class="toggle" onclick="$(\'dd#cmid'.$coursemoduleid.
' > div.toggle\').toggleClass(\'open\');$(\'dd#cmid'.$coursemoduleid.
' > ul\').toggleClass(\'block_grade_me_hide\');"></div>'."\n";
Expand All @@ -163,7 +162,7 @@ function block_grade_me_tree($course) {

ksort($item);

// Assign module needs to have a rownum and useridlist
// Assign module needs to have a rownum and useridlist.
$rownum = 0;
$useridlistid = $coursemoduleid.time();
$useridlist = array();
Expand All @@ -175,7 +174,8 @@ function block_grade_me_tree($course) {

$submissionlink = $CFG->wwwroot;
if ($itemmodule == 'assignment') {
$submissionlink .= '/mod/assignment/submissions.php?id='.$coursemoduleid.'&amp;userid='.$userid.'&amp;mode=single&amp;filter=0&amp;offset=0';
$submissionlink .= '/mod/assignment/submissions.php?id='.$coursemoduleid.'&amp;userid=' . $userid .
'&amp;mode=single&amp;filter=0&amp;offset=0';
} else if ($itemmodule == 'assign') {
$submissionlink .= "/mod/assign/view.php?id=$coursemoduleid&action=grade&rownum=$rownum&useridlistid=$useridlistid";
$rownum++;
Expand All @@ -202,14 +202,14 @@ function block_grade_me_tree($course) {
$userfirstlast = $user->firstname.' '.$user->lastname;
$userprofiletitle = get_string('link_user_profile', 'block_grade_me', array('first_name' => $userfirst));

$text .= '<li class="gradable">'; // open gradable
$text .= '<li class="gradable">'; // Open gradable.
$text .= '<a href="'.$submissionlink.'" title="'.$submissiontitle.'"><img src="'.$gradeimg.
'" class="gm_icon" alt="'.$altmark.'" /></a>'; // grade icon
'" class="gm_icon" alt="'.$altmark.'" /></a>'; // Grade icon.
$text .= $OUTPUT->user_picture($user, array('size' => 16, 'courseid' => $courseid, 'link' => true));
$text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'&amp;course='.
$courseid.'" title="'.$userprofiletitle.'">'.$userfirstlast.'</a>'; // user name and profile link
$text .= '<br />'.userdate($timesubmitted, $datetimestring); // output submission date
$text .= '</li>'."\n"; // end gradable
$courseid.'" title="'.$userprofiletitle.'">'.$userfirstlast.'</a>'; // User name and profile link.
$text .= '<br />'.userdate($timesubmitted, $datetimestring); // Output submission date.
$text .= '</li>'."\n"; // End gradable.
}

if ($itemmodule == 'assign') {
Expand All @@ -218,7 +218,7 @@ function block_grade_me_tree($course) {
}

$text .= '</ul>'."\n";
$text .= '</dd>'."\n"; // close module
$text .= '</dd>'."\n"; // Close module.
}
$text .= '</div>';

Expand Down
3 changes: 2 additions & 1 deletion plugins/assign/assign_plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ function block_grade_me_query_assign($gradebookusers) {
FROM {assign_submission} asgn_sub
JOIN {assign} a ON a.id = asgn_sub.assignment
LEFT JOIN {block_grade_me} bgm ON bgm.courseid = a.course AND bgm.iteminstance = a.id
LEFT JOIN {assign_grades} ag ON ag.assignment = asgn_sub.assignment AND ag.userid = asgn_sub.userid AND asgn_sub.attemptnumber = ag.attemptnumber
LEFT JOIN {assign_grades} ag ON ag.assignment = asgn_sub.assignment AND ag.userid = asgn_sub.userid AND
asgn_sub.attemptnumber = ag.attemptnumber
WHERE asgn_sub.userid $insql AND asgn_sub.status = 'submitted' AND a.grade <> 0
AND (ag.id IS NULL OR asgn_sub.timemodified > ag.timemodified)";

Expand Down
4 changes: 2 additions & 2 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

if ($ADMIN->fulltree) {

$settings->add(new admin_setting_configcheckbox('block_grade_me_enableadminviewall', get_string('settings_adminviewall', 'block_grade_me'),
get_string('settings_configadminviewall', 'block_grade_me'), 0));
$settings->add(new admin_setting_configcheckbox('block_grade_me_enableadminviewall',
get_string('settings_adminviewall', 'block_grade_me'), get_string('settings_configadminviewall', 'block_grade_me'), 0));

$settings->add(new admin_setting_configtext('block_grade_me_maxcourses', get_string('settings_maxcourses', 'block_grade_me'),
get_string('settings_configmaxcourses', 'block_grade_me'), 10, PARAM_INT));
Expand Down
32 changes: 16 additions & 16 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
.block_grade_me dd,
.block_grade_me ul,
.block_grade_me li {
list-style: none;
margin: 0;
padding: 0;
list-style: none;
}

.block_grade_me .gm_icon {
width: 16px;
height: 16px;
float: left;
height: 16px;
margin-right: 4px;
width: 16px;
}

.block_grade_me .cmod {
Expand All @@ -27,19 +27,19 @@

.block_grade_me .module {
line-height: 16px;
position: relative;
padding: 3px 0 3px 20px;
position: relative;
}

.block_grade_me .toggle {
position: relative;
left: 0;
background: transparent url('[[pix:block_grade_me|closed]]') no-repeat 50% 50%;
cursor: pointer;
display: block;
width: 16px;
height: 16px;
float: left;
cursor: pointer;
background: transparent url('[[pix:block_grade_me|closed]]') no-repeat 50% 50%;
height: 16px;
left: 0;
position: relative;
width: 16px;
}

.block_grade_me .toggle.open {
Expand All @@ -51,14 +51,14 @@
}

.block_grade_me .cloakable {
border-top: 1px dotted #ccc;
line-height: 1em;
margin: 0 0 3px 0;
border-top: 1px dotted #ccc;
}

.block_grade_me .gradable {
padding: 2px 0;
border-bottom: 1px dotted #ccc;
padding: 2px 0;
}

.block_grade_me .gradable .gm_icon {
Expand All @@ -74,16 +74,16 @@
}

.block_grade_me .empty img {
width: 15px;
height: 15px;
float: left;
height: 15px;
margin-right: 4px;
width: 15px;
}

.block_grade_me .excess {
color: rgb(205,0,0);
font-weight: bold;
margin-top: 4px;
padding: 4px 16px;
text-align: center;
font-weight: bold;
color: rgb(205,0,0);
}
Loading