Skip to content

Commit

Permalink
Merge pull request #4 from KQMATH/release/0.1.0
Browse files Browse the repository at this point in the history
Release/0.1.0
  • Loading branch information
andstor authored Jul 22, 2021
2 parents 52d4b35 + bd0c591 commit 4a3f96c
Show file tree
Hide file tree
Showing 12 changed files with 531 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
insert_final_newline = true
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
130 changes: 130 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: build

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-18.04

services:
postgres:
image: postgres:9.6
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
image: mariadb:10
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3

strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4']
moodle-branch: ['MOODLE_310_STABLE', 'MOODLE_39_STABLE']
database: [pgsql, mariadb]

steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
path: plugin

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
- name: Install moodle-plugin-ci
run: |
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}

- name: PHP Lint
if: ${{ always() }}
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpcpd

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpmd

- name: Moodle Code Checker
if: ${{ always() }}
run: moodle-plugin-ci codechecker --max-warnings 0

- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc

- name: Validating
if: ${{ always() }}
run: moodle-plugin-ci validate

- name: Check upgrade savepoints
if: ${{ always() }}
run: moodle-plugin-ci savepoints

- name: Mustache Lint
if: ${{ always() }}
run: moodle-plugin-ci mustache

- name: Grunt
if: ${{ always() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit --coverage-clover

- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome

- name: Convert Coverage (clover2lcov)
uses: andstor/clover2lcov-action@v1
if: ${{ always() }}
with:
src: ./coverage.xml
dst: ./coverage/lcov.info

- name: Coveralls Parallel
if: ${{ always() }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.test_number }}
parallel: true

finish:
needs: test
if: always()
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vscode

*.code-workspace
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
language: php

addons:
postgresql: "9.5"

services:
- mysql
- postgresql
- docker

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

php:
- 7.2
- 7.3
- 7.4

env:
global:
- MOODLE_BRANCH=MOODLE_39_STABLE
matrix:
- DB=pgsql
- DB=mysqli

before_install:
- phpenv config-rm xdebug.ini
- cd ../..
- composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
- 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 validate
- moodle-plugin-ci savepoints
- moodle-plugin-ci mustache
- moodle-plugin-ci grunt
- moodle-plugin-ci phpdoc
- moodle-plugin-ci phpunit
- moodle-plugin-ci behat
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
# moodle-block_capquizqtracker
[![build](https://github.com/KQMATH/moodle-block_capquizqtracker/actions/workflows/moodle-ci.yml/badge.svg?branch=master)](https://github.com/KQMATH/moodle-block_capquizqtracker/actions/workflows/moodle-ci.yml)

🐛 Moodle Question Tracker Block plugin for CAPQuiz

**Requires** [QTracker](https://github.com/KQMATH/moodle-local_qtracker) and [CAPQuiz](https://github.com/KQMATH/moodle-mod_capquiz).

This plugin creates a block to be added to [CAPQuiz](https://github.com/KQMATH/moodle-mod_capquiz) activities in order to provide an interface to [QTracker](https://github.com/KQMATH/moodle-local_qtracker).

See [QTracker](https://github.com/KQMATH/moodle-local_qtracker) for further information.

## Documentation
Documentation is available [here](https://github.com/KQMATH/moodle-block_capquizqtracker/wiki), including [installation instructions](https://github.com/KQMATH/moodle-block_capquizqtracker/wiki/Installation-instructions).

## Feedback:
**Project lead:** Hans Georg Schaathun <[email protected]>

**Developer:** [André Storhaug](https://github.com/andstor) <[email protected]>

## License
CAPQuiz QTracker is licensed under the [GNU General Public, License Version 3](https://github.com/KQMATH/moodle-block_capquizqtracker/LICENSE).

## Related

- [CAPQuiz](https://moodle.org/plugins/mod_capquiz) - Computer adaptive practice activity module for Moodle
- [Quiz QTracker](https://moodle.org/plugins/block_quizqtracker) - Moodle Question Tracker Block plugin for Moodle Quiz
113 changes: 113 additions & 0 deletions block_capquizqtracker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Main interface to Question Tracker
*
* Provides block for registering question issues for quiz module
*
* @package block_capquizqtracker
* @author André Storhaug <[email protected]>
* @copyright 2020 NTNU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use \local_qtracker\output\issue_registration_block;
use \mod_capquiz\capquiz;
use \mod_capquiz\capquiz_attempt;

defined('MOODLE_INTERNAL') || die();

class block_capquizqtracker extends block_base {
public function init() {
$this->title = get_string('capquizqtracker_quiz', 'block_capquizqtracker');
}

public function applicable_formats() {
return array('all' => false, 'mod-capquiz' => true);
}

function has_config() {
return true;
}

function get_content() {
global $COURSE, $USER, $PAGE;

if ($this->content !== null) {
return $this->content;
}

if (empty($this->instance)) {
$this->content = '';
return $this->content;
}

$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->text = '';
$this->content->footer = '';

// Get submitted parameters.
$cmid = optional_param('id', null, PARAM_INT);

if (is_null($cmid)) {
return $this->content->text;
}

$capquiz = new capquiz($cmid);

if (has_capability('mod/capquiz:instructor', $capquiz->context())) {
$url = new moodle_url('/local/qtracker/view.php', array('courseid' => $COURSE->id));
$this->content->text = html_writer::link($url, "View issues...");
return $this->content;
}

$currentcontext = $this->page->context->get_course_context(false);
if (!empty($this->config->text)) {
$this->content->text = $this->config->text;
}

if (empty($currentcontext)) {
return $this->content;
}

if ($this->page->course->id == SITEID) {
$this->content->text .= "site context";
}

if (isset($this->config->text)) {
$this->content->text = $this->config->text;
} else {
$this->content->text = html_writer::tag('p', get_string('question_problem_details', 'block_capquizqtracker'));
}

$this->userid = $USER->id;

$user = $capquiz->user();
$quba = $user->question_usage();
$qengine = $capquiz->question_engine($user);
$attempt = $qengine->attempt_for_current_user();
$slot = $attempt->question_slot();

$renderer = $this->page->get_renderer('local_qtracker');
$context = $PAGE->context;
$templatable = new issue_registration_block($quba, [$slot], $context->id);
$this->content->text .= $renderer->render($templatable);
return $this->content;
}
}
52 changes: 52 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Plugin capabilities.
*
* @package block_capquizqtracker
* @author André Storhaug <[email protected]>
* @copyright 2020 NTNU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$capabilities = array(

'block/capquizqtracker:myaddinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
),

'clonepermissionsfrom' => 'moodle/my:manageblocks'
),

'block/capquizqtracker:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,

'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),

'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
Loading

0 comments on commit 4a3f96c

Please sign in to comment.