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

WIP Feature/overviewopendiscussion #137

Open
wants to merge 2 commits into
base: master
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
9 changes: 8 additions & 1 deletion lang/en/moodleoverflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@
$string['answer'] = '{$a} Answer';
$string['answers'] = '{$a} Answers';

// Strings for Overview Pages
$string['overviewdiscussions'] = 'Overview of all started discussions';
$string['overviewposts'] = 'Overview of all posts';
$string['viewdiscussions'] = 'View started Moodleoverflow discussions';
$string['viewposts'] = 'View answers to Moodleoverflow discussions';
$string['showoverviewprofilpage'] = 'Link Overview on Profile Page';
$string['showoverviewprofilpage_desc'] = 'Show Links to Overview Pages in User Profile Page';

// Strings for the readtracking.php.
$string['markreadfailed'] = 'A post of the discussion could not be marked as read.';
$string['markdiscussionreadsuccessful'] = 'The discussion has been marked as read.';
Expand Down Expand Up @@ -465,7 +473,6 @@
$string['your_post_was_rejected_with_reason'] = 'Your post was rejected with the following reason:';
$string['original_post'] = 'Original post';


// Daily mail message.
$string['digestunreadpost'] = 'Course: {$a->linktocourse} -> {$a->linktoforum}, Topic: {$a->linktodiscussion} has {$a->unreadposts} unread posts.';

35 changes: 34 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,40 @@ function moodleoverflow_extend_settings_navigation(settings_navigation $settings
}
}
}

/**
* Insert Overview of discussions and post in the Miscellaneous block in the my profile page.
*
* @param tree $tree tree
* @param stdClass $user user
* @param int $iscurrentuser iscurrentuser
*/
function moodleoverflow_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) {
global $DB, $CFG, $USER;
if (isguestuser($user)) {
// Coopy from forum - the guest user cannot post, so it is not possible to view any posts.
// May as well just bail aggressively here.
return false;
}
if (get_config('moodleoverflow', 'showoverviewprofilpage')) {
$viewdiscussionurl = new moodle_url('/mod/moodleoverflow/viewstartingdiscussion.php');
if (!empty($course)) {
$viewdiscussionurl->param('courseid', $course->id);
}
$discussionnode = new core_user\output\myprofile\node('miscellaneous', 'moodleoverflowdiscussions',
get_string('viewdiscussions', 'moodleoverflow'), null, $viewdiscussionurl);
$tree->add_node($discussionnode);
$viewposturl = new moodle_url('/mod/moodleoverflow/viewcontributingposts.php');
if (!empty($course)) {
$viewposturl->param('course', $course->id);
}
$postnode = new core_user\output\myprofile\node('miscellaneous', 'moodleoverflowposts',
get_string('viewposts', 'moodleoverflow'), null, $viewposturl);
$tree->add_node($postnode);
return true;
} else {
return false;
}
}
/**
* Determine the current context if one wa not already specified.
*
Expand Down
422 changes: 238 additions & 184 deletions locallib.php

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class mod_moodleoverflow_renderer extends plugin_renderer_base {
public function render_discussion_list($data) {
return $this->render_from_template('mod_moodleoverflow/discussions', $data);
}
/**
* Display the discussion list for the viewstartingdiscussion.php.
*
* @param object $data The prepared variables.
*
* @return string
*/
public function render_discussion_started_list($data) {
return $this->render_from_template('mod_moodleoverflow/discussion_started_list', $data);
}

/**
* Display the forum list in the view.php if a discussion needs to be moved to another forum.
Expand Down
5 changes: 5 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
$settings->add(new admin_setting_configcheckbox('moodleoverflow/allowreview',
get_string('allowreview', 'moodleoverflow'), get_string('allowreview_desc', 'moodleoverflow'), 1));

// Allow teachers to enable review before publish.
$settings->add(new admin_setting_configcheckbox('moodleoverflow/showoverviewprofilpage',
get_string('showoverviewprofilpage', 'moodleoverflow'),
get_string('showoverviewprofilpage_desc', 'moodleoverflow'), 1));

$settings->add(new admin_setting_configtext('moodleoverflow/reviewpossibleaftertime',
get_string('reviewpossibleaftertime', 'moodleoverflow'),
get_string('reviewpossibleaftertime_desc', 'moodleoverflow'), 1800, PARAM_INT));
Expand Down
3 changes: 3 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/*
* The discussionlist in the view.php
*/
.moodleoverflowheaderlist {
border-spacing: 0;
}

.moodleoverflowheaderlist th.header.replies .iconsmall {
margin: 0 .3em;
Expand Down
149 changes: 149 additions & 0 deletions templates/discussion_started_list.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{{!
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/>.
}}
{{!
@template mod_moodleoverflow/discussion_list

Moodleoverflow discussion_list template.
The purpose of this template is to render a list of discussions for the view.php.

Example context (json):
{
}
}}

{{! There are no discussions. Print the string that specifies it. }}
{{^hasdiscussions}}
<div class="moodleoverflowdiscussions">
( {{#str}} nodiscussions, moodleoverflow {{/str}} )
</div>
{{/hasdiscussions}}

{{! There are discussions. Start to print the table. }}
{{#hasdiscussions}}

{{#discussions}}
<div class="moodleoverflowdiscussion d-flex border p-2 mb-3" data-moodleoverflow-postid="{{postid}}">
<div class="leftbox text-center mr-2">
<div class="votes text-center mb-1">
{{> mod_moodleoverflow/postvoting }}
</div>
<div class="status moodleoverflow-icon-no-margin">
{{# questionunderreview }}
{{#pix}}i/duration, moodle, {{#str}}pending_review, mod_moodleoverflow{{/str}}{{/pix}}
{{/ questionunderreview }}
{{^ questionunderreview }}
{{#markedsolution}}
<a href="{{teacherlink}}">{{! avoid whitespace
!}}{{# pix}} i/status-solved, moodleoverflow, {{#str}}containsteacherrating, moodleoverflow{{/str}} {{/ pix}}{{!
!}}</a>
{{/markedsolution}}
{{#markedhelpful}}
<a href="{{starterlink}}">{{! avoid whitespace
!}}{{# pix}} i/status-helpful, moodleoverflow, {{#str}}containsstarterrating, moodleoverflow{{/str}} {{/ pix}}{{!
!}}</a>
{{/ markedhelpful }}
{{/ questionunderreview }}
</div>
<div class="d-flex flex-colum flex-wrap justify-content-around">
{{# canreview }}
{{# needreview }}
<div class="reviews my-1">
<a href="{{{reviewlink}}}" class="text-danger bold"
title="{{#str}}amount_waiting_for_review, mod_moodleoverflow, {{needreview}}{{/str}}">
{{#pix}}i/commenting, mod_moodleoverflow{{/pix}}{{ needreview }}
</a>
</div>
{{/ needreview }}
{{/ canreview }}
<div class="replies my-1" title="{{#str}}answers, mod_moodleoverflow, {{replyamount}}{{/str}}">
<span><span class="reply-correction">{{#pix}}i/reply, mod_moodleoverflow {{/pix}}</span>{{ replyamount }}</span>
</div>
</div>

</div>
<div class="w-100 d-flex flex-column justify-content-between">
<div class="d-flex justify-content-between">
<a class="subject mb-3 mr-3" href="{{{subjectlink}}}">{{{ subjecttext }}}</a>

<div class="pt-2 text-right">
{{#cansubtodiscussion}}
<div class="discussionsubscription">{{{discussionsubicon}}}</div>
{{/cansubtodiscussion}}
{{#canmovetopic}}
<div class="discussionmove"><a href='{{ linktopopup }}'>{{#pix}} i/arrow-right, core, {{#str}}movetopicicon, moodleoverflow{{/str}} {{/pix}}</a></div>
{{/canmovetopic}}
{{#unread}}
<div class="mod_moodleoverflow-no-wrap unread-part d-flex align-items-baseline">
<a class="mark-read" href="{{markreadlink}}"
title="{{#str}}markallread, moodleoverflow{{/str}}">
{{#pix}}i/delete, core {{/pix}}
</a>
<a class="d-inline-block mt-3" href="{{ unreadlink }}"
title="{{#str}}amount_unread_posts_in_discussion, mod_moodleoverflow, {{unreadamount}} {{/str}}">
<span class="fa fa-envelope icon mr-0 moodleoverflow-icon-1_5x text-muted">
</span><span class="unread-bubble">
{{ unreadamount }}
</span>
</a>
</div>
{{/unread}}
</div>
</div>
<div class="d-flex justify-content-between flex-wrap moodleoverflow-gap-small">
{{#userlink}}
<a href="{{{userlink}}}" class="user-info d-flex questioner px-2 py-1 align-items-center">
{{/userlink}}
{{^userlink}}
<div class="user-info d-flex questioner px-2 py-1 align-items-center">
{{/userlink}}

{{# picture }}
<div class="user-avatar">
{{{ picture }}}
</div>
{{/ picture }}
<div class="user-details">
{{{ username }}}
</div>
{{^userlink}}
</div>
{{/userlink}}
{{#userlink}}
</a>
{{/userlink}}
<div class="d-flex flex-wrap align-items-center">
<span class="text-muted">Last post:</span>
<div>
<a href="{{{lastpostlink}}}" class="user-info d-flex px-2 py-1 align-items-center">
{{# lastpostuserpicture }}
<div class="user-avatar">
{{{ lastpostuserpicture }}}
</div>
{{/ lastpostuserpicture }}
<div class="user-details line-height-3">
{{{ lastpostusername }}}<br>
{{{ lastpostdate }}}
</div>
</a>
</div>
</div>
</div>
</div>
</div>
{{/discussions}}

{{/hasdiscussions}}
50 changes: 50 additions & 0 deletions viewcontributingposts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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/>.

/**
* Prints a particular instance of moodleoverflow
*
* You can have a rather longer description of the file as well,
* if you like, and it can span multiple lines.
*
* @package mod_moodleoverflow
* @copyright 2017 Kennet Winter <k_wint10@uni-muenster.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

// Include config and locallib.
require_once(__DIR__.'/../../config.php');
global $PAGE, $OUTPUT;
// If invoked from a course show the discussions from the course.
$courseid = optional_param('courseid', 0, PARAM_INT);
$params = array();

if ($courseid) {
$params['courseid'] = $courseid;
}

$PAGE->set_url('/mod/moodleoverflow/viewcontributingposts.php', $params);
require_login();

// Systemwide context as all post in moodleoverflows are displayed.
$PAGE->set_context(context_system::instance());

$PAGE->set_title(get_string('overviewposts', 'mod_moodleoverflow'));
$PAGE->set_heading(get_string('overviewposts', 'mod_moodleoverflow'));

echo $OUTPUT->header();
echo "hello world";
echo $OUTPUT->footer();
Loading