Does Moodle cache User Profile Field for activity restriction? - caching

I am trying to restrict access to Moodle course activities based on a user profile field. The profile field tracks eligibility based on other criteria such as whether they have filled in certain important information about their business.
The field is required, locked and set to a default value, although setting it to unlocked made no difference. It is hidden from view in the user profile and signup screen using CSS (because Moodle user profile fields that aren't displayed in the sign up screen don't get a mdl_user_info_data row created when the user is created - but that's another issue). The relevant row in mdl_user_info_data is updated when the user submits a form that I've created. This part works absolutely fine, except that the user still needs to log out and back in again in order for the change to trickle down to the course page (i.e. for them to be able to access the course activities).
It appears that the user profile fields are being cached when the user logs in, and are not being updated. Does anyone know if this is so? And the obvious follow up questions would be - Can I force this cache to be updated and, if I can, how would I go about triggering this?
I'm using Moodle 2.7.3.

The data is cached in the $USER global object (which is, itself, cached on the session data), in the $USER->profile field. You should be able to update the value there or call a function to reload it (I can't remember the function off the top of my head, but it will be in user/profile/lib.php).

Related

Passing page item field value into iframe url in Oracle Apex 5

I'm trying to create and iframe in Oracle Apex 5, it leads to an external website my company is doing business with.
The URL requires account, username and password to be passed in the URL, but that information is different for every user.
I plan on storing the login info in a custom login table and have it populate hidden fields on the iframe page with each user's information.
I'm unsure if I can, and how to, pass those variables from the page items into the URL.
the link's format is:
https://staging.companysite.com/match/login.do?account="account name"&username="username"&password="password"
Any help would be appreciated.
I actually had it correct during testing, but Apex was doing Apex things and not updating the changes.
if anyone ever runs into this issue again, here's the answer.
Make sure that the hidden fields are in the same region as the iframe you're working with and then the page item variable will be &P100_PAGE_ITEM..
That resolved the issue.

Tricky workflow from public page to restricted page with specific conditions

I have a public page with a data-request = onClaim button.
A user can use this button whether he is logged or not
When the user "claims" this page, if certain conditions are fulfilled, the database must be updated and then a specific restricted access page have to be displayed with the new updated datas.
If conditions are not met, user stay on the public page with warning message.
To know if these conditions are met, the user must be logged in (using his account or creating new one)
note:
When the restricted page is displayed by any other way than this button. No specific data is updated
hard to explain, do my best !
Please, How to implement this workflow elegantly (or not)?
development environment:
october 419
rainlab User plugin
debugbar 1.0.8 plugin
sweet alert 1.1.0 plugin
i tried some tricks but according to the xy problem, i prefer don't talk about

Temporary saving data somewhere which can be saved after user registration

I am working on a spring MVC with hibernate project. Below is the database schema for the project. This project is basically about making 'notes' which are divided in various sections and saving them. Also the user can have various 'canvases', thus the column 'canvas number'.
The problem I am facing is, there is public homepage, which is built using HTML, java-script and is used before login. Any user can add,edit,delete on public homepage, but cannot save it in database or the canvas. He/She is redirected to login/registration page. But we want to save all the notes in some sort of buffer so it can be saved directly in database once user logsin/registers completely. Any idea what I can use for the buffer mechanism??

codeigniter loses session due to redirect, is there a way to regenerate it?

I've got a form that has, among other things, a preview button and a submit button. Let's say that the form contains a person's data. Clicking preview will submit the form to example.com/preview and get it opened in a new tab. The preview controller will insert the person's data in a table and, based on the value of LAST_INSERT_ID(), it will redirect to example.com/person/ID. When the redirect occurs, all session data is lost. I want to be able to keep session data so that, upon checking the example.com/person/ID page, the admin user can close it and do some changes to the form or submit it.
I've noticed that storing the session id in a flashdata item won't work, it won't get past the redirect. Also, if i somehow manage to get the session_id past the redirect (although adding it to the url is not what my client wants), I still don't know a way to regenerate the Codeigniter session with it. Another option I've looked into is using Codeigniter Native Session class, but the version I've found on the site is not for Codeigniter 2.0.0.3, and I'm afraid that using it might break something.
Any advice is much appreciated.
The solution was to change my ci_sessions database table fields' collations to utf8_general_ci (the default was latin1_swedish_ci)

How to best handle user state when multiple browser windows share same session?

I have a web application (Java, Websphere, JSP) which allows co-workers to register visitors to various company exhibitions. A user object is stored in the session which records the currently selected exhibition and this is used when entering the details of new visitors.
One user has decided to open a second browser window which seems to share the same session. The user browses to an other exhibition in the second window. This changes the state of the currently selected exhibition. Back in the first window a menu item is clicked: 'List visitors'. The resulting list is a list of visitors to the exhibition selected in the second window.
I know that I could add the exhibition id to every form on every page but my actual scenario is more complicated that the one I have described.
What is your stategy for dealing with this kind of problem?
My first guess would be you can avoid the problem by keeping (or perhaps only identifying) view state in the URL and not the session.

Resources