×
Social Extensions Integration
CBSubs Joomdle and possible redirection
1 year 10 months ago
1 year 10 months ago by Dimitris .
Topic Author
CBSubs Joomdle and possible redirection #1
Hi Antonio,
CBSubsJoomdle allows a user to choose one or more courses in CBSubsPlan.
When user logs in Moodle, the course(s) related to CBSubsPlan are correctly displayed.
What I need to implement is the following:
When user enters CBProfile to be redirected to Moodle in order to complete the mandatory course related to user's plan (set by CBSubsJoomdle).
The first step for this is to check if the user has completed the course. The query for this would be something like:The problem is the next step for php. If checking truthy against 1 plan is easy and all work fine but since plans are 4 and the courses also 4 with 'Yes', 'No' options each, it becomes a bit more complicated.
So before I start writing all these conditions in php, I was wondering if there is an alternative to suggest for this. Maybe implement from within the plugin like in this part below to add an option for the administrator to choose like 'is it mandatory?' and then if mandatory 'yes' redirect the user upon visiting the profile since it is onCPayUserStateChange...
I hope the above can you an idea of what I have in my mind. Any thoughts are much welcome,
Thank you
Edit1 : Analyzing my thought a bit more, I believe that there should also be an index to the courses related to a plan. I mean, what if there are more than one mandatory courses? Then redirection should happen to course with index1 and then after user completes the course there will be another redirection to course with index2, etc
CBSubsJoomdle allows a user to choose one or more courses in CBSubsPlan.
When user logs in Moodle, the course(s) related to CBSubsPlan are correctly displayed.
What I need to implement is the following:
When user enters CBProfile to be redirected to Moodle in order to complete the mandatory course related to user's plan (set by CBSubsJoomdle).
The first step for this is to check if the user has completed the course. The query for this would be something like:
SELECT IF(COUNT(x.`id`) > 0, 'Yes', 'No') AS result
FROM `#__user` AS x
JOIN `#__course_completions` AS y ON x.`id` = y.`userid`
WHERE x.`username` = '[username]'
AND y.`course` = 2;
So before I start writing all these conditions in php, I was wondering if there is an alternative to suggest for this. Maybe implement from within the plugin like in this part below to add an option for the administrator to choose like 'is it mandatory?' and then if mandatory 'yes' redirect the user upon visiting the profile since it is onCPayUserStateChange...
$courses = JoomdleHelperContent::getCourseList ();
$rows = array ();
for ( $i = 0, $n = count( $courses ); $i < $n; $i++ ) {
$rows[$i] = new JObject ();
$rows[$i]->value = $courses[$i]['remoteid'];
$rows[$i]->text = $courses[$i]['fullname'];
}
array_unshift( $rows, moscomprofilerHTML::makeOption( '', CBPTXT::T( '- Select Lists -' ) ) );
if ( isset( $value ) ) {
$newfunc = function ($v) { $o=new stdClass(); $o->value=$v; return $o; };
$valAsObj = array_map( $newfunc, explode( '|*|', $value ) );
} else {
$valAsObj = null;
}
return moscomprofilerHTML::selectList( $rows, ( $control_name ? $control_name .'['. $name .'][]' : $name ), 'size="4" multiple="multiple"', 'value', 'text', $valAsObj, 0, true );
I hope the above can you an idea of what I have in my mind. Any thoughts are much welcome,
Thank you
Edit1 : Analyzing my thought a bit more, I believe that there should also be an index to the courses related to a plan. I mean, what if there are more than one mandatory courses? Then redirection should happen to course with index1 and then after user completes the course there will be another redirection to course with index2, etc
Please Log in or Create an account to join the conversation.
1 year 10 months ago
CBSubs Joomdle and possible redirection #2
I don't understand what you mean.
Do you want to redirect users to Moodle when they open the CB profile? And also based on some "mandatory" conditions....
I am sorry, but I cannot give you any advice, as I don't fully understand your requirements.
Do you want to redirect users to Moodle when they open the CB profile? And also based on some "mandatory" conditions....
I am sorry, but I cannot give you any advice, as I don't fully understand your requirements.
Please Log in or Create an account to join the conversation.
1 year 10 months ago
1 year 10 months ago by Dimitris .
Topic Author
You stated perfectly. That is exactly what I need to implement.
Actually, when the administrator sets a course as "mandatory", then all users who have not completed that course will be redirected to Moodle to complete the course, or they will not be able to visit their CBprofile.
CBSubs Joomdle and possible redirection #3
Do you want to redirect users to Moodle when they open the CB profile? And also based on some "mandatory" conditions....
You stated perfectly. That is exactly what I need to implement.
Actually, when the administrator sets a course as "mandatory", then all users who have not completed that course will be redirected to Moodle to complete the course, or they will not be able to visit their CBprofile.
Please Log in or Create an account to join the conversation.
1 year 10 months ago
CBSubs Joomdle and possible redirection #4
That seems like a new development, not tied to the CBSubs plugin.
You would need a way to define the mandatory courses, and then have a plugin to check and redirect....
You would need a way to define the mandatory courses, and then have a plugin to check and redirect....
Please Log in or Create an account to join the conversation.
1 year 10 months ago
1 year 10 months ago by Dimitris .
Topic Author
CBSubs Joomdle and possible redirection #5
It is done,
Couple of queries to check for the completion of the mandatory courses in relation to the user loged in and then a php that redirects in case queries result in 'No' solved it!
Thanks
Couple of queries to check for the completion of the mandatory courses in relation to the user loged in and then a php that redirects in case queries result in 'No' solved it!
Thanks
Please Log in or Create an account to join the conversation.
1 year 10 months ago
1 year 10 months ago by Antonio Durán.
CBSubs Joomdle and possible redirection #6
Great! I am glad I could help.
Please Log in or Create an account to join the conversation.