Social Extensions Integration

CBSubs Joomdle and possible redirection

  • Dimitris
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago - 2 years 10 months ago #1 by Dimitris
CBSubs Joomdle and possible redirection was created by Dimitris
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:
Code:
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;
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...
Code:
$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
Last edit: 2 years 10 months ago by Dimitris .

Please Log in or Create an account to join the conversation.

More
2 years 10 months ago #2 by Antonio Durán
Replied by Antonio Durán on topic CBSubs Joomdle and possible redirection
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.

Please Log in or Create an account to join the conversation.

  • Dimitris
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago - 2 years 10 months ago #3 by Dimitris
Replied by Dimitris on topic CBSubs Joomdle and possible redirection

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.
Last edit: 2 years 10 months ago by Dimitris .

Please Log in or Create an account to join the conversation.

More
2 years 10 months ago #4 by Antonio Durán
Replied by Antonio Durán on topic CBSubs Joomdle and possible redirection
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....

Please Log in or Create an account to join the conversation.

  • Dimitris
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago - 2 years 10 months ago #5 by Dimitris
Replied by Dimitris on topic CBSubs Joomdle and possible redirection
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
Last edit: 2 years 10 months ago by Dimitris .

Please Log in or Create an account to join the conversation.

More
2 years 10 months ago - 2 years 10 months ago #6 by Antonio Durán
Replied by Antonio Durán on topic CBSubs Joomdle and possible redirection
Great! I am glad I could help.
Last edit: 2 years 10 months ago by Antonio Durán.

Please Log in or Create an account to join the conversation.