How do I create and assignment with the Google Classroom API without a dueTime? - google-classroom

I am integrating the Google Classroom platform into our SIS and would prefer not to have to have an assignment dueTime - just a dueDate. I am aware of how to create the assignment otherwise and it is not required when creating the assignment with Google Classroom, but the API requires it. The NULL values return 12AM (once I factor in UTC). Is it possible to not submit dueTime? Thanks!
$service = new Google_Service_Classroom($client);
$post_body = new Google_Service_Classroom_CourseWork(array(
"description" => 'description here...',
"workType" => "ASSIGNMENT",
"title" => 'title here...',
"state" => "PUBLISHED",
"maxPoints" => 'points here...',
"dueDate" => array(
"day" => 30,
"month" => 07,
"year" => 2020
),
"dueTime" => array(
"hours" => NULL,
"minutes" => NULL
)
)
);
$params = array();
$result = $service->courses_courseWork->create($g_class_id,$post_body,$params);

Currently the situation is a described in the documentation:
So you cannot set the dueDate without the dueTime
There is already a feature request asking to implement independent setting - you can give it a "star" to icnrease visibility and hope for sooner implementation.
However, be aware of the fact that when you
create an assignment from the UI without specifying the time as done here:
subsequently retrieve the assignment programmatically with courses.courseWork.list (or courses.courseWork.get)
you will see that the system assigned a dueTime to the assignment:
So, even if you do not specify a dueTime Google Classroom will still create one.

Related

Laravel updateOrInsert with 'OR' or 'AND' operator in first arguments?

While it is possible to have multiple arguments for the updateOrInsert in Laravel query builder and what is the operator used by default.
For example in the documentation it is mentioned:
DB::table('users')
->updateOrInsert(
['email' => 'john#example.com', 'name' => 'John'],
['votes' => '2']
);
Does that mean that email && name are checked or does it mean email || name is checked? How can we control it for one or the other if required?
Please forgive me if this is a silly question or if it is not worded as per the correct vocabulary, as I am new to Laravel. I couldn't find this information in the documentation or API.
updateOrInsert() method is used to update an existing record in the database if matching the condition or create if no matching record exists. Its return type is Boolean.
Syntax :
DB::table('blogs')->updateOrInsert(
[Conditions],
[fields with value]
);
In your query :
DB::table('users')->updateOrInsert(
['email' => 'john#example.com', 'name' => 'John'],
['votes' => '2']
);
It will check if email == 'john#example.com' & name == 'john', then it will update votes=2.

how to update Cart Options in Codeigniter?

Through Documents provided by Codeigniter Its Cart Library doesnt Update its options We can add the Options like that
$data = array(
array(
'id' => 'sku_123ABC',
'qty' => 1,
'price' => 39.95,
'name' => 'T-Shirt',
'options' => array('Size' => 'L', 'Color' => 'Red')
)
);
$this->cart->insert($data);
Is there any other way or any tutorial to learn how we can update options of Cart just like
$qid = $this->input->post("qid");
$pairs = $this->input->post("pairs");
$males = $this->input->post("males");
$females = $this->input->post("females");
$data = array(
array(
'rowid' => $qid,
'qty' => 1,
'options' => array('pairs' => $pairs, 'males' => $males, 'females' => $females))
);
$this->cart->update($data);
I have searched it but seems no one has made any fix for it?
Though I have not found any solution therefore I am using simple solution and that is just rest the item in cart and adding new item with same id and updated option values. Its not great trick though but it is just working for me.
I am fallen yesterday like this kind of problem then i create Extending / Override update function. Here how to Extending Native library Link : Create CI Library
Here is my modified code in Github Link
I hope it will help someone and also can modify as their need.
No it did not work for me.. but there is no any errors, I check the array within the _update function as well,
Array
(
[id] => 177
[rowid] => 66bd8895e10f189f62bf3a65ada83630
[qty] => 1
[options] => Array
(
[vat] => 0
[discount] => 0
)
)
I know i'ts just too late but I want to share my solution:
I just got the the options in an array and updated it as I wanted and then update the entire options field in the cart with the array content.
Hope this help somebody.
Sorry for the english.
The way I tried was a bit difficult but it works. You can’t just update a single option value. To update you have to pass all the existing values to all the option values with the value you want to update as well.
If you want to update your Size option
$data = array(
‘rowid’ => $yourRowIdHere,
‘options’ => array ( ‘color’ => $yourExistingValue, ‘length’ => $yourExistingValue, ‘size’ => $newUpdatedValue)
));
$this->cart->update($data);
Give it a try :)

Order by title without taking into account 'the' in Wordpress (wp_query)

I currently have episodes from a TV Show that feature bands playing, so for example I have:
Moby
The Dandy Warhols
The Kooks
My wp_query looks like this:
$loop = new WP_Query(array('post_type' => 'episodio', 'cat' => '9', 'posts_per_page' => 90, 'orderby' => 'title','order' => 'ASC' ));
But I want to order them like this, alphabetically, without taking into account 'the':
The Dandy Warhols
The Kooks
Moby
There are a lot of records in the database, so it's not very practical and/or efficient to get everything into an array, remove 'the', order again and then going through the array to display the data.
Is this possible in WP? Maybe through a filter?
Thanks a lot in advance! :)
$loop = new WP_Query(array('post_type' => 'episodio', 'cat' => '9', 'posts_per_page' => 90, 'orderby' => 'title','order' => 'DESC' ));
you will get result post title descending of category 9.

What's the BNF of doctrine for?

It looks like a big mess,how does it work as reference?
http://www.doctrine-project.org/documentation/manual/1_1/en/dql-doctrine-query-language%3Abnf
I don't think it's used as a reference by any human-being, actually ; but it might be useful if someone want to use some automatic tool that understands BNF ; for instance, some kind of code generator.
The advantage of BNF being that's it's a formal way to describe a language -- much more easier to understand than english, when you are a program.
For reference :
BNF = Backus–Naur Form
Software using BNF
Edit after the comments : Here's a quick example about the DQL / Object stuff :
Let's consider this portion of code, which is using the object-oriented API to write a query, execute it, and get the results (hydrated as arrays -- prints out only the data, this way, when debugging) :
$result = Doctrine_Query::create()
->select('p.id, p.title, u.login')
->from('Ab_Model_Post p')
->innerJoin('p.User u')
->where('p.codeStatus = ?')
->orderBy('p.date desc')
->limit(2)
->execute(array('OK'), Doctrine::HYDRATE_ARRAY);
var_dump($result);
And here's the kind of output you'll get :
array
0 =>
array
'id' => string '7' (length=1)
'title' => string 'Septième post' (length=14)
'User' =>
array
'id' => string '1' (length=1)
'login' => string 'user1' (length=5)
1 =>
array
'id' => string '6' (length=1)
'title' => string 'Sixième post (draft=7)' (length=23)
'User' =>
array
'id' => string '1' (length=1)
'login' => string 'user1' (length=5)
Of course, this is considering the schema and models classes are OK -- and sorry for the example in french, I used a schema/model/database I set up some time ago for a demonstration of Doctrine, which was in french.
Basically, the DB is for a blogging application, and, here, we :
get some data from posts and the user who posted them
for valid posts
the most recents posts
only two posts
Now, here's an equivalent, using what I meant by "DQL" as in "pseudo-SQL language" :
$result = Doctrine_Query::create()
->query(<<<DQL
select p.id, p.title, u.login
from Ab_Model_Post as p,
p.User u
where p.codeStatus = ?
order by p.date desc
limit 2
DQL
, array('OK'), Doctrine::HYDRATE_ARRAY);
var_dump($result);
No object-oriented API here (well, to write the query, I mean) : I only wrote that pseudo-SQL I was thinking about -- which is what the BNF describes, as far as I can tell.
And, of course, the output of the var_dump is exactly the same as the one I got before.
I hope this makes things a bit more clear :-)
It's Backus–Naur Form, a method of describing context free grammars. See this wikipedia article.

Is it possible to customise drupal node reference and pass your search and a argument from another field

I'm trying to create a bespoke form in drupal, with a node reference field.
I'd like to add a little extra functionality to the node reference auto complete. I've created a view, that contains an argument. I'd like to be able to pass that argument from a drop down as well as the typed text into the autocomplete script.
Does anyone know how I'd start this off.
/* FIELD 1 - the drop down */
$sql = "SELECT nid, title FROM node where type='resourcetype' AND status =1 order by title
";
$result = db_query($sql);
$counter = 0 ;
$options = array();
while ($data = db_fetch_array($result)) {
// krumo ($data);
$options[$data[nid] ] = $data[title] ;
if ($counter ==0 ) {$df = $data[nid]; }
$counter ++;
}
/* FIELD 2 - the node reference field */
$form['sor']['type'] = array(
'#type' => 'select',
'#title' => t('Resource type'),
'#required' =>TRUE,
'#options' => $options,
) ;
$form['sor']['field_asor_sors'] = array(
'#type' => 'textfield',
'#title' => t('Add a SOR item to this job'),
'#autocomplete_path' => 'nodereference/autocomplete/field_asor_sors',
'#element_validate' => array('myelement_validate_is_valid_noderef'),
'#required' =>TRUE,
);
Many Thanks
Matt
AFAIK there is no easy way to do this.
I wanted to do something similar a while ago (using different arguments based on node context), but refrained from doing it, since it would've needed some significant changes of the autocomplete callback logic. You'd need to change several nodereference functions to add support for passing an argument to the initial callback nodereference_autocomplete(), passing it on from there to _nodereference_potential_references(), and finally to _nodereference_potential_references_views(), while ensuring that the changes don't break anything else.
If you want to try nonetheless, you should take a look at the patches in this thread, as they also want to do something like that and might contain some useful hints/examples.
A potentially easier alternative might be to exchange the #autocomplete_path callback of the nodereference field with your own custom version that would generate the result, while adding js logic to your dropdown to add an additional argument to that path when the selection changes.
If you go into the nodereference field configuration form, and scroll all the way to the bottom, there's a fieldset (which may be collapsed) that is titled 'Advanced - Nodes that can be referenced (View)'. You can use this to select a view and have that view be the source of the nodereference choices without writing any new code.

Resources